DSPRelated.com
Forums

Compensating for microphone frequency response in FFT

Started by Tyler Mandry July 10, 2011
I'm making an application that displays an FFT of sound data from a
microphone. One thing I need to be able to support is calibrating to
the frequency response of the microphone, which will be given to the
program via a calibration file. The calibration file contains + or -
dB values for different frequencies, like this: http://pastebin.com/raw.php?i=wFBwZaTS
. I can just apply the calibration after the FFT and before displaying
it on the screen.

My problem is this: how should I interpolate between those values,
which are essentially just select points of the whole frequency
response of the microphone? A naive approach might be to define rigid
rectangular bands around those points and, for each frequency in an
FFT, pick one or another calibration line to apply to that frequency.
This would cause visible jumps in the FFT graph, however. Another
solution might be to use linear interpolation, but I'm still not sure
that's the best way.

Is there a "standard" way to do this, that programs like Smaart or FFT
devices do? What would be the best way to generate a continuous curve
from those few fixed points?
On Jul 10, 7:43&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote:
> I'm making an application that displays an FFT of sound data from a > microphone. One thing I need to be able to support is calibrating to > the frequency response of the microphone, which will be given to the > program via a calibration file. The calibration file contains + or - > dB values for different frequencies, like this:
20 -2.7 50 +0.5 100 +0.7 135 +0.7 190 +1.4 250 +1 370 +0.9 550 +1 700 +0.6 1000 +0.5 1500 +0.4 2000 +0.5 2800 +0.6 2900 +0.4 3000 +0.5 4000 -0.2 4300 -0.2 5600 +0.7 6150 +0.6 12000 +3.5 13000 +3.5 20000 -1.5 since the spacing is so irregular in either linear frequency or log frequency (like what's this with two extra points at 2800 or 2900 or 3000 Hz?), you might have to fit a polynomial to it in, say, log frequency. but you might need to give up on the "detail" you have at those 3 frequencies, and fit something to it in some kinda least- squares fashion.
> . I can just apply the calibration after the FFT and before displaying > it on the screen. > > My problem is this: how should I interpolate between those values, > which are essentially just select points of the whole frequency > response of the microphone? A naive approach might be to define rigid > rectangular bands around those points and, for each frequency in an > FFT, pick one or another calibration line to apply to that frequency. > This would cause visible jumps in the FFT graph, however. Another > solution might be to use linear interpolation, but I'm still not sure > that's the best way. > > Is there a "standard" way to do this, that programs like Smaart or FFT > devices do? What would be the best way to generate a continuous curve > from those few fixed points?
dunno what Smaart does. i am trying to figure out what you're trying to do. is this compensation only for display purposes and you want to interpolate between those points in some smooth manner to adjust the FFT plot of the data? or are you trying to compensate for the microphone frequency response in the actual microphone signal? what you might do could be different for the two cases. r b-j
On Jul 10, 7:22&#4294967295;pm, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Jul 10, 7:43&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote: > > > I'm making an application that displays an FFT of sound data from a > > microphone. One thing I need to be able to support is calibrating to > > the frequency response of the microphone, which will be given to the > > program via a calibration file. The calibration file contains + or - > > dB values for different frequencies, like this: > > 20 -2.7 > 50 +0.5 > 100 +0.7 > 135 +0.7 > 190 +1.4 > 250 +1 > 370 +0.9 > 550 +1 > 700 +0.6 > 1000 +0.5 > 1500 +0.4 > 2000 +0.5 > 2800 +0.6 > 2900 +0.4 > 3000 +0.5 > 4000 -0.2 > 4300 -0.2 > 5600 +0.7 > 6150 +0.6 > 12000 +3.5 > 13000 +3.5 > 20000 -1.5 > > since the spacing is so irregular in either linear frequency or log > frequency (like what's this with two extra points at 2800 or 2900 or > 3000 Hz?), you might have to fit a polynomial to it in, say, log > frequency. &#4294967295;but you might need to give up on the "detail" you have at > those 3 frequencies, and fit something to it in some kinda least- > squares fashion. > > > . I can just apply the calibration after the FFT and before displaying > > it on the screen. > > > My problem is this: how should I interpolate between those values, > > which are essentially just select points of the whole frequency > > response of the microphone? A naive approach might be to define rigid > > rectangular bands around those points and, for each frequency in an > > FFT, pick one or another calibration line to apply to that frequency. > > This would cause visible jumps in the FFT graph, however. Another > > solution might be to use linear interpolation, but I'm still not sure > > that's the best way. > > > Is there a "standard" way to do this, that programs like Smaart or FFT > > devices do? What would be the best way to generate a continuous curve > > from those few fixed points? > > dunno what Smaart does. > > i am trying to figure out what you're trying to do. &#4294967295;is this > compensation only for display purposes and you want to interpolate > between those points in some smooth manner to adjust the FFT plot of > the data? > > or are you trying to compensate for the microphone frequency response > in the actual microphone signal? > > what you might do could be different for the two cases. > > r b-j
The file is an actual calibration file for a Rode measurement microphone. I think it is from the manufacturer. Perhaps they thought it important to include more detail around that range. The full breadth of what the application will do includes FFT display, SPL monitoring, and eventually it will have to do impulse response and transfer function analysis. I think most or all of this could be done by just adjusting the FFT output, and perhaps an inverse FFT, but I'm not an expert in the field. I thought about using a polynomial fitting, though that might be detrimental if it can't find a function that fits well to the data - then the application would be essentially ignoring some of the data it's given. It would be best if a technique was used that always hit or very nearly hit the points specified in the file. One person I asked this to did suggest just using linear interpolation. Would you (or anyone) argue against that?
On Jul 11, 1:43&#4294967295;am, Les Cargill <lcargil...@comcast.com> wrote:
> Tyler Mandry wrote: > > I'm making an application that displays an FFT of sound data from a > > microphone. One thing I need to be able to support is calibrating to > > the frequency response of the microphone, which will be given to the > > program via a calibration file. The calibration file contains + or - > > dB values for different frequencies, like this:http://pastebin.com/raw.php?i=wFBwZaTS > > . I can just apply the calibration after the FFT and before displaying > > it on the screen. > > > My problem is this: how should I interpolate between those values, > > which are essentially just select points of the whole frequency > > response of the microphone? A naive approach might be to define rigid > > rectangular bands around those points and, for each frequency in an > > FFT, pick one or another calibration line to apply to that frequency. > > This would cause visible jumps in the FFT graph, however. Another > > solution might be to use linear interpolation, but I'm still not sure > > that's the best way. > > > Is there a "standard" way to do this, that programs like Smaart or FFT > > devices do? What would be the best way to generate a continuous curve > > from those few fixed points? > > You can spline it. > > If the dataset just proves to be completely inadequate, you can make a > spark gap generator from an old strobe flash unit, some sort of spark > gap and an inductive loop pickup. Deconvolve the mic's read of the > impulse against the loop pickup's read of it. That produces a > convolution signature from which a response curve can be derived. > > Voxengo makes a good deconvolver. > > -- > Les Cargill
I hadn't thought about using splines, that may be the best option. And while that was -very- good and interesting information on how to measure the impulse response of a microphone, it doesn't do me much good, as it's the end user of my application that will be providing both the microphone and calibration, and I don't think I will be telling them to take apart a strobe lamp in the help/how-to :). Thanks though, I might be able to use that someday!
On Jul 10, 4:43 pm, Tyler Mandry <tman...@gmail.com> wrote:
> I'm making an application that displays an FFT of sound data from a > microphone. One thing I need to be able to support is calibrating to > the frequency response of the microphone, which will be given to the > program via a calibration file. The calibration file contains + or - > dB values for different frequencies, like this:http://pastebin.com/raw.php?i=wFBwZaTS > . I can just apply the calibration after the FFT and before displaying > it on the screen. > > My problem is this: how should I interpolate between those values, > which are essentially just select points of the whole frequency > response of the microphone? A naive approach might be to define rigid > rectangular bands around those points and, for each frequency in an > FFT, pick one or another calibration line to apply to that frequency. > This would cause visible jumps in the FFT graph, however. Another > solution might be to use linear interpolation, but I'm still not sure > that's the best way. > > Is there a "standard" way to do this, that programs like Smaart or FFT > devices do? What would be the best way to generate a continuous curve > from those few fixed points?
linear is probably all you need microphones are highly non-linear with respect to direction and volume, these points where probably taken at very specific direction (on axis) and a fixed volume, so compensation like you doing is difficult
Tyler Mandry wrote:
> I'm making an application that displays an FFT of sound data from a > microphone. One thing I need to be able to support is calibrating to > the frequency response of the microphone, which will be given to the > program via a calibration file. The calibration file contains + or - > dB values for different frequencies, like this: http://pastebin.com/raw.php?i=wFBwZaTS > . I can just apply the calibration after the FFT and before displaying > it on the screen. > > My problem is this: how should I interpolate between those values, > which are essentially just select points of the whole frequency > response of the microphone? A naive approach might be to define rigid > rectangular bands around those points and, for each frequency in an > FFT, pick one or another calibration line to apply to that frequency. > This would cause visible jumps in the FFT graph, however. Another > solution might be to use linear interpolation, but I'm still not sure > that's the best way. > > Is there a "standard" way to do this, that programs like Smaart or FFT > devices do? What would be the best way to generate a continuous curve > from those few fixed points?
You can spline it. If the dataset just proves to be completely inadequate, you can make a spark gap generator from an old strobe flash unit, some sort of spark gap and an inductive loop pickup. Deconvolve the mic's read of the impulse against the loop pickup's read of it. That produces a convolution signature from which a response curve can be derived. Voxengo makes a good deconvolver. -- Les Cargill
On Jul 10, 7:52&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote:
> On Jul 10, 7:22&#4294967295;pm, robert bristow-johnson <r...@audioimagination.com> > wrote: > > > > > > > > > > > On Jul 10, 7:43&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote: > > > > I'm making an application that displays an FFT of sound data from a > > > microphone. One thing I need to be able to support is calibrating to > > > the frequency response of the microphone, which will be given to the > > > program via a calibration file. The calibration file contains + or - > > > dB values for different frequencies, like this: > > > 20 -2.7 > > 50 +0.5 > > 100 +0.7 > > 135 +0.7 > > 190 +1.4 > > 250 +1 > > 370 +0.9 > > 550 +1 > > 700 +0.6 > > 1000 +0.5 > > 1500 +0.4 > > 2000 +0.5 > > 2800 +0.6 > > 2900 +0.4 > > 3000 +0.5 > > 4000 -0.2 > > 4300 -0.2 > > 5600 +0.7 > > 6150 +0.6 > > 12000 +3.5 > > 13000 +3.5 > > 20000 -1.5 > > > since the spacing is so irregular in either linear frequency or log > > frequency (like what's this with two extra points at 2800 or 2900 or > > 3000 Hz?), you might have to fit a polynomial to it in, say, log > > frequency. &#4294967295;but you might need to give up on the "detail" you have at > > those 3 frequencies, and fit something to it in some kinda least- > > squares fashion. > > > > . I can just apply the calibration after the FFT and before displaying > > > it on the screen. > > > > My problem is this: how should I interpolate between those values, > > > which are essentially just select points of the whole frequency > > > response of the microphone? A naive approach might be to define rigid > > > rectangular bands around those points and, for each frequency in an > > > FFT, pick one or another calibration line to apply to that frequency. > > > This would cause visible jumps in the FFT graph, however. Another > > > solution might be to use linear interpolation, but I'm still not sure > > > that's the best way. > > > > Is there a "standard" way to do this, that programs like Smaart or FFT > > > devices do? What would be the best way to generate a continuous curve > > > from those few fixed points? > > > dunno what Smaart does. > > > i am trying to figure out what you're trying to do. &#4294967295;is this > > compensation only for display purposes and you want to interpolate > > between those points in some smooth manner to adjust the FFT plot of > > the data? > > > or are you trying to compensate for the microphone frequency response > > in the actual microphone signal? > > > what you might do could be different for the two cases. > > > r b-j > > The file is an actual calibration file for a Rode measurement > microphone. I think it is from the manufacturer. Perhaps they thought > it important to include more detail around that range. > > The full breadth of what the application will do includes FFT display, > SPL monitoring, and eventually it will have to do impulse response and > transfer function analysis. I think most or all of this could be done > by just adjusting the FFT output, and perhaps an inverse FFT, but I'm > not an expert in the field. > > I thought about using a polynomial fitting, though that might be > detrimental if it can't find a function that fits well to the data - > then the application would be essentially ignoring some of the data > it's given. It would be best if a technique was used that always hit > or very nearly hit the points specified in the file. One person I > asked this to did suggest just using linear interpolation. Would you > (or anyone) argue against that?
Actually, since I do need to use this calibration for SPL metering, I need to figure out the best way to do that. Would doing an FFT, adjusting the amplitudes based on the calibration, then doing an IFFT make sense? Then I could calculate the SPL based on the RMS of the IFFT output (with a calibration gain applied). In many cases only the IFFT would be an extra step, since it will be showing the FFT anyway. Is this a good approach to take, or am I crazy? (Also, if you have any tips or things to watch out for when trying this approach, please let me know.)
On Jul 11, 6:29&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote:
> On Jul 10, 7:52&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote: > > > > > > > > > > > On Jul 10, 7:22&#4294967295;pm, robert bristow-johnson <r...@audioimagination.com> > > wrote: > > > > On Jul 10, 7:43&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote: > > > > > I'm making an application that displays an FFT of sound data from a > > > > microphone. One thing I need to be able to support is calibrating to > > > > the frequency response of the microphone, which will be given to the > > > > program via a calibration file. The calibration file contains + or - > > > > dB values for different frequencies, like this: > > > > 20 -2.7 > > > 50 +0.5 > > > 100 +0.7 > > > 135 +0.7 > > > 190 +1.4 > > > 250 +1 > > > 370 +0.9 > > > 550 +1 > > > 700 +0.6 > > > 1000 +0.5 > > > 1500 +0.4 > > > 2000 +0.5 > > > 2800 +0.6 > > > 2900 +0.4 > > > 3000 +0.5 > > > 4000 -0.2 > > > 4300 -0.2 > > > 5600 +0.7 > > > 6150 +0.6 > > > 12000 +3.5 > > > 13000 +3.5 > > > 20000 -1.5 > > > > since the spacing is so irregular in either linear frequency or log > > > frequency (like what's this with two extra points at 2800 or 2900 or > > > 3000 Hz?), you might have to fit a polynomial to it in, say, log > > > frequency. &#4294967295;but you might need to give up on the "detail" you have at > > > those 3 frequencies, and fit something to it in some kinda least- > > > squares fashion. > > > > > . I can just apply the calibration after the FFT and before displaying > > > > it on the screen. > > > > > My problem is this: how should I interpolate between those values, > > > > which are essentially just select points of the whole frequency > > > > response of the microphone? A naive approach might be to define rigid > > > > rectangular bands around those points and, for each frequency in an > > > > FFT, pick one or another calibration line to apply to that frequency. > > > > This would cause visible jumps in the FFT graph, however. Another > > > > solution might be to use linear interpolation, but I'm still not sure > > > > that's the best way. > > > > > Is there a "standard" way to do this, that programs like Smaart or FFT > > > > devices do? What would be the best way to generate a continuous curve > > > > from those few fixed points? > > > > dunno what Smaart does. > > > > i am trying to figure out what you're trying to do. &#4294967295;is this > > > compensation only for display purposes and you want to interpolate > > > between those points in some smooth manner to adjust the FFT plot of > > > the data? > > > > or are you trying to compensate for the microphone frequency response > > > in the actual microphone signal? > > > > what you might do could be different for the two cases. > > > > r b-j > > > The file is an actual calibration file for a Rode measurement > > microphone. I think it is from the manufacturer. Perhaps they thought > > it important to include more detail around that range. > > > The full breadth of what the application will do includes FFT display, > > SPL monitoring, and eventually it will have to do impulse response and > > transfer function analysis. I think most or all of this could be done > > by just adjusting the FFT output, and perhaps an inverse FFT, but I'm > > not an expert in the field. > > > I thought about using a polynomial fitting, though that might be > > detrimental if it can't find a function that fits well to the data - > > then the application would be essentially ignoring some of the data > > it's given. It would be best if a technique was used that always hit > > or very nearly hit the points specified in the file. One person I > > asked this to did suggest just using linear interpolation. Would you > > (or anyone) argue against that? > > Actually, since I do need to use this calibration for SPL metering, I > need to figure out the best way to do that. Would doing an FFT, > adjusting the amplitudes based on the calibration, then doing an IFFT > make sense? Then I could calculate the SPL based on the RMS of the > IFFT output (with a calibration gain applied). In many cases only the > IFFT would be an extra step, since it will be showing the FFT anyway. > > Is this a good approach to take, or am I crazy? (Also, if you have any > tips or things to watch out for when trying this approach, please let > me know.)
Filtering by tinkering with the output of an FFT has many pitfalls. Every filter has an impulse response, and you need to be sure that the FFT and IFFT are each at least as long as the impulse response of the filter you want to simulate. It's not impossible, but you need to understand what you're doing. Jerry -- Engineering is the art of making what you want from things you can get.
Tyler Mandry wrote:
> On Jul 11, 1:43 am, Les Cargill<lcargil...@comcast.com> wrote: >> Tyler Mandry wrote: >>> I'm making an application that displays an FFT of sound data from a >>> microphone. One thing I need to be able to support is calibrating to >>> the frequency response of the microphone, which will be given to the >>> program via a calibration file. The calibration file contains + or - >>> dB values for different frequencies, like this:http://pastebin.com/raw.php?i=wFBwZaTS >>> . I can just apply the calibration after the FFT and before displaying >>> it on the screen. >> >>> My problem is this: how should I interpolate between those values, >>> which are essentially just select points of the whole frequency >>> response of the microphone? A naive approach might be to define rigid >>> rectangular bands around those points and, for each frequency in an >>> FFT, pick one or another calibration line to apply to that frequency. >>> This would cause visible jumps in the FFT graph, however. Another >>> solution might be to use linear interpolation, but I'm still not sure >>> that's the best way. >> >>> Is there a "standard" way to do this, that programs like Smaart or FFT >>> devices do? What would be the best way to generate a continuous curve >>> from those few fixed points? >> >> You can spline it. >> >> If the dataset just proves to be completely inadequate, you can make a >> spark gap generator from an old strobe flash unit, some sort of spark >> gap and an inductive loop pickup. Deconvolve the mic's read of the >> impulse against the loop pickup's read of it. That produces a >> convolution signature from which a response curve can be derived. >> >> Voxengo makes a good deconvolver. >> >> -- >> Les Cargill > > I hadn't thought about using splines, that may be the best option. > > And while that was -very- good and interesting information on how to > measure the impulse response of a microphone, it doesn't do me much > good, as it's the end user of my application that will be providing > both the microphone and calibration, and I don't think I will be > telling them to take apart a strobe lamp in the help/how-to :). Thanks > though, I might be able to use that someday!
That might be a small service sub-business to go with the app... most might be perfectly happy with the 12-point cal, but some might not... -- Les Cargill
On Jul 12, 3:26&#4294967295;pm, Jerry Avins <j...@ieee.org> wrote:
> On Jul 11, 6:29&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote: > > > > > > > > > > > On Jul 10, 7:52&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote: > > > > On Jul 10, 7:22&#4294967295;pm, robert bristow-johnson <r...@audioimagination.com> > > > wrote: > > > > > On Jul 10, 7:43&#4294967295;pm, Tyler Mandry <tman...@gmail.com> wrote: > > > > > > I'm making an application that displays an FFT of sound data from a > > > > > microphone. One thing I need to be able to support is calibrating to > > > > > the frequency response of the microphone, which will be given to the > > > > > program via a calibration file. The calibration file contains + or - > > > > > dB values for different frequencies, like this: > > > > > 20 -2.7 > > > > 50 +0.5 > > > > 100 +0.7 > > > > 135 +0.7 > > > > 190 +1.4 > > > > 250 +1 > > > > 370 +0.9 > > > > 550 +1 > > > > 700 +0.6 > > > > 1000 +0.5 > > > > 1500 +0.4 > > > > 2000 +0.5 > > > > 2800 +0.6 > > > > 2900 +0.4 > > > > 3000 +0.5 > > > > 4000 -0.2 > > > > 4300 -0.2 > > > > 5600 +0.7 > > > > 6150 +0.6 > > > > 12000 +3.5 > > > > 13000 +3.5 > > > > 20000 -1.5 > > > > > since the spacing is so irregular in either linear frequency or log > > > > frequency (like what's this with two extra points at 2800 or 2900 or > > > > 3000 Hz?), you might have to fit a polynomial to it in, say, log > > > > frequency. &#4294967295;but you might need to give up on the "detail" you have at > > > > those 3 frequencies, and fit something to it in some kinda least- > > > > squares fashion. > > > > > > . I can just apply the calibration after the FFT and before displaying > > > > > it on the screen. > > > > > > My problem is this: how should I interpolate between those values, > > > > > which are essentially just select points of the whole frequency > > > > > response of the microphone? A naive approach might be to define rigid > > > > > rectangular bands around those points and, for each frequency in an > > > > > FFT, pick one or another calibration line to apply to that frequency. > > > > > This would cause visible jumps in the FFT graph, however. Another > > > > > solution might be to use linear interpolation, but I'm still not sure > > > > > that's the best way. > > > > > > Is there a "standard" way to do this, that programs like Smaart or FFT > > > > > devices do? What would be the best way to generate a continuous curve > > > > > from those few fixed points? > > > > > dunno what Smaart does. > > > > > i am trying to figure out what you're trying to do. &#4294967295;is this > > > > compensation only for display purposes and you want to interpolate > > > > between those points in some smooth manner to adjust the FFT plot of > > > > the data? > > > > > or are you trying to compensate for the microphone frequency response > > > > in the actual microphone signal? > > > > > what you might do could be different for the two cases. > > > > > r b-j > > > > The file is an actual calibration file for a Rode measurement > > > microphone. I think it is from the manufacturer. Perhaps they thought > > > it important to include more detail around that range. > > > > The full breadth of what the application will do includes FFT display, > > > SPL monitoring, and eventually it will have to do impulse response and > > > transfer function analysis. I think most or all of this could be done > > > by just adjusting the FFT output, and perhaps an inverse FFT, but I'm > > > not an expert in the field. > > > > I thought about using a polynomial fitting, though that might be > > > detrimental if it can't find a function that fits well to the data - > > > then the application would be essentially ignoring some of the data > > > it's given. It would be best if a technique was used that always hit > > > or very nearly hit the points specified in the file. One person I > > > asked this to did suggest just using linear interpolation. Would you > > > (or anyone) argue against that? > > > Actually, since I do need to use this calibration for SPL metering, I > > need to figure out the best way to do that. Would doing an FFT, > > adjusting the amplitudes based on the calibration, then doing an IFFT > > make sense? Then I could calculate the SPL based on the RMS of the > > IFFT output (with a calibration gain applied). In many cases only the > > IFFT would be an extra step, since it will be showing the FFT anyway. > > > Is this a good approach to take, or am I crazy? (Also, if you have any > > tips or things to watch out for when trying this approach, please let > > me know.) > > Filtering by tinkering with the output of an FFT has many pitfalls. > Every filter has an impulse response, and you need to be sure that the > FFT and IFFT are each at least as long as the impulse response of the > filter you want to simulate. It's not impossible, but you need to > understand what you're doing. > > Jerry > -- > Engineering is the art of making what you want from things you can get.
With the help of http://www.dspguide.com/ I think I have it working :)