Simulating a moving sound source perceived by a listener on a 2d plane.
I want to simulate a basic moving sound source and a ‘microphone’ on a 2-dimensional Cartesian plane. The plane will range from, say, -10 to 10 on both axes, and the sound source/listener will both be somewhere along those lines.
Then I want to be able to calculate the perceived amplitude and Doppler effect when the sound source moves away from, or closer to the microphone, in both directions.
Doing the Doppler effect is a piece of cake, I use a delay line and change the time of the delay to change the wavelength of the sound.
The problem that I’ve run into is that I don’t know how to do the AM math. I’ve came up with this formula for amplitude modulation across a single direction
Amplitude = 1 / (Sound position - Ear position)
This works okay-ish with the case I’ve demonstrated but the closer it gets to the sound source, the higher risk it is at to explode. This is because the result of (Sound position - Ear position) gets closer to 0 the closer they are in values, and 1 div 0 is theoretically infinity, which is just interpreted as 0 by Reaktor.
When I try to do this along 2 axes, with both the sound emitter and the microphone having 2 values corresponding to the X and Y axes, it doesn’t work as intended.
I want to do the same thing that game engines like Unity do to manage sound AM, but across a 2-dimensional plane and in Reaktor.
Comments
-
I would add small number into the bracket, than it would not go to 0 in any case. Maybe adding 1 would be sound. It would mean, that xy plane is 1 m away from listener/source.
0 -
@Laureano Lopez doesn't your project in the UL kinda deal with that?
https://www.native-instruments.com/en/reaktor-community/reaktor-user-library/entry/show/14421/
1 -
Maybe this helps.
0 -
Pretty sure the energy drops off with the square of the distance not just linearly (Could be the cube?)... you'll probably need to scale the volume, and add that minimum offset as suggested by kubrak...
Amplitude = 1 / (minimum + Sound position - Ear position) ^ 2
0 -
It is second order, I forgot mention that earlier, also...
Amplitude = 1 /(minimum + (s1-l1)^2+(s2-I2)^2) where s1,s2 are coordinates of source and I1,I2 coords of listener.
--------------------
The distance of source and listener is sqrt( (s1-l1)^2+(s2-I2)^2 ) .... euclides
So squared it is (s1-l1)^2+(s2-I2)^2.
0 -
And don't forget there are two listeners at different positions... left ear and right ear!
1 -
Is it something like Absynths Pipe effect?
0 -
. . . . . .
0 -
I am sad that laureano lopez redacted his comment
0 -
It is annoying though when you put the effort in and the op doesn't respond
1 -
agreed. but it was a wonderful response and it was gone before I was able to draft a reply :/
0 -
I agree, it is a pitty. Generally it was that the amplitude is proportional to 1/d and not to 1/d^2 as we thought.
And he had smart solution to smooth aproaching to limiting distance. Do not remember well, but it was about power to four and to 1/4 after that.
0 -
Hmm iirc he said the sound pressure was 1/d but there was some other thing that was 1/d^2... can't remember exactly what is was though...
0 -
Yes, but if I remember it correctly in this doppler case it should be 1/d. Otherwise it would not be 4th root of sum of powers of four. It would be squareroot of powers of four.
Sorry, I do not know the exact mathematical terms in english.
0 -
Sorry, I thought it was too long and didn't have the time to revise it... It's annoying not being able to actually delete comments though -.-
Hmm iirc he said the sound pressure was 1/d but there was some other thing that was 1/d^2
Yep, sound intensity is inv. proportional to the squared distance but sound pressure only to the linear distance, and the amplitude of an audio signal represents pressure.
it was about power to four and to 1/4 after that
I used d' = (d^4+min^4)^(1/4) on the plain distance d = (x^2+y^2)^(1/2), which turns zero into min with a soft curve and fast convergence. Simplifying d into d' gives ((x^2+y^2)^2+min^4)^(1/4), which is the actual code in the distance | abs macro. Gain is then computed as min/d' to have unity gain at min distance.
1
Categories
- All Categories
- 19 Welcome
- 1.4K Hangout
- 60 NI News
- 742 Tech Talks
- 3.9K Native Access
- 16K Komplete
- 1.9K Komplete General
- 4.2K Komplete Kontrol
- 5.5K Kontakt
- 1.5K Reaktor
- 367 Battery 4
- 819 Guitar Rig & FX
- 419 Massive X & Synths
- 1.2K Other Software & Hardware
- 5.5K Maschine
- 7K Traktor
- 7K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators