Sunday 21 January 2024

BirdNet-Pi: more thoughts on microphones & audio

There's a lot of talk on the Github Discussions page about microphone quality.

So naturally I have been giving the matter some consideration and have conducted a few simple checks.

Note: this post was updated on 23 Jan 2023 after I'd re-run some of the tests & added a few more notes.

my assumptions

To use BirdNet to monitor an area, microphones need to be omnidirectional when working in an open site (e.g. marshland, woodland & so on).

When using the monitor in your back garden, there may be reasons to try to shield the microphone to some degree (e.g. to reduce the level of traffic noise from the front of the house).

But generally speaking, you probably wouldn't want to use a directional microphone unless you were just monitoring a feeding station or a particular tree!

Whereas a bird song enthusiast may use a directional mic to get a good recording of a particular species, we are trying to identify everything, be it on the ground or in the sky, doing a fly-past.

Even in a relatively quiet outside environment, the background noise maybe around 30dBA. And bird song may be quite loud close up, but perhaps only (say) 40dBA when the source is tens of metres away from the microphone.

BirdNet attempts to identify species by using machine learning to conduct a visual analysis of a recording's spectrogram. The system is not only 'taught' to recognise bird calls from hundreds of good recordings, but also trained with other sounds such as traffic, aircraft and those created by other non-avian sources. I think its reasonable to assume that the system will recognise and seek to reduce common electrical noise such as 'mains hum'.

audio capture

I have a small collection of analogue and digital microphones. But the audio block diagram is the same in both cases...

...its just that the mic is external for the analogue microphones.

See also my comments on common-mode noise & mains hum in this post
Notice that once the analogue signal has been digitised via the A/D converter, the signal to noise ratio (SNR) cannot be improved by adjustment via Alsamixer of the digital gain. But I'm not sure whether the signal filtering & analysis is affected by the [digital] magnitude of the signal ...I suspect not.

The preamplifier gain for most of my microphones is preset by the manufacturer to a level which probably tries to safeguard against signal overload (clipping) when someone is talking or singing into it at close range.

My Dodotronic Ultramic does allow the user to adjust its analogue gain via a couple of switches. But as its application includes recording bat calls (which can be very loud) even when the gain is set to high, its not as sensitive as my other, cheaper mics.

microphone sensitivity testing

This summarises my test method:-

  • run the BirdNet-Pi system in a quiet room
  • set alsamixer capture level
  • note ambient VU level
  • set signal generator frequency & level
  • note increase in VU level
  • record a short audio segment on BirdNet-Pi
  • view recorded audio waveform on Audacity
  • adjust audio level for appropriate comparison
  • switch Audacity to spectrogram and compare

My test setup looks like this...

...with soft furnishings to reduce echoes!

I power the BirdNet-Pi from a powerbank as I know the system is noisier when powered from a mains supply.

I use a signal generator application on my phone to deliver an 800Hz sine wave.

I marked out a sheet of paper so that I can position the phone & microphones in a repeatable way (they were initially 200mm apart, but this was reduced to 50mm & the signal level reduced for recordings because I was getting harmonic distortion).

On a Linux computer/laptop, open a terminal window and ssh into your BirdNet system.


arecord -d 5 -r 44100 -f S16_LE audioTest.mp3

...but don't hit return just yet.

Also on your computer/laptop web browser, go to BirdNet-Pi menu via the its local web page and select Tools > Web Terminal login and type:-


Note mic/adapter identity (e.g. Texas Instruments PCM2902). This also confirms that your mic has been recognised by the system.



...then hit F4 and adjust Capture level to 100

Hit <esc> key to exit Alsamixer, then enter:-

arecord -V mono -r 44100 -f S16_LE -c 2 /dev/null

You should now see a simple one line VU meter, a bit like this:-

#+                                   | 01%

Note the "no signal" percentage.

Turn on the signal generator and note the new %

At the same time, hit <return> in the Linux terminal to create a 5s recording. Move this recording to computer/laptop and rename using mic identity.

After you have repeated this sequence for all microphones, you should have a good idea which ones are most sensitive from the vu % readings.

My results:-

  • stumpy digital mic, Texas Instruments PCM2902: no sig = 0-1%, 800Hz =17%
  • Dodotronic UltraMic 192k 16bit r4: no sig = 1%, 800Hz = 14-15%
  • WM61A mic#1 + C-Media CM108: no sig = 7%, 800Hz = 55-61%
  • WM61A mic#2 + C-Media CM108: no sig = 2%, 800Hz = 39%
  • WM61A mic#2 + Texas Instruments PCM2902: no sig = 0%, 800Hz = 10%

Clearly, the Panasonic WM61A electret microphone capsules with CM108 digital module are far more sensitive (i.e. produce a higher level output) than my digital microphones. The most sensitive mic readings were more difficult to read because they were jumping about quite a bit.

The Texas Instruments digital module was the least sensitive. This only has a 1.5V electret mic bias voltage, whereas the CM108 is 2V.

Next step is to review the audio recordings. I had to run these tests with a slightly lower signal from my phone as I was getting harmonic distortion.

I've used Audacity menu Effect > Amplify to bring all recordings up to a similar level using Audacity's recommended amplification factors.

These waveforms are in the same order as listed above.

Judged simply on the modulated envelopes, the two best ones are the top (Stumpy digital mic) and the third one down (one of the WM61A samples).

The second one (Dodotronic) is asymetrical as the output seems to have a d.c. bias. The last two look a little noisy, but it was difficult to keep the room 'quiet' and the rain was by now gently hitting the windows.

Moving to the spectrograms from the above amplified waveforms we get this...


The Dodotronic appears to have a problem with noise. This is rather disappointing given that it was about 100 times more expensive than most of my electret mic capsules.

My 'stumpy' digital microphone looks OK but it is not as sensitive as the Panasonic WM61A electret mics coupled with CM108 module.

conclusions (...or maybe not)

Since BirdNet has been trained to 'filter out' non-avian sounds to some degree, I wonder how much difference it makes to use expensive microphones. Live test comparisons are quite difficult, but there are users that seem to have proved that some microphones are better than others.

I'm still sceptical. When I previously tested 2 identical systems, both with WM61A microphones, side-by-side they did not produce identical results. Both systems reported bird calls that the other did not.

A quick test on my system under controlled conditions seems to indicate that it does not monitor continuously, it samples continually. Therefore the system will miss bird calls, presumably while the system is busy ...I need to re-test this.

The SNR needs to be good for your chosen microphone, but I don't think it needs to be exceptional. After all, the environmental audible & electrical noise is many times greater than that generated within your device.

I think my test method is useful for determining relative microphone sensitivity. If sensitivity is important, maybe because the capture range is important, then using a higher sensitivity microphone may be beneficial.

There is one modification that could be tried with an analogue microphone setup. It should be possible to feed an electret mic through another stage of analogue pre-amplification to boost the level. However, this won't improve the environmental SNR, so any distant bird calls may still be lost in the noise.

These tests will allow me to select the most sensitive microphone for my base system (which will be one of my eletret mic capsules). However, I'll continue to use the 'stumpy' digital mic for my portable system, because its more convenient.

No comments:

Post a Comment