Hi all,

I'm currently trying to use the AudioTrack class to play a sound
sequence.

Here is a brief description of what i'm doing.
I'm launching a Thread which runs as a daemon and generates a sound
every 500ms.

To generate the sound :
- I instanciate an AudioTrack class in MODE_STATIC, with a buffer size
equal to the size of the byte array i'm going to play.
- I write the raw PCM data as a byte array once.
- I call play the first time i have to play the sound, and then the
only way i managed to replay it is by calling stop(), reloadStaticData
(), setPlaybackHeadPosition() and play() again.

Now let's say i want to play this sequence for 2s.
I press the start button, the Thread runs an infinite loop and calls 4
times the method which plays the sound, then i press the stop button.
I should hear the sound played 4 times, but in fact i hear it 6-7
times.

What am i doing wrong ?

I'm new to Java and Threads, and i can't identify if this is a kind of
synchronization problem or if it comes from my AudioTrack usage.

I'm using MODE_STATIC because in MODE_STEAMING the write method is
blocking and i can't play a sound which is more than 500ms long.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to