One goal of our open source hearing aid platform ("Tympan") is to get people to experiment with new sound processing algorithms but another goal of the Tympan is to enable people to experiment with different microphones and speakers.  So, with regards to microphones, we designed the Tympan electronics to have several different kinds of inputs to allow it to support a range of microphones.  Today, I'll start by calibrating three different microphones with the Tympan.  Then, in a later post, I'll look at how the different microphones influence the self-noise of the system.

Microphones:  The three microphones that I'm using today are shown above.  There's the "Sony Mic", which  is a lapel electret mic intended for picking up voice.  Then, there is the "PCB Mic", which is an inexpensive surface-mount silicon MEMS mic that we've included on the Tympan PCB.  And, finally, there's the "Knowles Mic", which is a high-sensitivity, low-noise mic intended for use in hearing instruments like hearing aids.

Why Calibrate?  If you calibrate your microphones, your audio processing will be able to look at the in-coming digital data and know what sound level is happening in the real world.  Knowing the true sound level in the different frequency bands allows you to tailor your algorithms (amplification, compression, noise reduction) to better respond to a person's specific hearing loss.
Calibration Approach:  To calibrate these microphones, I'm using the approach shown above.  Here, I put the Tympan in my sound chamber and play known sounds at it.  I record the digital values obtained by the Tympan (recorded via its SD card) and compare them to the "truth" that was simultaneously recorded from my laboratory-grade microphone (Bruel & Kjaer 4191).

Truth Microphone:  It is important that the truth microphone be placed very close to the Tympan microphone during this calibration.  Ideally, they'll see exactly the same sound levels.  Pictures showing my arrangement is shown below.
Connecting the Tympan Microphone:  Each of the three test microphones connects to the Tympan in a different way:
  • Sony Mic:  Like many lapel microphones, this mic comes nicely packaged with a 1/8" (3.5 mm) phono plug.  We have a mic jack on the Tympan PCB just for this purpose!  I programmed the Typman to supply a 2.5V bias voltage for this microphone.  
  • PCB Mic: This microphone is just a raw element.  We designed the Tympan to have two of these mics right on the circuit board so that they'd be easy to use.  Therefore, this mic is already wired and simply needs to be enabled in the Tympan software.  
  • Knowles Mic: This is a raw hearing aid microphone.  I soldered some wires to it and connected the wires to the Tympan's "line in" holes that are on the edge of the Tympan PCB.  I provided the bias voltage from a pair of AA alkaline batteries.
Software:  For this test, I wrote an Arduino sketch that allows me to switch the Tympan between the three different microphones.  The sketch saves the digitized audio to the Teensy's SD card.  Additionally, the sketch steps through different levels of gain on the Tympan input (0 dB to +40 dB) so that I can see its effect.  My Arduino code is on my GitHub here.  You'll also need the Tympan library, which you can get here.

Example Data:  Below is a spectrogram of the audio data that I recorded during one of these calibration tests.  The top plot shows the audio from the truth microphone.  The bottom plot is the signal recorded by the Tympan, in this case for the Sony mic.  You can see that I had a loop of audio that I was playing over-and-over into the room.  The audio loop alternates between white noise and a 1 kHz test tone.  In the bottom plot, you can clearly the see the effect of increasing the gain of the Tympan input.
Analyzing the Truth Data:  I started by analyzing the truth data.  Looking at just the white noise periods, I filtered the audio into 3rd-octave bands from 125 Hz to 16 kHz and assessed the average signal level in each band.  Because this laboratory microphone is itself regularly calibrated, I know its data in units of Pascals, which leads directly to units of sound pressure level (SPL).  The SPL that I measured in each band is shown in the figure below.  This is the truth to which I will compare the Tympan data.
Analyzing the Tympan Data:  I performed the same 3rd-octave band analysis of the Tympan data.  Because this microphone is not calibrated (that's what we're doing here) I can only measure the signal levels relative to digital full scale (ie, relative to the level at which the system starts to digitally clip the data).  The plot below shows the 3rd-octave band levels that I measured for the Tympan for the five different gain settings.  The blue line at the bottom shows the levels when the input gain was set to 0 dB while the green line at the top is for an input gain of +40 dB.
Combining with the Truth:  The last step to computing the scale factor is to combine the Tympan data with the truth data.  By bringing the two sets of data together, I can compute how the Tympan digital values (dBFS) can be scaled to reveal the true, in-the-air sound pressure level (SPL).  The figure below shows the resulting scale factor for the Sony mic for the different Tympan gain settings.  It is good to see that the gain setting only appears to affect the overall sensitivity of the system -- that the shape of the frequency response is basically the same for all gain settings.

Repeat for Other Mics:  When I perform this calibration process for all of the microphones, I get the figure below.  It shows that the Sony mic (blue) has a up-sloping response, which is good for a closely-placed lapel microphone.  The PCB mic (orange) is more flat, but has nearly the same sensitivity as the Sony mic.  The most interesting response is the Knowles mic (yellow) because it is nearly 20 dB more sensitive than the other two.  That is quite a difference!
What Gain Setting to Use?  In my tests, I tried a bunch of different gain settings.  Which is the right one to use?  Well, one approach to picking the right gain is to decide what is loudest sound that is likely to be seen.  Let's assume that 120 dB SPL is the loudest sound that we want the Tympan to handle  Then, we look at our sensitivity numbers and choose a gain setting that permits this maximum SPL without clipping.  Using the data for the graph above, the calculation goes like this:

  • Sony Mic at 120 dB SPL yields a digital level of: (120-94) + -48.6 = -22.6 dBFS.  This means that it has 22.6 dB of excess headroom.  I can safely set the gain to +20 dB.
  • PCB Mic at 120 dB SPL yields a digital level of: (120-94) + -47.4 = -21.4 dBFS.  This means that it has 21.4 dB of excess headroom.  I can safely set the gain to +20 dB.
  • Knowles Mic at 120 dB SPL yields a digital level of; (120-94) + -28.9 = -2.9 dBFS.  This means that it only has 2.9 dB of headroom.  For this mic, I would leave the gain at 0 dB
We're Calibrated!  With this testing, we've now calibrated these three microphones with the Tympan.  We know the frequency response and we know how to relate our recorded digital values to real-world SPL numbers.  We also have some guidance as to what gain value we should use for each microphone.  We got a lot done!

Follow-Up:  I've added the raw data and my Matlab analysis files to my GitHub repo.  You can get them here.