Tsardoz
Newbie level 3
In high end audio enthusiasts sometimes want to know the phase response of their microphone.
Although they can get them calibrated the labs just return the magnitude response.
So tricks are used to calculate the phase response from the magnitude response.
I have only ever seen mention of Hilbert transforms for this.
eg. see Phase Portrait: Someone asked me about Hilbert transforming minimum-phase magnitude responses today...
The trouble is - it does not seem to work!
I just wondered if anyone could show me what I am doing wrong here.
Now I do not have a microphone calibration that shows magnitude and phase.
So I have something else I developed before I had tried using Hilbert transforms.
This method is based on an equivalent circuit representation as follows:
1) First find a high pass filter that be configured to track a frequency response as closely as possible. For the Beyrerdynamic MM1 microphone I tired various filter types and found it could be accurately modelled by a first order (real pole) high pass filter in series with a second order section with adjustable damping factor.
2) You can easily find an expression for the amplitude response of such a filter which has 3 unknowns (fc1,fc2 and damping factor).
3) Set up a nonlinear regression (nlinfit) with the target being the low end frequency response. Find the best fit to suit the data.
4) Repeat steps 1-3 until a good match is found (I did this and came up with the filter described as being best).
This is what I came up with
**broken link removed**
This makes sense. A third order hpf will have a lower end phase limit of 270 degrees and at the corner frequency of about 30 Hz the phase should be about 3*45 = 135 degrees (check).
So this is the next best thing to having a measured phase response.
Now to the various methods of estimating this...
Raw Hilbert transform
(data was resampled at constant 500 log frequency intervals)
X = hilbert(log(microphone_magnitude_spectrum));
phase = -imag(X)*180/pi;
**broken link removed**
You can see this does a poor job at estimating the low frequency phase shift.
Then in Matlab I foun another method with a function called genphase
"genphase uses the complex-cepstrum algorithm to generate a complex frequency response resp whose magnitude is equal to the real, positive response d, but whose phase corresponds to a stable, minimum-phase function."
frd1 = frd(microphone_magnitude_spectrum,2*pi*microphone_sample_frequencies);
resp = genphase(frd1);
[m,p] = bode(resp,2*pi*microphone_sample_frequencies);
phase = p) + 360;
This performs marginally better than the Hilbert transform (why is it different?) but is still inadequate at modelling the expected 270 degree low frequency phase shift.
Then I had the idea that this problem appears to be related to end conditions. What if I were to artificially extend the frequency response at each end by a decade?
Just use linear regression of the magnitude response to work out the slopes so you can make a good estimate of what the magnitude response is doing in these regions. Then you can remove them again and hopefully do away with these end problems.
extended genphase
Hey it worked!
genphase is now accurately modelling the predicted phase response.
What about if we do the same for the Hilbert transform?
extended hilbert transform
It did not work!
The phase response looks either shifted to right, or up, from what it should be (the red curve).
What is going on with Hilbert transforms?
Why dont they work?
If I had not managed to successfully generate the phase curve from the genphase command I would be having doubts about my algorithms.
However this is not the case.
I know I can just use genphase but I'd like to know what is going on.
Can anyone help identify the problem here?
Although they can get them calibrated the labs just return the magnitude response.
So tricks are used to calculate the phase response from the magnitude response.
I have only ever seen mention of Hilbert transforms for this.
eg. see Phase Portrait: Someone asked me about Hilbert transforming minimum-phase magnitude responses today...
The trouble is - it does not seem to work!
I just wondered if anyone could show me what I am doing wrong here.
Now I do not have a microphone calibration that shows magnitude and phase.
So I have something else I developed before I had tried using Hilbert transforms.
This method is based on an equivalent circuit representation as follows:
1) First find a high pass filter that be configured to track a frequency response as closely as possible. For the Beyrerdynamic MM1 microphone I tired various filter types and found it could be accurately modelled by a first order (real pole) high pass filter in series with a second order section with adjustable damping factor.
2) You can easily find an expression for the amplitude response of such a filter which has 3 unknowns (fc1,fc2 and damping factor).
3) Set up a nonlinear regression (nlinfit) with the target being the low end frequency response. Find the best fit to suit the data.
4) Repeat steps 1-3 until a good match is found (I did this and came up with the filter described as being best).
This is what I came up with
**broken link removed**
This makes sense. A third order hpf will have a lower end phase limit of 270 degrees and at the corner frequency of about 30 Hz the phase should be about 3*45 = 135 degrees (check).
So this is the next best thing to having a measured phase response.
Now to the various methods of estimating this...
Raw Hilbert transform
(data was resampled at constant 500 log frequency intervals)
X = hilbert(log(microphone_magnitude_spectrum));
phase = -imag(X)*180/pi;
**broken link removed**
You can see this does a poor job at estimating the low frequency phase shift.
Then in Matlab I foun another method with a function called genphase
"genphase uses the complex-cepstrum algorithm to generate a complex frequency response resp whose magnitude is equal to the real, positive response d, but whose phase corresponds to a stable, minimum-phase function."
frd1 = frd(microphone_magnitude_spectrum,2*pi*microphone_sample_frequencies);
resp = genphase(frd1);
[m,p] = bode(resp,2*pi*microphone_sample_frequencies);
phase = p) + 360;
This performs marginally better than the Hilbert transform (why is it different?) but is still inadequate at modelling the expected 270 degree low frequency phase shift.
Then I had the idea that this problem appears to be related to end conditions. What if I were to artificially extend the frequency response at each end by a decade?
Just use linear regression of the magnitude response to work out the slopes so you can make a good estimate of what the magnitude response is doing in these regions. Then you can remove them again and hopefully do away with these end problems.
extended genphase
Hey it worked!
genphase is now accurately modelling the predicted phase response.
What about if we do the same for the Hilbert transform?
extended hilbert transform
It did not work!
The phase response looks either shifted to right, or up, from what it should be (the red curve).
What is going on with Hilbert transforms?
Why dont they work?
If I had not managed to successfully generate the phase curve from the genphase command I would be having doubts about my algorithms.
However this is not the case.
I know I can just use genphase but I'd like to know what is going on.
Can anyone help identify the problem here?