I would like to cancel out a known audio signal at my receiver.

Specifically at my transmitter I am playing a song, and at my receiver I am recording it. Both transmit and receive sampling rate is 44.1kHz.

At the receiver I basically want to null out the song so that the only thing that is left is the ambient noise in the room.

When I lined up the received and transmitted signal, I noticed that there is sampling offset so I cannot simply subtract out the transmitted signal.

Are there tools in Matlab that are designed for this task? And what are the general principles I can use to solve this?


So bad news first: you can't just subtract your transmission.

Any room has more than one path that sound waves can take. Hence, there will be multiple different "copies" of your transmit signal, and they will arrive at the receiver with different delays, according to the path lengths. There, they will add up. You know this as echo / reverberation.

This has a lot of interesting effects, such as frequency selectiveness of your audio channel. Long story short: you can't just assume the signal you receive is transmit signal + noise. That's not how the basic physics below this works, at all.

Then: Good news is that there's ways to "reverse" the effect of a room. We call these methods equalizers; you'll need one that perfectly matches the room (including all obstacles in it). There's ways of "learning" about the room impulse response (which fully describes the described multipath environment, should it not change over time and be linear).

Especially, when you have a reference signal you know has been sent: You can use the same song as kind of a matched filter (if you're from a wireless comms background), or pulse compression (same thing, but if you're from a RADAR background) by correlating with it in the receiver. By doing so, you'd get an estimate for the overall system's impulse response, from DAC to speaker to room to microphone to ADC.

Problem is that it's just an estimate, and the less easy your system model is, the more complex this computation would have to look. Essentially, the assumption that a cross-correlation is sufficient to get the channel impulse response is that your system is linear and time-invariant.

While time-invariance might be given for a static room with no movement, linearity is usually simply not fully true for audio problems. Your speaker does not cause twice the amplitude in air pressure when actuated with twice the signal, for example.

One can, these days, to a high degree calibrate all these disturbing effects out. But I think you might have been underestimating the complexity of your problem there.


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.