SFML community forums
Help => Audio => Topic started by: Astrof on March 05, 2009, 06:13:03 am
-
I'm having trouble getting the SetPosition thing to work. I'm thinking my problem is my z value, but I'm not exactly sure. I define a position by doing a sound.setPosition(x,y,0), x and y being the position of the drawable at initialization. I tried changing the 0 to a 1 or a -1 and it still didn't work (no sound was played). what am I doing wrong? It's probably something real stupid...
-
In 3D, Y is the "up" vector. I guess you want to use X and Z to map your 2D view.
-
oh makes sense, thanks!
This is the reason why I stick to 2D game programming...I'm directionally dyslexic.
EDIT: What do I have to set the Y value then to get it to work? It still doesn't play the sound when I do sound.SetPosition(x,value,y) where value is a number (I tried 0,1,-1,100,etc).
-
If you can show me a minimal and complete example that reproduces the problem, I'll try it myself.
-
I just do:
sound.SetPosition(x,value,y);
where value is a value that I experimented with and x and y are the initial position of the object on the screen.
I did a quick test on a test program and it seems that only small values seem to work. (It seems that If the x and y values go too far away they are just not heard).
What units are a sound's position measured in? Because I think I'm using pixel positions to try to map them. Also is 0,0 the Center of the screen (this could also be a problem with my current code)?
-
There's no absolute unit. The origin is given by position of the listener, and the "scale" is given by the attenuation. Just find the proper values for your application.
-
I found a very useful homepage where 2D sound spatialization with SFML (!) is explained. I thought I'd share it, in case one should come across this thread.
-> Link (http://blog.tbam.com.ar/2009/05/sound-spatiaiization-for-2d-games-in.html)
-
Wow that article is really helpful, thanks!
-
Yey! I wrote that :D
I'm glad it helped!
You might encounter some degree of engrishness :P
-
Yey! I wrote that :D
I'm glad it helped!
Ah, I didn't know that. Very nice work, thanks a lot. :)