You are using AudioTrack.MODE_STATIC, designed for short sounds and low-latency requirements, while you should use AudioTrack.MODE_STREAM. AudioTrack.MODE_STREAM is for longer streams, but I don't know how long your samples are. So you can try changing AudioTrack:
audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, generatedSnd.length, AudioTrack.MODE_STREAM);
In addition, AudioTrack requires a buffer size in bytes, the multiplicity must be multiplied by two in order to calculate the correct number of bytes needed. You can hack it like this:
audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, generatedSnd.length*2, AudioTrack.MODE_STREAM);
jobbert
source share