Android Question AudioStreamer custom data


Well-Known Member
Licensed User
Longtime User
I see the new AudioStreamer Object. This looks perfect.

I have an application from long ago that outputs audio data. The source of the data is a Wav file containing a sampled sine wave or chirp that I generated in code. Previously I had used SoundPool to loop continuously playing this data. There were several problems: it worked on my devices but sometimes not on the customer's devices, there may be a "glitch" when the data looped around and repeated, and Android 4.3 has a known looping bug.

I generate my own data, rather than capturing from the microphone. I would like to create "buffers" of data and feed them to the streamer. Is the data format in each buffer simply waveform samples (stereo or mono, at the sample rate and word size requested during initialize)? Or, does each buffer have some sort of header – like a wave file header?

I will continuously create the waveform data and feed it to the audio streamer for as long as the user requests – this could be 5 seconds or a few hours.

I see the "streamer.PlayerBufferSize" – so I know how big the data buffers can be. The question is "how many buffers are needed?". I could use a timer set for, say 5 seconds, and create and write 5 seconds worth of buffers then if the user is still playing my sine wave, replenish the streamer with another 5 seconds of buffers when the timer ticks.

Another way to accomplish creating the correct number of buffers would be to check the number of buffers remaining to be output within the streamer's queue. When the number of buffers remaining falls to some threshold, create and write a bunch of new buffers. I think this method would be preferable. Is it possible to check the number of buffers remaining in the streamer's queue?

The AudioStreamer looks really nice – tons of potential applications. I could not find documentation in the online Audio library documentation. Are there any more events that are not included in the example? Is there a description of the buffer data format?