Convolver and mic phase correction - Page 2 - Home Theater Forum and Systems -

Thread Tools
post #11 of 28 Old 01-23-12, 06:01 PM
HTS Senior Moderator
Wayne A. Pflughaupt's Avatar
Join Date: Apr 2006
Location: Katy, Texas
Posts: 8,809
Send a message via Yahoo to Wayne A. Pflughaupt
Re: Convolver and mic phase correction

Tsardoz wrote: View Post
So the next question is ... does anyone have a microphone cal file which also has phase?
That's a question for the calibration lab/vendor.


Wayne A. Pflughaupt is offline  
Sponsored Links
post #12 of 28 Old 01-25-12, 03:18 AM Thread Starter
Join Date: Jan 2012
Posts: 20
Re: Convolver and mic phase correction

OK just for completeness I finished writing code for this.
My idea of fitting known filter types to the calibration curves did not work so well. (too many curves fit the data and there is no unique best fit).
Indeed, Hilbert transforms are the way to go.

I could not find ANY mic phase data. Clearly nobody gives a stuff about mic phase.
So why should I?
Only because I think although it is highly unlikely to be audible in its own right, if you say that about everything eventually you are wrong when you add them all up. Kind of an interesting philosophical/logical dilemma that.
(if A,B,C,D are each inaudible then A and B an C and D should logically be inaudible together but not necessarily!)

Anyway I digress.
Here is Matlab code ...

code deleted due to bugs
Here is mic phase data for the averaged ECM8000 found in the download section

calibration deleted due to errors
and here are magnitude and phase plots
Well I was going to post pics but I cant figure out how to so I wont.
A message said I could not post links.

The phase response at frequency extremes (<20 Hz , > 10 KHz) is unreliable.
eg. <20 Hz should keep going up and not curve back down

Last edited by Tsardoz; 01-26-12 at 03:29 AM.
Tsardoz is offline  
post #13 of 28 Old 01-26-12, 03:41 AM Thread Starter
Join Date: Jan 2012
Posts: 20
Re: Convolver and mic phase correction

I found some bugs and corrected them.
I have also compared the Hilbert transform approach with the equivalent circuit approach and both give similar phase responses so I now think the bugs are out.
There is still some minor errors below 20Hz and > 20 KHz which I think are due to end effects of the Hilbert transform itself.
(EDIT: Actually this is pretty accurate. The input stage of this microphone looks like a third order high pass filter, so the total phase contributed wont exceed 3*90 = 270 degrees)

But the 20 - 20 000 Hz response looks OK to me.

Matlab code
deleted again as I cannot get Hilbert transforms to work
and calibration data for ECM8000
deleted as it has errors from the Hilbert transform
and a graph of frequency response

EDIT - further note to this. I have since discovered that many (all?) of the phase correction systems already do similar microphone phase corrections. This is just unnecessary for PEQ systems like REW that do not use phase and superfluous for the others that already have their own algorithms. So rather a waste of time really. In any case feel free to use the Matlab code, for anyone who wants to.

EDIT2 - There are problems with the Hilbert transform method so I have deleted this data. I have found another method that works better (see next post from me)

Last edited by Tsardoz; 01-27-12 at 09:39 AM.
Tsardoz is offline  
post #14 of 28 Old 01-26-12, 10:36 AM
Elite Shackster
Join Date: Mar 2009
Location: Michigan, USA
Posts: 1,368
My System
Re: Convolver and mic phase correction

Thanks for posting this! I had been looking for a routine to create the phase info for my Mic. I generally agree that it is not needed for good results, but I like to calibrate the measuring system as well a possible for just the reasons you cited above. It gives me more peace of mind when reviewing the charts. Hopefully someday I will also get into DRC, but for now I am still having fun developing a fuller understanding of all the ins and outs of PEQ.
Thanks again!
jtalden is offline  
post #15 of 28 Old 01-27-12, 09:59 AM Thread Starter
Join Date: Jan 2012
Posts: 20
Re: Convolver and mic phase correction

OK the Hilbert transform method does not work, well at least using Matlab in my algorithm.
I have seen another HTF post that demonstrates the same problem I was having with it

Post #8 shows the same end-effect problems I have encountered (around 10000 Hz). Their conclusion is that you cannot derive mic phase. My conclusion is that the Hilbert transform approach is questionable. I am not saying it wont work but if it does work you need to use it in a special way (that I do not know about).

The good news is that I was able to replicate almost exactly the equivalent circuit phase of the ECM8000 using another Matlab function called genphase.

function phase = findphase(calfile)
%Determine microphone phase from an amplitude calibration file
%get calibration data from file

fid = fopen(calfile);
tline = fgets(fid);
mic = [];
while ischar(tline)
    if isnumeric(str2num(tline(1)))
        tline(tline == ',') = ' ';
        mic = [mic;str2num(tline)];
    tline = fgets(fid);
save mic_data mic

b = [1/2,1/2];  %phase smoothing filter
nhi = 2;          %number of points to use to find slopes at extremes
nlo = 3;          %number of points to use to find slopes at extremes
nextra = 10;    %number of extra points to add at ends
N = 10;         %frequency multiplier at extremes

%extend low frequencies
tlow = logspace(log10(mic(1,1)/N),log10(mic(1,1)),nextra);
blow = regress(mic(1:nlo,2),[log10(mic(1:nlo,1)),ones(nlo,1)]);
xlow = [log10(tlow'),ones(nextra,1)] * blow;

%extend high frequencies
thi = logspace(log10(mic(end,1)),log10(N*mic(end,1)),nextra);
bhi = regress(mic(end - nhi + 1:end,2),[log10(mic(end - nhi + 1:end,1)),ones(nhi,1)]);
xhi = [log10(thi'),ones(nextra,1)] * bhi;

%convert dB to absolute
x = 10.^([xlow(1:end-1);mic(:,2);xhi(2:end)]/10);
t = [tlow(1:end - 1)';mic(:,1);thi(2:end)'];
%x = 10.^(mic(:,2)/10);
%t = mic(:,1);

%resample frequency space to equi (log) space
%tt = logspace(log10(t(1)),log10(t(end)),500);
tt = logspace(log10(t(1)),log10(t(end)),1000);
yy = abs(spline(t,x,tt));
frd1 = frd(yy,2*pi*tt);
resp = genphase(frd1);
[m,p] = bode(resp,2*pi*mic(:,1));
phase = p(:) + 360;

%find phase via hilbert transform NOTE: This does not work for an unknown
%X = hilbert(log(yy));
%phase = spline(tt,-imag(X)*180/pi,mic(:,1));
%smooth phase response with zero phase filter
ylabel('Magnitude (dB)');
title('Microphone magnitude calibration');
%plot phase
xlabel('Frequency (Hz)');
ylabel('Phase (degrees)');
title('Microphone derived phase response');
outfile = [strtok(calfile,'.'),'-phased.',fliplr(strtok(fliplr(calfile),'.'))];

fid = fopen(outfile,'w');
for k = 1:length(phase)
    fprintf(fid,'%5.1f %4.2f %4.2f\r\n',mic(k,1),mic(k,2),phase(k));
and ECM8000 cal file
  5.0 -19.49 264.53
  5.6 -17.79 261.09
  6.3 -16.08 259.63
  7.1 -13.99 253.39
  8.0 -12.39 246.97
  9.0 -10.41 241.86
 10.0 -8.60 231.35
 11.2 -6.98 217.94
 12.5 -5.48 203.90
 14.0 -4.17 186.72
 16.0 -3.05 167.51
 18.0 -2.13 152.05
 20.0 -1.40 137.08
 22.4 -0.88 121.01
 25.0 -0.54 107.02
 28.0 -0.32 94.03
 31.5 -0.20 82.62
 35.5 -0.09 72.88
 40.0 -0.01 64.32
 45.0 0.07 56.79
 50.0 0.11 50.69
 56.0 0.16 44.70
 63.0 0.16 38.91
 71.0 0.14 34.01
 80.0 0.11 29.82
 90.0 0.07 26.45
100.0 0.05 24.06
112.0 0.05 21.68
125.0 0.04 19.60
140.0 0.04 17.71
160.0 0.02 15.94
180.0 0.04 14.79
200.0 0.06 13.63
224.0 0.08 12.44
250.0 0.09 11.38
280.0 0.10 10.47
315.0 0.11 9.53
355.0 0.10 9.09
400.0 0.17 8.72
450.0 0.20 6.89
500.0 0.09 6.74
560.0 0.19 6.91
630.0 0.14 5.79
710.0 0.16 5.78
800.0 0.12 4.91
900.0 0.03 5.18
1000.0 0.00 6.55
1120.0 0.10 7.22
1250.0 0.12 6.40
1400.0 0.02 5.38
1600.0 -0.28 9.55
1800.0 0.11 13.21
2000.0 0.19 9.94
2240.0 -0.15 12.71
2500.0 0.21 16.22
2800.0 0.14 14.85
3150.0 0.08 19.80
3550.0 0.44 23.51
4000.0 0.67 23.76
4500.0 0.78 25.00
5000.0 0.89 28.10
5600.0 1.28 32.02
6300.0 1.78 31.41
7100.0 1.85 32.90
8000.0 2.55 40.73
9000.0 3.93 36.54
10000.0 4.46 23.33
11200.0 4.29 16.38
12500.0 4.73 13.23
14000.0 4.99 5.14
16000.0 5.35 -3.21
18000.0 5.70 -16.83
20000.0 5.37 -29.53
22400.0 5.09 -39.99
25000.0 4.48 -50.52
and this graph actually shows the equivalent circuit phase in red against the genphase phase in blue so you can see that this is now an excellent match.

Uploaded with

I should add that the assumption here is that a condenser microphone is a minimum phase device. Now I dont know if this is true or not but we should be able to correct any minimum phase behaviour. Anything outside that may not be possible but some correction is better than no correction IMHO.

Hopefully I wont have to add any more errata as I am beginning to feel foolish!

Last edited by Tsardoz; 01-27-12 at 09:42 PM. Reason: correction
Tsardoz is offline  
post #16 of 28 Old 01-27-12, 10:20 AM
Senior Shackster
Join Date: Jan 2009
Location: Springfield, MA
Posts: 397
Re: Convolver and mic phase correction

Tsardoz wrote: View Post
Post #8 shows the same end-effect problems I have encountered (around 10000 Hz). Their conclusion is that you cannot derive mic phase.
Well now, my conclusion (well, speculation really) is that you can't derive it based on freq response alone, obviously if you have all the relevant microphone capsule parameters (diaphragm tension & thickness, air gap, etc) you can derive the phase directly from a condenser mic model.

genphase hasn't been ported to Octave yet so I can't run the script. If I send you the B&K 4145 data I used for my phase calc, can you run it through the script and see what you get?
Anechoic is offline  
post #17 of 28 Old 01-27-12, 10:38 AM
Join Date: Dec 2009
Location: CST
Posts: 516
Re: Convolver and mic phase correction

After you get everything worked out, you can then go to work on the electronics (including mic pre-amps) that are conveniently assumed to all exhibit linear phase...

But hey, as the popular goal seems to be to spend no more than $50 on 'ideal'(sic) pre-amps with limiting noise floors this all may be a bit of overkill....

I fear we may be falling victim to the assumption that the difference between a Styrofoam rubber band powered airplane and an F-35 fighter is the quality of the rubber band.
SAC is offline  
post #18 of 28 Old 01-27-12, 01:28 PM
Elite Shackster
Join Date: Mar 2009
Location: Michigan, USA
Posts: 1,368
My System
Re: Convolver and mic phase correction

Tsardoz wrote: View Post
Thanks again for the replies.
So the next question is ... does anyone have a microphone cal file which also has phase?
In case you are still looking for other .cal files for testing your algorithm...

Here is a mic cal file for an ECM8000 that includes phase: ECM8000.txt

It was obtained from:

There appear to be couple of others there as well.
jtalden is offline  
post #19 of 28 Old 01-27-12, 10:12 PM Thread Starter
Join Date: Jan 2012
Posts: 20
Re: Convolver and mic phase correction

Ah thanks for that.
These are the results I have from that calibration file

Red is equivalent circuit model
Blue is calculated from genphase
Green is phase as supplied by calibration file

So the blue phase is a very similar shape to the supplied phase but roughly twice the size.
Rather than just immediately think the routine I am using is wrong, I am questioning the validity of the phase supplied in the calibration file.
From what Anechoic has said, phase is very hard to measure for microphones and that he would be doing it if he could.
If that is true (and it sounds fair enough to me), then how did this calibration file include phase?
Was it just generated with a Hilbert transform routine?
That is what most of the software packages out there tend to do.
If that is the case then there is really no reason to think that the green curve is any more valid than the blue curve.

This whole thing stinks of chicken and egg. Without properly validated microphone phase, any routine I come up with will really just be conjecture. I might go check the academic sources to see if I can find anything truly trustworthy.

On the plus side the HF frequency response extends a bit further than most and catches the resonance peak. Maybe I can try fitting an equivalent circuit to the HF for this mic.
Tsardoz is offline  
post #20 of 28 Old 01-27-12, 10:24 PM Thread Starter
Join Date: Jan 2012
Posts: 20
Re: Convolver and mic phase correction

Anechoic, in another thread someone suggested just measuring impulse response of microphones by measuring the sound from electric spark discharge. This sounded like a pretty good idea to me. Electric sparks are pretty easy to generate. I can't think of anything that would be closer to a true impulse generator.


The SPL might be on the low side but you can fix any SNR problems that arise from that by ensemble averaging of the impulse response. Once you have impulse response you can get phase response. It would be better than these roundabout ways that make assumptions of minimum phase.
Tsardoz is offline  


convolver , correction , mic , phase

Quick Reply

Register Now



Confirm Password
Email Address
Confirm Email Address
Random Question
Random Question #2

User Name:
Please enter a password for your user account. Note that passwords are case-sensitive.


Confirm Password:
Email Address



Activation requires you reply to an email we will send you after you register... if you do not reply to this email, you will not be able to view certain areas of the forum or certain images... nor will you be able download software.


See our banned email list here: Banned Email List

We DO NOT respond to spamcop, boxtrapper and spamblocker emails... please add @hometheatershack DOT com to your whitelist prior to registering or you will get nowhere on your registration.

Email Address:


Human Verification

In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML is not allowed!
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


For the best viewing experience please update your browser to Google Chrome