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 would like my game to have semi-realistic sound, where the left/right channel volume depends on the position of the sound source within the world.

I've looked and it seems that it's not possible with Löve2d or pygame. They modify the volume of a sound based on distance, but the left and right channels are identical.

Am I wrong? Are there any other 2d game libraries that make this possible?

share|improve this question
    
The title is a bit confusing... Are you looking for 2d game libraries, or positional sound libraries? –  Marton Jul 14 '12 at 6:49

2 Answers 2

Check out SFML (C++ or .net), supports 2D/3D sound spatialization.

This is an old tutorial (2.0 changes API quite a bit), but it gives an example.

The 2.0 documentation has functions for GetPosition and such, so it should be easy to implement.

Edit: According to this and this, you are not wrong in thinking that the two mentioned libraries do not support what you want.

share|improve this answer
    
To Sara: there are mono and stereo recorded sounds, you cannot play stereo sound data from a direction. Like many areas of game programming you have to be precise about what data you're working with and what operations you plan to do on them. If you come around to checking out this example please be careful of your audio data so that everything works as expected. –  Patrick Hughes Jul 14 '12 at 15:02

There is no such thing as positional stereo sound. Audio in stereo formats are pre rendered audio scenes where the listener is at one specific position. It's basically a lot mono channels at different positions mixed together to one. So to get a high quality sound experience you would need all those mono channels and position them where they actually come from. (For example the drum sounds would come from the position where the drum stands, as simple as that.)

You could also split the stereo audio file up into two mono sounds you put into different positions. That isn't realistic but maybe is a good approximation.

share|improve this answer

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.