I am trying to play a mono sound through a single channel, the only thing I can think of is interweaving a second channel into the byte array, changing AudioFormat
to stereo then calling
audioTrack.setStereoVolume(leftVolume, rightVolume);
to set one channel's volume to zero. Is there a simpler way?
Playback:
AudioTrack audioTrack = null; // Get audio track
try {
audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
sampleRate, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, (int)numSamples*2,
AudioTrack.MODE_STATIC);
audioTrack.write(generatedSnd, 0, generatedSnd.length); // Load the track
audioTrack.play(); // Play the track
}
catch (Exception e){ }