I have a procedural FM Synth that I would like to use in my games, and am wondering how I would go about playing it via AudioNode. I see how it is possible to play a sound from a file or from memory, but what if I have created my own PCM stream? (16-bit, 44100 fps, stereo)
In Java, I’m using SourceDataLine as my output. What should I use here? Is this sort of thing supported?
Check out WAVLoader or OGGLoader from the JME code. Would it be possible to create a FMSynthLoader and fake a resource to load. Register the loader e.g. “.fmsynth” and create a fake resource to load. And just feed the stream? Not very elegant, but might work.
The AudioStream class requires an InputStream which can generate audio data. You can create an AudioStream, specify the format of the data, pass an InputStream which generates data in the format, then play() that stream.