OpenAL - play from byte array

I’m exploring using Pure Data ( or specifically libpd (GitHub - libpd/libpd: Pure Data embeddable audio synthesis library) with jME and was considering how OpenAL could be used to play from a PD patch. However, as I’ve not worked with OpenAL before, I couldn’t find a simple method like “write(byteArray, offset, length)” as in Java Sound.

Is there a simple way to play sounds from a byte array with OpenAL (or with AudioNodes) or should I stick with Java Sound?

If you use AudioStream (a subclass of AudioData, which gets used in an AudioNode), you can use the updateData method to give it an InputStream

1 Like

Thanks, I tried that, but I can’t quite figure out how to feed more data to the stream being played from, as I can’t use updateData more than once. PD continuously processes data and produces sounds, sometimes in response to inputs, so the audio stream needs to be continuously refilled. It feels like it shouldn’t be too difficult and perhaps I’m just too tired to see it right now.

You might have to look in the JME source code to see how normal streaming works.

You will need to create your own subclass of InputStream. updateData() will be called once and your stream subclass will need to generate additional audio when it comes.