Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to get some music to play back in stereo in libGDX, but it seems to be blending the left and right channels so much that it sounds like it was mono.

To test this out I made a sound file that is just me saying "left" in the left channel and "right" in the right channel. After playing this through libGDX's music class it has blended the channels to the point where the difference is only slight. This is much more noticeable with stereo music where the difference is smaller to begin with.

Here are the sounds themselves. The first one is the input file as I recorded it, and the second is the output recorded from the game:

http://www.jimmakesgames.com/leftRightInput.wav

http://www.jimmakesgames.com/leftRightOutput.wav

You can hear the difference very clearly with headphones. I've looked high and low and can't find anything about this. The libGDX audio stuff seems to be pretty much a black box. The only reference I found to setting stereo or mono is with the newAudioDevice method which is only for writing PCM data directly.

I'm pretty desperate at this point, so if anyone can offer some assistance it would be greatly appreciated. Thanks.

share|improve this question
    
Can a framework called Mono provide stereo capabilities? ;-) –  danijar Apr 7 '13 at 8:02
add comment

1 Answer 1

I'm not sure how libGDX blends the audio because in the source its precompiled code. However I did try something that may or may not be something that could help you. I took your leftRightInput.wav file and split up the tracks into two separate files. One for the left channel and one for the right channel (I used Audacity). I loaded them both as Music objects then I lowered the right channel's volume a bit to try to better distinguish between the channels.

Music left = Gdx.audio.newMusic(Gdx.files.internal("left.wav"));
Music right = Gdx.audio.newMusic(Gdx.files.internal("right.wav"));
right.setVolume(0.5f);
left.play();
right.play();

Maybe give this a try and see if it will fit your needs. If not I would suggest posting directly on the libGDX forums and see if they plan to expand on the Music and Sound classes.

share|improve this answer
    
Ah, an inventive approach. This could work, but fortunately I recently reported it as a bug on the error tracker and got a very quick response. Apparently it is an issue with OpenAL and the fix has already been accomplished. It just needs to work its way up the chain through LWJGL to libGDX and that should hopefully be soon. So no workaround should be necessary. But thanks for your suggestion. –  Jim Makes Games Apr 7 '13 at 5:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.