Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How does Sound.Position work?  (Read 4074 times)

0 Members and 1 Guest are viewing this topic.

ptrxyz

  • Newbie
  • *
  • Posts: 32
    • View Profile
How does Sound.Position work?
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
How does Sound.Position work?
« Reply #1 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.
Laurent Gomila - SFML developer

ptrxyz

  • Newbie
  • *
  • Posts: 32
    • View Profile
How does Sound.Position work?
« Reply #2 on: June 26, 2009, 01:12:51 pm »
Ah using a mono sound fixed it. Thanks a lot =)