Playing sound with Minim on Pi breaks

Hi Folks, I’ve got a bit of a mystery for you. I’ve got some code that cycles through a folder of audio files and plays them with minim. I’m using the following that gets called in draw to check when one file is done and start the next.

  if(!player.isPlaying() && !inputing && index < lovequestions.length) {
        player.close();
        player = minim.loadFile(language + "/love/questions/" + lovequestions[index]);
        delay(100);
        player.play();
        index++;
        println("Index: " + index);
  }

But after about 9 tracks I get the following error. Sometimes its a few tracks less, sometimes a few more. I know that it is not related to the audio files themselves because they all will play individually, its in trying to play multiple files in sequence that I get the error.

==== JavaSound Minim Error ====
==== Couldn't open the line: line with format PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian not supported.

=== Minim Error ===
=== Couldn't load the file elevator2.wav

It looks like there is/was an issue with Minim breaking after loading 16 sound files, maybe that’s what I am running into? https://github.com/ddf/Minim/issues/45 Thanks for any advice you have!

1 Like

Ok, here’s a potential work around, but it is not an ideal fix - use FilePlayer instead:

  if(!player.isPlaying() && !inputing && index < lovequestions.length) {
        player.close();
        player.unpatch(out);
        player = new FilePlayer(minim.loadFileStream(language + "/love/questions/" + lovequestions[index]));
        delay(100);
        player.patch(out);
        player.play();
        index++;
        println("Index: " + index);
  }
2 Likes