# Frequency response of a microphone using a sine sweep

I want to determine the frequency response (magnitude, phase) of a microphone. I have another "good" reference microphone whose frequency response I know.

I understand that I can use a good speaker and measure the two mics simultaneously using white noise. Regarding the magnitude response, I can estimate the power-spectral densities by a method of averaged periodograms. Next, I can find the magnitude response of the device under test by subtracting the power spectral densities in logarithmic scaling and adding the known magnitude response of the reference microphone.

1. Averaging over periodograms seems necessary to control the variance of the periodogram estimator. But what about the phase response? Does a similar inconsistency exist for the angle of the fft also?

1. If I use an exponential sine sweep $$x(t) \propto \sin(\omega_0 e^{a t} t)$$, how do I obtain the frequency response? Do I average over the entire measurement time or do I do no averaging at all?

Edit: I did not explicitly state but implied that I perform the measurements in an anechoic room.

• you also need to consider that the room you test in has a response as well.
– user28715
Jul 27, 2019 at 1:32
• Could you simply generate n sine waves at n different frequencies and measure the phase and gain (attenuation) ? The old HP 35665A Dynamic signal analyzer had different modes to measure the frequency response (impulse, chirp, swept sine) and I always found that swept sine was the most precise. keysight.com/en/pd-1000001333%3Aepsg%3Apro-pn-35665A/…
– Ben
Jul 27, 2019 at 3:27
• This would seem to be a simpler application of room acoustic measurements - where typically log sweep sines or maximum length binary sequences are used. Perhaps reusing that methodology is less work than reinventing the wheel? Apr 22, 2020 at 18:15

Say $$\mathbf{h}_1$$ and $$\mathbf{h}_2$$ are the impulse response coefficients of mic1 and mic2, respectively, where $$\mathbf{h}_1$$ is known. Let $$\mathbf{x}$$ represent the input signal. Then, we can write the output of mic1 as

\begin{align} \mathbf{b} = \mathbf{X} \mathbf{h}_1 \end{align} where $$\mathbf{X}$$ is a Toeplitz matrix. If you want to find the impulse response coefficients of mic2, then you need to solve the following optimization problem \begin{align} \arg \min_{\mathbf{h}_2} ||\mathbf{X} \mathbf{h}_2 - \mathbf{b}||^2_2 \end{align}

The solution to the above problem is a simple least-squares solution. In the above formulation, I tried to express the convolution operation as a matrix multiplication. Find the filter coefficient response and express the transfer function in terms of $$H_2(z)$$. Once you know the transfer function, it is easy to determine the magnitude and phase response.

• Are you sure about the least-squares criterion? Wouldn't the solution be $\textbf{h}_2 = \textbf{h}_1$? Jul 27, 2019 at 7:51
• @Crenguta I fixed the solution. Thanks for pointing out the trivial case. Jul 27, 2019 at 15:42

Assuming that your microphones and speaker set up is such that you don't have echos or noise from external sources, you could use the cross FFT.

Its output gives you the comparison of two signals. If the two are identical, you get a flat line. Multiply that line with the known response of the reference microphone, and you have the response of your unknown microphone.

If you use white noise, average the complete output for a lot of FFTs. It's been a while since I did this kind of thing a lot, but you'll need dozens to hundreds of averages get a clean result out of white noise. It works, and gives good results. You just have to be a bit patient.

What I've also done is to use chirps. That's basically a sine sweep, but at fairly high speed.

You sychronize the capture with the chirp so that you always get a block of audio that contains the entire chirp.

You do the cross FFT (or DFT because of the block length) on the entire block and the whole chirp at once.

That gets you a nice, clean, clear analysis in one shot. It comes at the cost of having to pick your whole chirp out of the recorded audio and analyse it in one (often) enormous chunk.

For linear-swept sinusoids (not exponentially-swept), there is a well-developed theory that is spelled out in this answer.

In general, if you squirt anything broadbanded at the two microphones, you can divide the FFT of the signal from the device under test (DUT) by the FFT of the signal from the reference microphone. The logarithm of the magnitude (dB) of that result can be added to the known frequency response of the reference microphone. Pink noise or an exponential swept sinusoid might be good candidates for the broadbanded squirts of sound that the two microphones simultaneously receive.