LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering background noise using two microphones

Hi,

 

I am new to Labview so please bear with me. I am trying to work out the sound vibration level emitted from a compressor. I have a microphone placed next to it but it is operating in a noisy laboratory and therefore I need to filter out the background noise.

 

I have another microphone to record the background noise. I think I might need to use an adaptive noise cancellation filter but cannot figure out how to make one on Labview. I have tried simply inputting the two signals and subtracting them but get an error saying "Resource requested by this task has already been reserved by a different task" when trying to run it.

 

Basically I am looking for the simplest way to get rid of the background noise in real time or in processing the signals afterwards.

 

Any help would be greatly appreciated. Please ask if you need more information.

Thanks a lot,

Sam

0 Kudos
Message 1 of 10
(6,719 Views)

Sam,

 

 

You did not say what kind of device you are using for measuring the microphone outputs.  From the error message you reportrd it sounds like you need to create one analog input task with two channels rather two separate tasks.

 

Lynn

0 Kudos
Message 2 of 10
(6,704 Views)

I'd need to look at your code to be sure, but it sounds like you are trying to acquire the data with two tasks.  A single card's analog inputs can only run 1 task at a time.  Put both of the channels into a single task and run that one task.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 10
(6,698 Views)

Ah ok thank you. Yes I was trying to use two DAQassistant blocks - one for each microphone so that I could then subtract one from the other afterwards. If I put them in the same DAQassistant how do I subsequently split them up?

 

Thanks for your time,

Sam

0 Kudos
Message 4 of 10
(6,694 Views)

Use a large ax?  I do not use the DAQ Assistant so I am not sure.  I think it generates Dynamic Data Type outputs. The Express palette has a Split Signals function or something similar.

 

Lynn

0 Kudos
Message 5 of 10
(6,679 Views)

Lynn, thanks for the reply. Sorry I do not know what an ax is.

 

Ok is that the standard/(most simple!) way of removing background noise from a signal?

 

My setup is a pair of microphones that are wired through an amp into an input box (can find out the make/model tomorrow if this is necessary information,) and then fed into the usb port.

 

Appreciate the help.

0 Kudos
Message 6 of 10
(6,670 Views)

An ax (also spelled axe) is a tool for chopping down trees.  I was trying to make a joke.  Like some other experienced LabVIEW programmers, I do not like the Dynamic Data Type because it hides the structure of the data contained within it.

 

The subtraction technique is standard and simple.  The biggest issue is phase shift.  Suppose the two microphones are 1 meter apart. A sound arriving on the line through the microphones will arrive 3 milliseconds later at one than at the other. Sound arriving along a line at right angles to the line through the microphones and equidistant from both will arrive at the same time at each.  At other angles the time will vary between those values. Compensating for that delay or phase shift is necessary to get good cancellation.

 

In addition the amplitude of the signals at each microphone will vary inversely as the square of the distance between the source and the microphone. For sources much closer to one microphone the amplitude difference can be significant.

 

Directional microphones will further complicate the amplitude variations.  I think that two microphones are not enough to provide unambiguous determination of the direction of an unknown source, especially when there are multiple sources.

 

Lynn

 

0 Kudos
Message 7 of 10
(6,667 Views)

Lynn,

 

Haha my sense of humour was a bit off.. I understand the issue with phase shift but am happy to play around with it in Labview if there is a way to do that until I get good cancellation. I also read a bit on adaptive noise cancelation (ANC) and opened the example in Labview but could not understand it. Is there a way to simply drag an ANC block onto the block diagram? The cancellation does not have to be perfect but it is quite a noisy laboratory and therefore some cancellation is necessary.

 

Thanks.

0 Kudos
Message 8 of 10
(6,653 Views)

I do not have an ANC example. Maybe it comes with a toolkit I do not have.  Most examples are VIs which you can open and run.  You can also look at the block diagram to see how they do things so you can adapt your VI as needed.

 

Lynn

0 Kudos
Message 9 of 10
(6,639 Views)

A simple approach might be to calculate an FFT for each microphone to get the magnitude spectrum (discarding the phase information), subtracting the two spectra, then doing a reverse FFT on the result. I've seen more sophisticated methods that use Singular Value Decomposition, but I don't know enough about the math to really help you. Googling "singular value decomposition noise reduction" will point you to many resources.

0 Kudos
Message 10 of 10
(6,608 Views)