Question

I want to play mp3 file ONLY the right channel. -> left channel, set volume: 0 (muted)

I tried :

public class TestSound {

    private SoundPool soundPool;
    private int id;

    public TestSound(Context context,final float leftVolume, final float rightVolume) {
        soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 100);
        id = soundPool.load(context, R.raw.cat, 1);
        soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {

            public void onLoadComplete(SoundPool arg0, int arg1, int arg2) {
                soundPool.play(id, leftVolume, rightVolume, 1, 0, 1f);                     
            };
        });
    }
}

//execute
new TestSound(getApplicationContext(), 0f, 1.0f); //left vol:0; right:1

Unfortunately, the first channel(left) : very-very silently play the song (not muted), and second channel(right) is good. Why?

Android OS: 2.3.4

Thank you for help!

Was it helpful?

Solution

What you have seems correct, so I'd actually suspect that what you thought was a programming/software problem may actually be a hardware problem. You may simply be getting signal bleed across channels. To test you could try to run this code on the emulator and use recording software to record (digitally) the output and see in a wave editor if the left channel is actually playing.

Alternatively, you could try to compare the other way. Edit your file in a wave editor first to be all on the right channel and listen to it on your device and see if you get bleed into the left.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top