我正在尝试通过单个通道播放单声道声音,我唯一能想到的是将第二个通道交织到字节数组中,更改AudioFormat
为立体声然后调用
audioTrack.setStereoVolume(leftVolume, rightVolume);
将一个通道的音量设置为零。有没有更简单的方法?
回放:
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){ }