• Advertisement
Sign in to follow this  

Simulating positional 3d sounds

This topic is 4171 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I’m trying to simulate positional 3d sounds. To do this I’ve been using two methods to give an OK approximation. Attenuation: Based on the distance the emitter is from the ear I attenuate the volume Pan: Based on the vector from the emitter to the ear, I use that ratio pan from the left and right speaker. This doesn’t help for sound emitters in front, behind, above and below. Does anyone know how to simulate those effects? -= Dave

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ph33r
This doesn’t help for sound emitters in front, behind, above and below. Does anyone know how to simulate those effects?


Pretty sure the hardware can do this for you if you use a supported library like OpenGL.

Otherwise, I don't know. Perhaps you could just add extra fading for distance. To get more 3D sound with 2 speakers you'd likely have to know waaaaay more math about sound waves than I.

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Palidine
Pretty sure the hardware can do this for you if you use a supported library like OpenGL.

The API I'm using doesn't have support for playing 3d sounds.

Share this post


Link to post
Share on other sites
The listener should have a position, but also an orientation. Using the orientation (a rotation matrix), you can build 3 planes: XY, YZ, XZ.

I guess you could use those 3 planes to caracterize the relative position of the emitter to the listener and pan accordingly. I also guess you need a setup with more than 2 speakers, or you'll have to stick with L/R panning only.

You could also search about the pitch (by bending a channel) property of a sound and try to modulate it.

Share this post


Link to post
Share on other sites
Quote:
Original post by ph33r
The API I'm using doesn't have support for playing 3d sounds.


Alas. I have no answers then. You might want to switch APIs then. My hunch says it's very complicated math to actually make it sound right. dunno... maybe extra attenuation?

Consider a sound emitter movind in an arc in front of your face. At the point directly in front, it's going to be 1/2 the volume from each speaker as a full left or full right sound. I don't know actually that it gets more complicated than that unless you're using a 5.1 speaker system (in which case you need a better API anyway).

-me

Share this post


Link to post
Share on other sites
I can recommend FMod or OpenAL, both are very simple to use and has support for 3D sound.

Share this post


Link to post
Share on other sites
I'm sorry I didn't specify the constraints I'm working under.

- I don't have access to hardware support or another API. This means that using FMOD or OpenGL isn't an option.
- I have only two speakers to work with.

Share this post


Link to post
Share on other sites
Quote:
Original post by skalco6
You could also search about the pitch (by bending a channel) property of a sound and try to modulate it.


I'm not sure I understand what this would accomplish?


Share this post


Link to post
Share on other sites
I've simulated 3D sound on the Nintendo DS, so it's not always a matter of choice of API guys... The basic concept is simple, and the math is fairly easy.

From what I read on the web, the pitch is lower when the sound is far and getting higher as it pass you by. Think of a car...
I've not altered the pitch in our game, but I guess you could toy with it if you have enough time.

Share this post


Link to post
Share on other sites
Quote:
Original post by skalco6
I've simulated 3D sound on the Nintendo DS, so it's not always a matter of choice of API guys...

Cool, I'm working on the PSP :)

Quote:
From what I read on the web, the pitch is lower when the sound is far and getting higher as it pass you by. Think of a car...
I've not altered the pitch in our game, but I guess you could toy with it if you have enough time.

I've got positional distance from the ear already being calculated through attenuation but that doesn't help tell the direction the sound is comming from. It wouldn't help to tell if the sound was above or below you.

Share this post


Link to post
Share on other sites
The pitch won't add any information about where the sound is coming from, but it might add some 'depth' to the simulation.

As handheld systems don't allow more than 2 speakers (speakers or headphones), I don't think it's really think it's possible to do more than volume attenuation and L/R panning.

I suggest you to leave room for front/rear and top/bottom panning in your high-level audio system, as you might use this same code on another system, maybe the PS3, who knows...

Share this post


Link to post
Share on other sites
Quote:
Original post by skalco6
The pitch won't add any information about where the sound is coming from, but it might add some 'depth' to the simulation.

As handheld systems don't allow more than 2 speakers (speakers or headphones), I don't think it's really think it's possible to do more than volume attenuation and L/R panning.

I suggest you to leave room for front/rear and top/bottom panning in your high-level audio system, as you might use this same code on another system, maybe the PS3, who knows...

I'm sure it's possible because I've played FPS games with headphones on and I believe I could tell if the noise was comming from somewhere lower or higher. I think I'll have to go home and see if thats the case.

Share this post


Link to post
Share on other sites
skalco6,
That looks like an awesome article.

ph33r,
Have you Googled yet?
"3D sound" and "spatial sound" return a lot of good links.

Shawn

Share this post


Link to post
Share on other sites
No, in practice you cannot distinguish between above/below/front/back with headphones or two-channel stereo in general. It's actually debatable whether you can do this with just two ears either as the differences are really small. The fact that we can distinguish these sound directions in real life may simply be due to us moving our heads, which we do all the time and especially when determining the direction of a sound.

For example, if you hear a sound that has the same volume and phase at both ears, turning your head slightly will cause the sound to be slightly to the left or right and you can determine whether it's behind you or in front. If turning your head produces a smaller than expected shift in volume and phase difference, it means the sound is either above or below you (which you can in turn determine by cocking your head to the side). This is all automatic of course, so you won't notice it very often... But I've noticed myself doing this in FPS games :)

Share this post


Link to post
Share on other sites
Reading the article I linked in my previous post, I learned about the HRTF.
Quote:
HRTF (Head Related Transfer Function) is a transfer function which models sound perception with two ears to determine positions of the sources in space. Our head and body are actually obstacles modifying the sound, and our ears hidden from the sound source perceive sound signals altered; then the signals proceed to our head to be decoded in order to determine the right position of the sound source in space.
I haven't read much about this function, but I know it's about manipulating the sound in the frequency space, which means using the Fourrier Transform (see FT or FFT). This means heavy data processing, which is usually directly computed on a DSP (Digital Sound Processor) chip.

I really don't know if it's possible, but you might be able to access the PSP's DSP...

Share this post


Link to post
Share on other sites
Quote:
Original post by skalco6
Reading the article I linked in my previous post, I learned about the HRTF.
Quote:
HRTF (Head Related Transfer Function) is a transfer function which models sound perception with two ears to determine positions of the sources in space. Our head and body are actually obstacles modifying the sound, and our ears hidden from the sound source perceive sound signals altered; then the signals proceed to our head to be decoded in order to determine the right position of the sound source in space.
I haven't read much about this function, but I know it's about manipulating the sound in the frequency space, which means using the Fourrier Transform (see FT or FFT). This means heavy data processing, which is usually directly computed on a DSP (Digital Sound Processor) chip.

I really don't know if it's possible, but you might be able to access the PSP's DSP...


Yah, I was reading up on that. That article was a great starting point so thanks for that.

Share this post


Link to post
Share on other sites
This is actually quite a deep topic. You can take is about as far as your technology allows:

If you want to convincingly simulate distance, you'll at least need access to an equaliser. Four bands should get you by. People were talking about changing pitch depending on distance, but this isn't really how it goes. Otherwise an orchestra would have serious trouble keeping in tune without sitting on top of each other.

Materials mediate sounds according to their frequencies. The density of a medium determines how quickly and efficiently sound travels through it. The surface inertia determines which frequencies it attenuates and the hardness, how much it reflects noises.

Put simply, the further away an object is, the more the higher frequencies need to be attenuated. If a sound is passing through a dense medium, such as ground, it will arrive sooner than it would through air. So to simulate a loud sound moving through the air, you need only EQ off the upper frequencies. If the same sound is passing along the ground, you'll get a distinctly different effect: The lower frequencies will arrive soon, relatively unadulterated, whereas the higher ones come upon a delay with a bit of reverb.

The story goes on, and Google will help you, but if you have access to a Fourier transform and a little knowledge of audiodynamics, you can go a long way.

Regards
Admiral

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement