# Spatial Audio (Ambisonic) and calculating sound source position

I have 4ch Spatial Audio (Ambisonic) WAV file and I want to calculate sound source position and put it on 2D plane.

What I know so far is the following:

WAV file consists of signals that support of 360 video playback

• Channel 1 = omnidirectional sphere (named W: $$w(t) = p(t)$$)
• Channel 2 = left-right dipole (named Y: $$y(t) = \sqrt{2}p(t)\sin(a)\cos(b)$$)
• Channel 3 - has no data
• Channel 4 = front-back dipole (named X: $$x(t) = \sqrt{2}p(t)\cos(a)\cos(b)$$)

How to calculate sound source position at any point of time using these data?

Edit:

calculation like this gives mess:

theta = Math.Atan2(y, x);
px = r * Math.Cos(theta);
py = r * Math.Sin(theta);


Edit 2:

So imagine we have Spatial Audio/Ambisonic/B-Format WAV file and we need to draw/visualize a microphone in the center of screen and a sound source around the microphone at any time reading WAV file

Edit 3:

We use H2n SPATIAL AUDIO mode that gives 1 WAV file with 4 Channel Using the suggested wiki-formula here is our result for first 1000 ticks using MatLab (does not look proper): • what are you computing ? i know "sound source position", but which parameter is it ? – Ahmad Bazzi Feb 14 '19 at 12:30
• we need to find any parameter for source position, for example angle 0-360 degrees around microphone or X and Y relative to center of circle/sphere – okarpov Feb 14 '19 at 13:02
• so we need to draw a microphone and sound source around it at any time reading Ambisonic WAV file – okarpov Feb 14 '19 at 13:11

I know nothing about Ambisonic decoding, but the Wikipedia page suggests: $$p(\theta_n) = w(t) + x(t) \cos(\theta_n) + y(t) \sin(\theta_n)$$ Perhaps you could form that and vary $$\theta_n$$ to find the direction of highest power?

Note: I realize that's not what the page is really saying. It's saying that this is the signal to feed to a speaker at $$\theta_n$$... but that seems similar to finding the directionality of the source. Also note that it does not find the distance of the source, just the $$x-y$$ plane angle.

• we need to get angle or x and y 2d coordinates from the WAV file. not sure what does this formula/wikipage explain really – okarpov Feb 14 '19 at 14:21
• @okarpov : It will get you the angle: find the angle at which the $p(\theta_n)$ is largest. – Peter K. Feb 14 '19 at 17:29
• we have tested your suggestion and formula - bet seems not really promising @peter-k – okarpov Feb 15 '19 at 10:33
• @okarpov OK! Thanks for posting the image of the result. I'm wondering if the sound field recording has a single source, or multiple sources? – Peter K. Feb 15 '19 at 15:12
• this is a record of meeting with a few people talking around H2n Zoom microphone on a table – okarpov Feb 15 '19 at 17:13

That's tricky, especially if it's an in-room recording and not anechoic. In a room, the energy at the microphone is typically dominated by the reflections and not by the first arrival.

Here is what I would try

1. Look through the omni channel and see if you can find identifiable events: best are broad band transients after some quieter passages. Claps, plosives, pops, hits, something like this
2. Cross correlate the dipoles with the omni channel. Determine amount and phase of correlation.
3. Do inverse geometry using the correlation values. E.g. if it's negatively correlated with the left-right dipole but uncorrelated with the front back dipole it's coming from the right
4. Total amount of correlation gives you an estimate for elevation and the ratio of the correlations can determine the azimuth. It'll be noisy though.

You can only resolve one hemisphere, you can't distinguish between up and down. That's obvious from your original equations: if you flip the sign of $$b$$, nothing changes.