0
$\begingroup$

I am still learning, so please bear with me:

My audio measurement tool exports the measured spectrum of the DUT in the following format:

  • Frequency [Hz]
  • Magnitude [dB]
  • Phase [degree]

It is stored in a simple text file.

I managed already to read the file in Matlab, split the lines into vectors for each column. So I have now a vector for the frequency points, a vector for the magnitude values and a vector for the phases.

Now I want to generate the impulse response from it. I managed already to interpolate the values on a FFT frequency grid e.g. for a 4096-points FFT and that the second half (the negative frequencies) can be obtained with conj(X) and mirrored. That's all clear. So I can run ifft on it. What is not clear to me is, how to handle the phases.

Can I just write:

X = 10.^(mag/20) .* exp(j*phi/360*2*pi)

with

  • mag the vector with imported magnitude values in dB and
  • phi the vector with imported phase values in degree?

Or do I need to apply another conversion to phi? Something that takes the sampling frequency into account?

$\endgroup$
1
  • $\begingroup$ no need to be so self-depreciating! Asking is how we all start, and it's no shame. $\endgroup$ – Marcus Müller Jan 11 at 19:26
0
$\begingroup$

Can I just write: X = 10.^(mag/20) .* exp(jphi/3602*pi) ?

Yes. If your software returns the phase in degrees, that's exactly right.

The tricky part is, however, the interpolation. The phase wraps round at 360 degrees. For example, if you have 1 degree and 355 degree, the correct interpolation would 0 degree (since 355 is the same as -1) but regular interpolation will give you 180 degrees which is about as wrong as you can get.

In this case unwrapping the phase often helps. You would start somewhere in the middle of the frequency spectrum where you have good signal to noise ratio and than unwrap up and down from there. Unwrapping means to look for phase jumps of more than 180 degrees and add/subtract multiple of 360 degrees to the phase until the jump is less than 180 degrees.

Another potential problem is bulk delay in the measurement which is fairly common for acoustic measurements. Bulk delay leads to very steep phase gradients which makes both unwrapping and interpolation difficult. This can be addressed by "eye balling" the bulk delay, take it out of the measurement. Then do the interpolation and inverse FFT and put the bulk delay back into the impulse response.

$\endgroup$
1
  • $\begingroup$ Ok. Thank you. What do you exactly mean with "eye balling" the bulk delay? Can it be done by Matlab or do I have to do it manually, e.g. specifying the latency of the USB audio interface and/or the distance from speaker to microphone? $\endgroup$ – dsprookie Jan 12 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.