I am using Audio track to play a different sounds, in stream mode. I would like to know if there is a way to know when each sound beings/ends playing.
I create the audio track like this:
AudioTrack tmpAudioTrack = new AudioTrack(
STREAM_TYPE,
SAMPLE_RATE,
CHANNEL_CONFIG_TYPE,
AUDIO_FORMAT_TYPE,
getOptimalBufferSize(),
AUDIO_TRACK_MODE);'
And start it in a background thread:
backround_thread = new Thread(new MyRunnable(aTrack));
backround_thread.start();
I write each sound like this inside the runnable:
byte generatedSnd[] = new byte[2 * beepSamples];
<code for filling the buffer with sound here>
int bytesWritten = track.write(generatedSnd, 0, generatedSnd.length);
It is possible to use any of the AudioTrack APIs such setNotificationMarkerPosition, or setLoopPoints, or setPositionNotificationPeriod to accomplish this? and how do they work?
Each sound can be different duration of time. I think this is key.
I don't fully understand the documentation for these APIs. Is each frame the same as a sample? How do I specify a marker for where each sound begin/end?
Thanks,