I've just moved to a new apartment on a foreign assignment in one of those countries that practice open-air aerobics in the morning.

4:45am in the morning.

Their speakers are about 150m away, but big, and I still get woken to the thud-thud-thud of high-energy disco. It's not especially loud, but I'm a light sleeper, and it's loud enough.

Since it's a rental apartment, sound-proofing isn't really an option. I've tried earplugs, but they don't seem to have much effect on the low-frequencies, which are about all that's getting through 150m of park, my walls and windows, anyway.

I'm wondering if some kind of noise cancellation could work, since the source is at a fixed location and volume, I'm only trying to cancel at one particular fixed spot, where my head is when I'm sleeping, and I only need to deal with maybe 100Hz and lower.

I'm thinking along the lines of digital room correction. eg, I'd have a microphone several meters from the bed (maybe even outside), and measure a "room response" between it and a sleeping position (perhaps just record an early morning session, at the microphone, and at the sleeping position, and use software to convolve the two).
I'd have a subwoofer in the general line between source and bed, although I guess the sound is leaking through everywhere - the steel building frame, windows, ceiling and even floor. Again maybe the speaker is a meter or two from the bed, or maybe closer. I'd measure a "room response" between speaker to bed.

Then, combining the two impulse resposes, I should be able to generate a filter for the the microphone signal, that would result in canceled sound at my sleeping position. And given the microphone is several meters "ahead" of the speaker and the bed, and I only want to do the low frequencies, I should have plenty of time to process the microphone signal to generate an antisound signal.

I have used "Pink-Noise" generated by Audacity played from an mp3 player during the night.
It mask out several disturbed sounds from the surrounding.
But (there is always a but) you have to get used to it, the very first days is difficult!

Also it's the repetitive thump-thump that wakes and annoys, I wonder if simply inversely-modulating the noise generator to the level picked up by microphone would help mask any rhythm - ie not actually trying to cancel individual waves would be a big simplification.

Give it a try in the way as follows: Cut one piece into halves or thirds (depending on the diameter of your external acoustic meatus) and knead them into longish cones, insert in your ear, cram a bit and enjoy the silence. Itīs recommended to use them only once, but each does several times.

Give it a try in the way as follows: Cut one piece into halves or thirds (depending on the diameter of your external acoustic meatus) and knead them into longish cones, insert in your ear, cram a bit and enjoy the silence. Itīs recommended to use them only once, but each does several times.

Originally posted by jackpipeI'm wondering if some kind of noise cancellation could work

Ah, sounds like a near-ideal application for an adaptive noise canceller. Do you happen to have two microphones, a loudspeaker, and the facility for some real-time signal processing? If so, I imagine something relatively successful could be made to work based on an adaptive filter.

In essence, place one microphone near (or even outside) your window, and the other close to where you sleep, along with the loudspeaker. The signal from the outdoor microphone is then run through an FIR filter, and the output inverted and sent to the speaker. At the second microphone (and, of course, your own head), the original outdoor sound and the loudspeaker's output are summed. The LMS/RLS system will adapt the coefficients of the filter to try and minimise power of this sum.

Since in this case the disco music audible inside your room is going to be a filtered (by your walls) version of the music captured by the outdoor microphone, I imagine the system would perform very well.

Wow thanks Wingfeather, that is exactly what I was looking for. The setup you describe is exactly what I had in mind, but I couldn't find how to get the FIR filter.

All the digital room correction systems seem to use a log sweep signal of some kind to do the measurement, and that would mean putting a signal speaker where the outside microphone is, and would probably be quite inaccurate - also they don't measure the absolute delay between outside microphone/speaker and measurement microphone.

Just one question - can you "freeze" the adaptively-generated FIR filter in some way, does that even make sense? Or should the system run adaptively always. I'm guessing just running the signal through a "frozen" fir filter is less intensive than running the adaptive algorithm all the time (ie I could temporarily ship in a big machine to do the measurement), not to mention the issue of having a microphone on the pillow...

Generally speaking, this kind of system is run adaptively all the time. This is nearly always the best thing to do: the update equations are not computationally expensive, and any changes to the acoustic transfer function (maybe you accidentally knock the reference microphone after you've set the system up or something) are adapted to.

Also, the delay between the outdoor microphone and the pillow microphone is accounted for - it comes out in the wash with the adaptive filter, and you're free to move things around during operation to find the best placement. Accounting for the delay does mandate a long filter if the two microphones are a long distance apart, which could be expensive - but if you know approximately the delay you're expecting you could add in a delay line to take care of the buik of it.

In terms of needing a microphone actually on the pillow, you don't need it to be that close. It all depends what kind of bandwidth you want to cancel out, as this approach is most effective at low frequencies. So long as the pillow mic is "relatively close" to yourself at the highest frequencies you want to cancel (in terms of phase difference), the system should be relatively effective. Indeed, you should actively bandlimit the signals (a 4th order lowpass or so is probably sufficient) so that this is satisfied.

If the pillow microphone is about a meter away from you, I imagine you should get good results at ~150Hz and down, give or take.

In terms of microphone placement, imagine a line drawn from the distant loudspeakers to the pillow microphone and beyond. I *think* that arranging the loudspeaker somewhere on this line will give the broadest sweet-spot (but I'm not in a position to think that through properly right now).