Software Noise Cancellation?
DangerTenor asks: "As I flew around the world, lusting after my coworker's $300 BOSE Quiet Comfort Noise-cancelling headphones, I looked down at my laptop computer and noticed the built-in microphone. Has anyone written or considered writing software to run noise-cancellation based on the built-in mic?"
It would be great if reality were that cooperative, but unfortunately there is no such thing as a "constant or regular, repetitive sound", unless you're talking a digitally-generated sine wave out of a good speaker.
This become especially noticable with high-pitched sounds (or components of sounds) you are trying to cancel. Suppose for the sake of argument there's a 5,000 Hz sound you are trying to cancel that varies randomly in absolute pitch over the course of a second or two by up to 1%, or +/- 50Hz. (1% is easily detectable with training of any sort, but still a lot of people won't notice it, esp. in a noisy situation like fan noise.) Kick in a fudge factor for the fact that your mic can probably barely "hear" that as it is. If your sound canceller is not instantly reactive, it will "cancel" sound from the past (and it can only react at the speed of sound at best), and you could turn an annoying high pitched sound into an annoying 20-50Hz sound, that for bonus points is phased all over the place with all kinds of fun harmonics. Thanks, but no thanks.
And this assumes some sort of ideal environment. It's actually quite hopeless because each speaker of the laptop, assuming it even has two, will affect both ears, plus the reflections of each speaker, plus the reflections of the noise. Real noise dampers put one damper on each ear, because the interaction between the two would take a very challenging math problem and make it an impossible one.
Oh, and the sounds your speaker is making can't reach the mic, either. (Because the sounds can't be cancelled at both of your ears and the mics... in fact, you'll be lucky to manage cancelling the sound at one ear, let alone three places!)
In short, the laptop noise canceller would be interesting to see what kind of crazy phased noises you could get out of your environment, and could even conceivably be useful in some small degree to someone mining their environment for sound effects (musicians, sound effect artists) as an intriguing filter on the world, but for actual noise cancellation, you might as well just stick your fingers in your ears and hmm loudly.
I didn't want to start spouting off signal analysis lingo. But apparently around here it gets you karma.
...all at once.
Okay, you bring up a number of interesting points.
Record some and run it through your favorite MP3 player, with a reasonably sized FFT filter going in realtime.
Not a good idea, MP3 encoding tends to filter out some of the noise...
Watch the FFT display jerk spasmodically. Even the wiggling isn't as regular as you think; if you could do an FFT of the FFT, you'd see that. It's noise, it really is, and even if it sounds to your ear like it's "the same" noise, your computer hears it as anything but.
But what ultimately matters is what that noise sounds like to the ear, and while we can't eliminate the PC noise entirely, we can compensate for an approximation so that it is all that more pleasing to the human listener. While the traces may "jump around" a lot (which an FFT of an FFT won't indicate clearly), what we want is to have a time-decayed sum of the power spectrum. This averages out (over a few frames) energy drift across bands, and emphasizes the stationary energy that is most annoying. We will probably doing this with overlapping windows, up to, lets say, 50ms long(which more than covers 60Hz hum), and window intervals at 4 times that rate (12.5 ms updating).
Noise is really, really dynamic, and you can't predict what it is going to do next.
Exactly. It doesn't autocorrelate, by definition. But then there's the stuff that does...
Oh, and there's no such thing as noise cancellation, by the way, only cancelling certain sounds at certain isolated locations. That's why you need two headphones, one dedicated to each ear, to cancel noise. A single microphone cannot cancel noise for two ears across a set of frequencies, period, especially if it doesn't know where those ears are.
Duh. I never said that my idea could lead to noise elimination, just that it could help.
Again, don't take my word for it, draw it. Draw equally-spaced concentric circles emanating from a point... blah blah blah
Look, the stuff that we're most interested falls below 200Hz, at this point the sound is fairly omnidirectional. So any intelligent compensation will not be in vain. You don't even care about preserving phase. What you're trying to do just a little compensation, allowing the fan noise to fill out frequencies you attentuate in the signal. (During the processing, you don't touch the complex components of the transformed signal, also make sure to window it the same way you windowed the microphone samples for attenuation). Also, there will be issue with expected trip delay, because you might want to be able to do a dry run and see how much contribution (if any) the sound output has on the input to the mic, and what the system delay is. You might want to purposefully filter the filtering information using a delayed copy of the previously outputed sound. And if you're doing that, you'll have to pay attention to clock phase drift between the input and output sections of whatever sound hardware you have (phase unwrapping... ooh fun).
Please try these things before trying to pick them apart; human intuition and wave phenomena are notoriously poor bedfellows.
?! I've been involved in projects recently doing things like this in relation to positional tracking using PSKs. I'm not offering a magic bullet or anything. But everyone here has such a bad attitude. Give me a break.
Now as to whether this could become a product marketable to audiophiles... forget it. As to whether it's worth someone's time to write this software because his PC is too noisy... she'd be better off buying quieter fans.
But it's interesting... not a waste of time if you dig that sort of thing. Just thinking about the response is getting me more excited about it.
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON