Android:通过单一频道播放单声道声音

时间:2013-10-11 04:50:32

标签: android audio audiotrack

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

0 个答案:

没有答案