ethaniel
Posts: 14
Joined: Sat Dec 16, 2017 9:26 am

Dual microphone noise cancellation

Mon Apr 13, 2020 4:57 pm

Hi,

I've got a RPI3 with 2 microphones (each connected to a separate USB card). This is located on the beach. One microphone is pointed towards the water, the other is pointed towards the forest in the back which has birds chirping.

Both microphones are picking up the waves, but the forest microphone is picking up the waves more quietly and birds more loudly.

Is there a way to actively cancel out the first microphone from the second one? I would like to hear the forest noises more clearly, lowering the noise coming from the water.

wh7qq
Posts: 1466
Joined: Thu Oct 09, 2014 2:50 am

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 1:47 am

Disconnect the one pointed at the beach...simple as pulling out a USB connection. Use a directional mike on the forest to minimize the surf noise.

ethaniel
Posts: 14
Joined: Sat Dec 16, 2017 9:26 am

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 4:06 am

wh7qq wrote:
Tue Apr 14, 2020 1:47 am
Disconnect the one pointed at the beach...simple as pulling out a USB connection. Use a directional mike on the forest to minimize the surf noise.
This is a very hostile environment (heat, salty mist, rain, etc), and this is a 24/7 setup which uses specific outdoor microphones.
Unfortunately, I couldn't find directional microphones which would survive in these conditions. So I'd want to play with cancelling out one mic from another in real time.

https://www.youtube.com/watch?v=9WbCh2AE_NU

Heater
Posts: 16344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 4:12 am

God, can't even go to the beach without people spying on you now a days. And listening apparently.

You could always ignore one microphone in software.
Memory in C++ is a leaky abstraction .

ethaniel
Posts: 14
Joined: Sat Dec 16, 2017 9:26 am

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 8:53 am

Heater wrote:
Tue Apr 14, 2020 4:12 am
God, can't even go to the beach without people spying on you now a days. And listening apparently.

You could always ignore one microphone in software.
I appreciate your advice, but you're going offtopic and the question still stands.

User avatar
Burngate
Posts: 6334
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 10:18 am

Long, long ago, when the World was young, and horses ran round Epsom Downs with crowds cheering them on - remember crowds? Lots of people all together, and no policemen telling them to go home? - microphones (unless they were rifle-mics, to pick the sound of the hooves over the twittering birds) tended to be omnidirectional, figure-of-eight or cardioid.

If they were sold as "directional" they were actually cardioid, which can be considered a figure-of-eight and an omni added together.
Or you can think of a figure-of-eight as two cardioids back-to-back.

What ever you do, adding or subtracting the two signals from co-sited microphones will give you some variant of omni, figure-of-eight or cardioid, because the physics won't let you have anything else.

Since you have to use those specific mics, you can't swap to a rifle mic which would be better, but could you move one mic closer to the forest?
You'd have to put a delay in the "waves" mic signal to account for the speed of sound, and I'm not going to try coding that into any software.

drgeoff
Posts: 10962
Joined: Wed Jan 25, 2012 6:39 pm

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 10:54 am

Without using two identical capsules sited very close together you are not going to have much success with good cancelling over a range of frequencies. Waves sound very much like noise which does cover a wide spectrum.

Stick to one microphone. The usual technique to record bird song is to mount a microphone in front of a reflecting dish. Same theory as a dish for satellite TV reception. (Or in reverse, a torch.)

Eg
Buy https://www.ebay.co.uk/i/223501178466
DIY https://www.youtube.com/watch?v=2BqOwd48A_w
Quis custodiet ipsos custodes?

ethaniel
Posts: 14
Joined: Sat Dec 16, 2017 9:26 am

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 12:08 pm

drgeoff wrote:
Tue Apr 14, 2020 10:54 am
Without using two identical capsules sited very close together you are not going to have much success with good cancelling over a range of frequencies. Waves sound very much like noise which does cover a wide spectrum.
They're identical capsules which are very close together, looking in opposite directions.
There should be a simple software solution which would allow to cancel off one pattern from another (with a configurable tunable offset, to account for slight variations in delay between microphones). I looked everywhere and can't find it :(
WhatsApp Image 2020-04-12 at 20.41.50.jpeg
WhatsApp Image 2020-04-12 at 20.41.50.jpeg (88.94 KiB) Viewed 605 times

Heater
Posts: 16344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 12:39 pm

ethaniel,
I appreciate your advice, but you're going offtopic and the question still stands.
Don't be so quick to dismiss what I say. Getting a good, strong, clean signal is far easier and will get better results than trying to fix up a noisy up with processing afterwards. This is true of all such signals not just audio and microphones.

It might be better to just use the output of one microphone. It might be better to point both mics toward the source you want rather than the one you don't. It might even help to put a nice thick baffle plate behind the mics on the sea side to try and block some of that noise. In fact I would experiment with making a parabolic dish or shotgun mic arrangement.

You could try and subtract the reverse signal from the one you want. I suspect it would not work so well. You will likely need to introduce a delay in one signal to compensate for the distance between mics and what ever lack of synchronization there is between the USB channels.

You could try to filter out frequencies you don't want. Tune into the birds as it were.

A google search for "linux noise audio cancelling software" find all kinds of ideas about this.

By the way, I love that pole installation you have shown.
Memory in C++ is a leaky abstraction .

MarkTF
Posts: 318
Joined: Tue Mar 03, 2015 4:59 pm

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 1:26 pm

ethaniel wrote:
Tue Apr 14, 2020 12:08 pm
drgeoff wrote:
Tue Apr 14, 2020 10:54 am
Without using two identical capsules sited very close together you are not going to have much success with good cancelling over a range of frequencies. Waves sound very much like noise which does cover a wide spectrum.
They're identical capsules which are very close together, looking in opposite directions.
There should be a simple software solution which would allow to cancel off one pattern from another (with a configurable tunable offset, to account for slight variations in delay between microphones). I looked everywhere and can't find it :(

WhatsApp Image 2020-04-12 at 20.41.50.jpeg
If the two microphones were at precisely the same point and sampled at precisely the same time it would be a simple matter of scaling the amplitude of the "beach" microphone channel to the same amplitude of beach component of the "trees" microphone and subtracting "beach" from "trees". The scaling factor can be estimated from cross correlation techniques or perhaps by trial and error.

That the microphones are not precisely colocated implies some compensation to time delay one of the signal streams linearly across frequency will be required. This might be a linear phase all-pass filter of some sort with the design specifics based on the particular physical geometry of the microphone setup. You'll have an additional problem if using two independent sound cards as the two signal streams will not be phase coherent and will have to be made so, again through some correlation process plus a resampler. Better would be to use a single stereo sound card so coherency is built into the sensor acquisition process.

These techniques are well documented in various digital signal processing textbooks, typically presented in 400 level courses with calculus and linear algebra prerequisites.

It's not my intent to discourage anyone from experimenting with this sort thing. Rather, I'm trying to point out that it isn't an afternoon project, even for someone who more or less knows what they're doing.

richrussell
Posts: 41
Joined: Thu Jan 16, 2020 10:52 am

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 1:43 pm

Whilst it may be possible to reduce the wave sounds - as noted above, waves are very broad spectrum in frequency and a reasonable approximation to white noise (other than amplitude). So when you come to do the cross-correlation stage of the noise cancellation it'll be very difficult for it to get a good match, because the noise of the waves in one sample is pretty much the same as the noise from waves in the next. In effect you're more likely to be successful at emphasising the more narrow-band bird and forest sounds above a white noise background with just one microphone than trying to subtract the noise of the sea more computationally.

Noise cancellation tends to work very well with impulse noise, especially signals with a limited range of frequencies. Hence speech or traffic is quite successful, but things like jet engine rumble or the sea are very tricky to do well without distorting the sounds you want to retain. It's not impossible but it'll require some pretty sophisticated DSP and a lot of maths (or trial and error) to get a good result.If you had a brass band on the beach, you could probably have a decent go at removing that from the birdsong, but the waves and sea noises are much more difficult.

I have to say, my heavily DSP oriented electronics degree was 25 years ago, but the basic principles haven't changed. I was using Motorola DSP56000 and TI TMS320 DSP processors back then, but the ARM processors on the Pi are way more powerful, and so you can have larger and more complex filters than I could back then.

There are a few easy(ish) to use DSP packages for Linux that work well on the Pi - for example gnu-radio has a good selection of processing blocks that work well with audio as extracting intelligible voice from a noisy radio signal isn't that different a task from what you're looking at.

ganzgustav22
Posts: 101
Joined: Tue Feb 11, 2020 1:04 pm

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 2:31 pm

I think SoX can do this.

MarkTF
Posts: 318
Joined: Tue Mar 03, 2015 4:59 pm

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 2:37 pm

richrussell wrote:
Tue Apr 14, 2020 1:43 pm
In effect you're more likely to be successful at emphasising the more narrow-band bird and forest sounds above a white noise background with just one microphone than trying to subtract the noise of the sea more computationally. . . .

There are a few easy(ish) to use DSP packages for Linux that work well on the Pi - for example gnu-radio has a good selection of processing blocks that work well with audio as extracting intelligible voice from a noisy radio signal isn't that different a task from what you're looking at.
This is worth emphasizing. While it's not "noise cancelling", filter might be effective "noise reduction" in this case. In addition to GnuRadio (a real time data flow environment) I'd point to the Python Scipy.signal package which might be a better platform for experimenting with recorded data samples.

The process would be to record a sample of the "woods" channel and try processing it with a band pass filter with a frequency range consistent with the bird species (or whatever) of interest. A more detailed outline and key functions:
  • Record wav file - ???
    Import wav file to Python script - scipy.io.wavfile.read(wavFile)
    Generate filter coefficients - scipy.signal.firwin(numtaps, [lowFreq, highFreq], fs=wavFileSampleFreq)
    Run filter - scipy.signal.filtfilt(b, a, waveFileData)
    Export wav file - scipy.io.wavfile.write(filteredWavFile)
Edit to add: Similar to the suggestion of "ganzgustav22", Audacity has some filtering capabilities as well, so a bandpass filter could be applied to an audio signal by sequentially applying a lowpass filter and a high pass filter to retain the frequency band of interest. This is a "no code" GUI platform to play with filtering.

ethaniel
Posts: 14
Joined: Sat Dec 16, 2017 9:26 am

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 3:51 pm

Thank you for the input! In case somebody stumbles on this thread, here is the closest thing that I could find so far (didn't test it yet):
https://cloudacm.com/?p=3180

Heater
Posts: 16344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 4:58 pm

As noted by others I would be very surprised if one could get that technique to work well in removing the sound of waves on the beach.

That technique, as far as I can tell, relies on taking a frequency spectrum of the unwanted sound, and then filtering that spectrum out of the wanted sound.

That fine when the noise consists of some discrete frequencies. Problem is the noise you have is effectively spread all over the audio spectrum, hard to isolate and filter without removing the signal you want as well.
Memory in C++ is a leaky abstraction .

deepo
Posts: 592
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: Dual microphone noise cancellation

Tue Apr 14, 2020 6:33 pm

Just stumbled on this: Noise cancellation in Pulse under Ubuntu:
https://www.youtube.com/watch?v=HCc80p7MsDg

/Mogens

Return to “General discussion”