We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a folder of .wav files that are played sequentially by the sketch. This works fine, but after a while, the sound starts to gradually degrade until the sketch runs out of memory (as shown in VisualVM).
// Load the audio file
sound = new FilePlayer(minim.loadFileStream(outputFilename + ".wav", 512, true));
// Patch the audio into minim
sound.patch(mainOut);
// Play the file
sound.play();
The variable 'outputFilename' changes periodically, so it refers to a different sound file. There are about 45 of these, so I can't use the AudioSample class, which seems to be limited to a max of 30 files.
Can you recommend a good way of handling large amounts of small audio files, and how do you correctly clean up a file after its use?
Answers
The FilePlayer has a close() method. Are you calling that when each sound is done playing?
When assigning a new value to sound you will first want to unpatch it from mainOut and close() it. If you leave the old sound patched to the mainOut will not get garbage collected because the output has a handle on it. Also it will still be needlessly generating.