I'm working with some digital sound generation, and I want to work with making 3d sound- in other words, taking a pregenerated wave and using audio delay and slight amplitude differences to make it sound like it is coming from some position described with x y variables. I am a sufficient programmer, and I can make it happen, but I have no idea how to do the calculations for this. I know that 3d sound simulations can be made, video games do it all the time- an explosion will occur and the sound will seem like it is coming from the explosion. I just wanted to know if there was an algorithm or formula for calculating what each ear hears. I'm new to this community, so let me know if my question needs updating.
1 Answer
It's not so much about what the ear hears, it's more about what the speakers reproduce. In the first instance, you should investigate panning law. This is about ensuring that when you have more than one speaker reproducing a sound at the same time, that the overall level stays equal no matter how much of that sound is being reproduced at any time through any speaker.
For instance, if you have two speakers, A and B reproducing a sound at an overall 0dB (relative) the following is true:
- if attenuation (A)=0dB then attenuation (B)= inf dB (nothing)
- if attenuation (B)=0dB then attenuation (A)= inf dB (nothing).
So basically, if A is on full level then B is off, and if B is on full level then A is off.
IF both A and B are on, then they are at -3dB (3dB attenuation)
If you were to draw a graph it might look like this.
I recommend reviewing the following link for more detail, which discusses issues around maintaining a constant level and the possible different panning laws. No point in me reinventing the wheel when there is a good reference document to review:
-
Thanks! Working on a stereo simulation, I'll probably post it when/if I finish Commented Apr 1, 2020 at 21:09