SFML community forums

Help => Audio => Topic started by: ptrxyz on June 25, 2009, 06:01:50 pm

Title: How does Sound.Position work?
Post by: ptrxyz on June 25, 2009, 06:01:50 pm
I got an Sound.Object playing a stereo sound from a Soundbuffer.
Now I want to set the .Position property. But what scales are expected for the vector's elements? Is it something between 0..1.0? Or maybe something like 0..1000?
I tried to produce some kind of 2D-Sound: If a rocket flies by on the left side the sound should be much louder on the left side then on the right side. I made it like this:

Code: [Select]

With New Sound (daBuffer)
    .Position = New Vector3((rock_x-self_x)/app.width, (rock_y-self_y)/app.height, 0)
    .RelativeToListener = true
    .Play()
End With


So, rock_XY=Rocket, self_XY=listener. The .Position gets a new value relative to the listener and by setting .RelativeToListener that should be applied to the sound.
But sadly the volume on both speakers is the same...so no 2D-Sound =(
Am I doing wrong or isnt it supposed to support that?

PS: rock_XY and self_XY are screen coordinates, so vector3.X and .Y are between 0...1.
Title: How does Sound.Position work?
Post by: Laurent on June 25, 2009, 07:05:13 pm
You must have a mono sound to enable spacialization ;)

Regarding the values, it depends on how you setup the listener, as well as the attenuation / min distance. Look at the corresponding tutorial if it's not clear.
Title: How does Sound.Position work?
Post by: ptrxyz on June 26, 2009, 01:12:51 pm
Ah using a mono sound fixed it. Thanks a lot =)