Slashdot Mirror


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?"

6 of 38 comments (clear)

  1. Yeah, to some degree.... by IshanCaspian · · Score: 5, Informative

    Although previous posters were correct in saying that it's impossible to have the speakers cancel sound on the fly, because the delay would cause the inverse wave to be out of sync, I could definitely see writing some software that would cancel constant or regular, repetitive sounds. My only isse is that the built-in mics are generally very low-quality.

    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.

    --

    But there is another kind of evil that we must fear most... and that is the indifference of good men.
  2. Just Gotta Say by matt.fotter · · Score: 5, Informative
    I fly weekly and those Bose headphones were one of the best investments I've made. Really, if you fly with any regularity, burn the cash or the AMEX points.

    Mod me offtopic - those damn headphones are worth it.

    --
    quis fimum scribit?
  3. Lust not Required by Kalak · · Score: 4, Informative

    NoiseBuster Headset. Spent $40 or so on these a year and half ago. Great for the server room.

    http://www.spiritcorp.com/noise_cancellation.htm l for some software. That was a 3 second google search for "noise cancellation software". Never used it, but it seems based on the same principles. Not for live listening though.

    --
    I am, and always will be, an idiot. Karma: Coma (mostly effected by .hack)
  4. Re:Sound is slow by orangesquid · · Score: 3, Informative

    Eletricity is the phenomena of charged particle interaction such as to cause a ``current'' that can be made to do useful work. Electrons in an electric current move *VERY* slowly. However, the EMF field induced by the charged particle motion propagates at the speed of light (light is just an EM wave, after all). Imagine the creation of an electric current as an explosion from a bomb; the shock wave propagates outwards at the speed of sound, even though very little motion happened near the bomb. The shock wave is a pressure wave, and its speed is a function of the propagation of pressure waves through the surrounding medium (e.g. the speed of sound in air or in water). The creation of the electric current does something very similar, except the "shock wave" is replaced by a causality horizon (in other words, because information can travel no faster than the speed of light, I can't cause something to happen in a galaxy far away any faster than light can travel, and an electric current that creates an EMF field can't zap your brain with microwaves any sooner than however long it would take for a "light wave" to get there) whose boundary expands at the speed of propagation of an electromagnetic wave through a medium (e.g., the speed of light in a vacuum).

    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).

    --
    --TheOrangeSquid Is it any wonder things seem so awry? We swim in a sea of confusion and don't have to think to survive
  5. Re:There IS a way... by Jerf · · Score: 5, Informative

    What some other people here forget is that by-and-large, the noise created by a PC's fans are stationary signals.

    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.

  6. Re:Better to be slient and be suspected a fool... by arnex · · Score: 3, Informative

    Great Ghu save us from people who think they know more than they actually do!

    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.