Page 1 of 2

Modifying stereo sound placement

Posted: Thu Jul 12, 2012 5:31 am
by kexisse
Is it possible to change the way sounds are played in stereo with Löve? Is there an external library I could use?

I want to create the illusion of space with sound:
  • Modify volume of left/right depending on sound placement within the world.
  • Muffle sounds.

Re: Modifying stereo sound placement

Posted: Thu Jul 12, 2012 7:29 am
by kikito
I remember someone mentioning that you can only do that with mono sounds.

Re: Modifying stereo sound placement

Posted: Thu Jul 12, 2012 7:33 am
by kexisse
You can only modify mono sounds in that way? That might make sense.
But is there a way to do it with the Löve API? Or through some other means?

Re: Modifying stereo sound placement

Posted: Thu Jul 12, 2012 8:29 am
by kikito
I think you can use Source:setPosition for the position and Source:setVolume for the muffling.

Re: Modifying stereo sound placement

Posted: Thu Jul 12, 2012 3:54 pm
by kexisse
How did I not see this? o.o
Thank you so much!

Re: Modifying stereo sound placement

Posted: Thu Jul 12, 2012 4:11 pm
by Boolsheet
kikito is correct, the positioning of the audio in the 3D space only works with mono Sources.

There's currently an issue with LÖVE 0.8.0 for Windows and Linux. The stereo effect is not be as pronounced as it should be. It's very noticable with headphones. This will be fixed with the next version.

Pitch and volume is all we got. No fancy things like frequency filters.

Re: Modifying stereo sound placement

Posted: Fri Jul 13, 2012 1:27 am
by BlackBulletIV
Ah, this explains why I couldn't get setPosition to work the way it used to.

Re: Modifying stereo sound placement

Posted: Sat Jul 14, 2012 4:33 am
by kexisse
I wrote a quick prototype to test playing sounds depending on their X/Y.

I noticed that the overall volume is modified depending on the X/Y, but the sound is the same in both the left and right speakers.
So even if you move the sound to the left, the right speaker still "hears" the same amount as the left. So it's not true stereo.
I talked to Boolsheet on IRC and he says this is a limitation of the OpenAL library. So I guess there's nothing I can do. Seems kind of a shame though :( I really want sound to be excellent for my game so I guess I'll swap to another game library for my full game.

To use the prototype: Arrow keys to modify x/y, space to play sample.
Also there's a bug somewhere, the sound stops playing sometimes.

Re: Modifying stereo sound placement

Posted: Sat Jul 14, 2012 5:29 am
by Boolsheet
Possible OS X bug? Oh nooo! :o

Re: Modifying stereo sound placement

Posted: Sat Jul 14, 2012 5:39 am
by dreadkillz
Your demo works for me. I move the source left and it plays on the left right speaker only and vice versa for the right side. Sound volume is also attenuated based on distance. Bug on your end maybe?