我试图通过单个声道播放单声道声音,我唯一能想到的是将第二个声道交织到字节数组中,将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){ }