Software Noise Cancellation? 38
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?"
Reasons this may not work (Score:4, Insightful)
A quick overview of sound; all sounds are comprised of varying frequency, and amplitude pressure waves. A sound dampener 'listens' to a sound, and emits it 180 degrees out of phase. This means the crests and troughs of the 2 waves are overlapped, negating one another.
The main issue to be overcome is direction and such that shifts the pitch of sounds coming from a computer. Unless you are using a very high quality, wide pickup mic (which are rather expensive), you are probably not going to be able to get enough sound precision to be able to get the damper working effectively. Also, positioning the mic would take a while to get the best location for maximal damping effect for overall sound. This is still work checking out though cause it may yield greater results than I think it will. However, most computer users do not have high quality mics in the first place (and a $20 mic wont cut it). The more mics used, the more effective this would be due to wider sound coverage.
Sound is slow (Score:2)
Re:Sound is slow (Score:3, Informative)
However, digital devices are slow things. When you want a transistor to switch on, you have to push electrons over a quantum "cliff" (in a sense). This happens much slower than EM wave propagation; that's why silicon switching speeds are measured in nanoseconds rather than fractions of a femtosecond...
If you are confused (I may be a bit confused too, it's been a while since I studied this stuff), check out http://www.amasci.com/ for more info. It's a very informative site.
As for the noise cancellation idea, the laptop mic's own frequency response would have to be compensated for, otherwise the cancellation signal will have noticable imperfections. You'll need a really, really fast machine to do this too (lots of overlapping fast fourier transforms), if you want to keep up with the sound.
An easier way to get cheap noise cancellation is to take a "snapshot" of the noise in the current room and play back the inverse of that overtop of your sound. You'll still get some white noise, of course, but it'll be evenly distributed across the spectrum, rather than being focused at certain frequencies; your ears will get used to the background white noise fairly easily, though, and you'll have the added benefit of perceived distortion being even across the spectrum, so the sound will probably "feel" a bit cleaner. If you want to calibrate the system, though, you'll need to do a few measurements. You need the audio "fingerprint" of your mic, your headphones, your sound card input, and your sound card output; you can use two different mics, two different sound inputs, two different sound outputs, and two different sets of output devices. Then, you can emit test frequencies and see how much they get reduced by all 2x2x2x2=16 combinations of apparatus (I *think* that will work), do some algebra, and solve many many systems of equations to find a decent audio profile of each of the pieces in the chain. One sample equation would be: SoftwareOutputVolume * SoundCardDtoAReduction * HeadphoneReduction * MicReduction * SoundCardAtoDReduction = SoftwareInputVolume. Compare the output level you think you're sending to the soundcard, the input level from the soundcard, and repeat ad nauseum. Or, if you don't mind some loss of quality, and you have at least one very good sound card, pair of headphones, and microphone (you want the flattest frequency response possible for all of these), you can simplify the above approach quite a bit (just record signals from your laptop through your everyday headphones with the good equipment, then play signals with the good equipment and record them with your laptop; you get the idea).
Just some thoughts =)
If you decide to do a project for this, best of luck (you'll need it).
Better to be slient and be suspected a fool... (Score:1, Flamebait)
You really are just another fucking English major, aren't you, asshole?
Sound is slow. Really really slow. While the previous poster wasn't quite correct about computer signals going the speed of light in copper, it's still up there in terms of magnitude. Figure that the signal going through the computer is going to be going 1,000,000 times faster than the sound and you'll be in the right neighborhood. That's plently of time to emit a signal that's exactly 180 degrees out of phase with the original sound, presumably in the human hearing range of frequencies.
There are active sound cancelling technologies in products such as the BOSE headset mentioned. And if it can be done in hardware, it can be done in software running on the following generation of hardware.
Great Ghu save us from people who think they know more than they actually do!
Re:Better to be slient and be suspected a fool... (Score:3, Informative)
Indeed.
You are evidently unaware that PC audio processing takes place on chunks of audio as it passes through the sound card's buffers. This is where the latency comes from. And since it would require two buffer trips (read buffer -> phase shift -> write buffer) the latency will be doubled.
Furthermore, the environmental noise sample would need to be taken as close as possible to the point in space where the "dead zone" is to be simulated. This means we'll need to attach two mics to the ears of the listener. It follows then that we'll need to process two independent signals, so double the effective size of your buffers and figure on devoting a few more CPU cycles to the "phase shift" step in the scenario above.
All things considered, with a fast CPU and extremely small buffers you might be able to reduce latency to fifty or sixty milliseconds, but this simply won't suffice for the requested application.
Face it, PC sound cards were designed for making asynchronous beep-beep game noises, not for realtime signal processing. Laptop sound "cards" are even worse.
Re:Better to be slient and be suspected a fool... (Score:2)
Yeah, to some degree.... (Score:5, Informative)
Has anyone considered writing software to filter a computer's fan? That would be really cool, and probably pretty easy to do...some little tray program that constantly runs the inverse sound over your speakers...hmmm.
GOOD LORD (Score:2, Funny)
Re:GOOD LORD (Score:2)
your window system.
Re:Yeah, to some degree.... (Score:3, Funny)
"I don't think I can spend the night again, your computer kept me awake all night last time."
of course maybe she was just trying to protect my feelings...
Re:Yeah, to some degree.... (Score:1, Insightful)
Re:Yeah, to some degree.... (Score:1)
If you canceled the noise of your fans, the question is would the white noise be worse, the same, or better than your fans? This obviously depends on your fans of course. However, my rig has 5 fans, 6 if you include the power supply, and it's already quieter than essentially every other appliance in my house (well, the furnace is quiet actually). I remember reading that the white noise these headphones generate is just as bad as a fridge or something.
Course, I've never used a set of headphones personally, so I can't say if any of this is really true. I'd like to demo some one day.
Re:Yeah, to some degree.... (Score:3, Interesting)
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.
Re:Yeah, to some degree.... (Score:1)
Re:Yeah, to some degree.... (Score:2)
Re:Yeah, to some degree.... (Score:1)
Would using the fan speed, as predicted by some math, help a noise canceller effectively cancel fan noise?
Can't be done. (Score:2)
See, not only is the inverse waveform important, but the PHASE as well. Shift ear position 180 degrees out of phase (at 13392 in/s, a 3000 Hz signal will be 180 out of phase by moving 2.232 inches) and the speaker will actually double the sound pressure.
That's why the noise-cancelling headphones work. They are guaranteed a distance from the sensing microphone to the ear. Also, noise-cancelling devices on machinery work because they are very close to the origination point of the noise, so the inverse waveform is nearly on top of the noise waveform.
Just Gotta Say (Score:5, Informative)
Mod me offtopic - those damn headphones are worth it.
Lust not Required (Score:4, Informative)
http://www.spiritcorp.com/noise_cancellation.ht
i got it (Score:1, Troll)
Too noisy. (Score:2)
There IS a way... (Score:2, Insightful)
What some other people here forget is that by-and-large, the noise created by a PC's fans are stationary signals. A second of training to the ambient noise in the room via an omnidirectional mic will allow you to build a frequency profile. Then, you filter the data against this profile to compensate for the ambience. Of course, you keep updating the profile, as noise levels in the room are constantly changing. One problem is that you have to deal with processing the sound in the frequency domain to compensate, so you have to transfer to and from the time domain in chunks. This all has to be accopmlished in realtime (it's not light on the CPU) and it will introduce a short delay, but the shorter that delay, the less effective it will be.
I think a better solution would be to place the crappy desktop mic (if you aren't using it for telephony) into the case of the PC, where it will work better. Then you could work on reducing the apparent machine noise (including 60Hz hum!)
Re:There IS a way... (Score:5, Informative)
No, they are not.
Don't take my word for it. Record some and run it through your favorite MP3 player, with a reasonably sized FFT filter going in realtime. 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.
For extra bonus points (and to really enhance your understanding of what noise really is!), open that noise recording in a sound program. Zoom in really tight, until you can see one wave cycle (from 0, to max, to 0, to min, back to 0 again. It may cross 0 a few times in that span, so eyeball it. You can't really be wrong, so it's not that big a deal, as long as the two ends meet up when you're done.) Copy that sound for 1 or 2 seconds worth, and play it. (Copy and paste it twice, highlight that, copy and paste again, and duplicate that; you'll be into seconds in no time.) Take a moment and ask yourself what you expect this to sound like. Then play it. Is that what you expected? Still don't believe me? Take a larger snippet, three or four waves.
Noise is really, really dynamic, and you can't predict what it is going to do next.
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.
Again, don't take my word for it, draw it. Draw equally-spaced concentric circles emanating from a point. Draw equally spaced concentric circles of the same size emanating from another point. The distance between the two concentric circles is the frequency, and let's say one circle's lines is the bottom of the signal, and the other the top. The places where the circle touch the sound is canceled (in this hopelessly perfect little world where nothing is interfering with the sound). In the middle of each of the little quadrangles you build, the sound is doubled. You'll see it's impossible to complete and totally cancel the sound unless the two sources are exactly the same... which is not surprising because that's equivalent to preventing it in the first place!
And lest ye think that you can put your ears at two of the meeting points (again, totally and completely ignoring the sound's interaction with the environment)... draw another set of circles using the same sources, but multiplying the distance between each concentric circle by, say, 8/7s. And 1/3. And 87/34s. And everything in between. All at once.
Please try these things before trying to pick them apart; human intuition and wave phenomena are notoriously poor bedfellows.
Forgive me for my grass simplification. (Score:2, Interesting)
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 post has noise cancellation down pat (Score:2, Funny)
Won't work (Score:2, Insightful)
The problem is that the microphone is not near your ear.
In order for noise cancelling speakers to work, they need to maintain a constant and known spatial relationship with your ears relative to the sound source. The only practical way to do this is to locate them at the ear (that's how noise cancelling headphones work).
Thus unless the laptop's microphone is at the loci of both your ears, you're not going to do any better than just add to the racket.
Re:Won't work (Score:2)
It's possible to have noise-cancelling speakers near an annoying sound source. This works best for low-frequency sources, like fans, reciprocating engines, large transformers, and rotating machinery.
Forget it (Score:2)
(unrelated, but interesting) A few years ago, I read about a maker in Europe, maybe Airbus, who was developing a jet with lots of microphones and speakers, so that the entire cabin could have noise-cancellation.
Be A True Geek, Roll Your Own!!! (Score:1)