• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

Sound cancellation

Qacer

Platinum Member
Apr 5, 2001
2,721
1
91
Hi folks,

I decided to play around with some Matlab in the university lab. One computer was set to output a sine wave with no phase delay. Another one was set to output a sine wave of the same frequency and amplitude, but with a 180 degree phase shift.

I was hoping to cancel out the sound if I play both sound waves simultaneously. However, I wasn't successful. What would be some reasons for the sounds not canceling out?

I don't know much about acoustics.

I also tried using two sine sources in Matlab and merging them into one output. The sine sources had a phase difference of 180 degrees. But the sound card still produced sound.

Thanks!
 

BrownTown

Diamond Member
Dec 1, 2005
5,314
1
0
The fact that you added the 2 sine waves in MATLAB and they didn't cancel out is more confusing, since they of course should cancel each other, and in a mathematical environment i would expect it to work perfectly (in real life its harder to get working right). Only thing I can think of is maybe you though you were doing degrees and really were in radians.

My stupid MATLAB and Mathematica were lost when my HD died and I haven't gotten them back yet so I can't test this for you nows.
 

Born2bwire

Diamond Member
Oct 28, 2005
9,840
6
71
Originally posted by: BrownTown
The fact that you added the 2 sine waves in MATLAB and they didn't cancel out is more confusing, since they of course should cancel each other, and in a mathematical environment i would expect it to work perfectly (in real life its harder to get working right). Only thing I can think of is maybe you though you were doing degrees and really were in radians.

My stupid MATLAB and Mathematica were lost when my HD died and I haven't gotten them back yet so I can't test this for you nows.

He had two different computers running the playback. You need to make sure that you listen at a point where the interference of the two sound waves are completely destructive. The wavelength of a 1KHz tone in air is around 33 cm, so you need to make sure that you have positioned yourself and the speakers at the correct place. Technically though, all of this is rather easy to do if you have a set of speakers that you can hook up the wires to. You can reverse the polarity of one speaker to put the two speakers 180 degrees out of phase. The sound does not cancel perfectly though. What you generally hear is a soft null-space in front of you with the sound coming in from the sides. My guess as to the primary reason why you still hear sounds is due to the reflected sound off of the walls of the room arriving back at you. If you have never been inside an anechoic chamber then you have never truly realized how much ambient echos and reflections that exist in a room.
 

f95toli

Golden Member
Nov 21, 2002
1,547
0
0
If you emitt two sine-waves from two different positions how they will add will depend not only on their relative phase but also on the relative posistion of the speakers.
In theory you would get perfect cancellation exactly in-between the speakers, try drawing two sine-waves and then add them and you will se why.
However, the main problem is that that direct sound only accounts for some of what we hear, sound bounces around and by the time the reflected soundwaves reaches your ears the phase is for all practical purposes random (at least if the frequency is higher than a few hundred Hz, below that room modes will start to be important).
Hence, "simple" noise cancellation does not work in real rooms. There are more advanced soluation which uses a microphone to record the incoming sound and then sends out another sounwave out of phase, but even that is never perfect; it merely dampens the sound somewhat (noise canceling headphones work because then you can "control" what sound reaches your ears).

Adding two sine-waves in matlab should work.

E.g. something like


FS=44100; %smapling frequency
t=0:1/Fs:3; %time
freq=3000; %Frequency
y1=sin(2*pi*freq*t);
%Beep at 3kHz for 3s
sound(y1,FS) %irritating beep

pause %pause

y2=sin(2*pi*freq*t+pi);
sound(y1+y2,FS); % you shouldn't hear this






 

Qacer

Platinum Member
Apr 5, 2001
2,721
1
91
I actually used the Signal Processing blockset with two sine sources directed thru a merge block. The output of the merge block was sent to the soundcard output. I also used radians and not degrees.

But I would agree with the other replies regarding sound waves bouncing. I guess the cancellation will only apply to a one-dimensional plane, huh? I actually moved my head near the speaker to see if I can hear any nulls, but I didn't notice anything.

 

Born2bwire

Diamond Member
Oct 28, 2005
9,840
6
71
Originally posted by: Qacer
I actually used the Signal Processing blockset with two sine sources directed thru a merge block. The output of the merge block was sent to the soundcard output. I also used radians and not degrees.

But I would agree with the other replies regarding sound waves bouncing. I guess the cancellation will only apply to a one-dimensional plane, huh? I actually moved my head near the speaker to see if I can hear any nulls, but I didn't notice anything.

As mentioned before, you can't just merge two sine waves that are out of phase as the result would just be zero. What you could do though, if you only have one computer, is use Matlab to make a stereo wave file and have the left track with a phase shift of 0 and the right track with a shift of \pi/2. Then position the speakers the same distance away from you pointing towards you. If you want to know how to do this stuff, take a look at an old thread I did over at Head-fi about how to make impulse files for convolvers.

Text

Look at my last post to see how I created a stereo wav. The left channel is column 1 of the matrix and the right channel is column two of the matrix.
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Here's something to try so you can experience sound cancellation and remove any possible timing errors. Have one output a sine wave and the other output a sine wave with a slowly changing phase shift. Make it such that it probably goes through a 360 degree phase shift in say 10 seconds or so. Ideally you should hear the sound get louder and quieter in 10 second periods.
 

Born2bwire

Diamond Member
Oct 28, 2005
9,840
6
71
Originally posted by: TuxDave
Here's something to try so you can experience sound cancellation and remove any possible timing errors. Have one output a sine wave and the other output a sine wave with a slowly changing phase shift. Make it such that it probably goes through a 360 degree phase shift in say 10 seconds or so. Ideally you should hear the sound get louder and quieter in 10 second periods.

Curse you and your good ideas.
 

dkozloski

Diamond Member
Oct 9, 1999
3,005
0
76
Stand outside as a Bell helicopter goes overhead. The whop whop sound comes and goes as the sound from the rotor blades phases in and out.
 

randay

Lifer
May 30, 2006
11,018
216
106
Originally posted by: dkozloski
Stand outside as a Bell helicopter goes overhead. The whop whop sound comes and goes as the sound from the rotor blades phases in and out.

really? cool.
 

dkozloski

Diamond Member
Oct 9, 1999
3,005
0
76
Originally posted by: randay
Originally posted by: dkozloski
Stand outside as a Bell helicopter goes overhead. The whop whop sound comes and goes as the sound from the rotor blades phases in and out.

really? cool.

A Bell helicopter has a two bladed rotor system. As the craft approaches the sound can be very loud as the sound waves from each blade add. At the closest point of approach the sound cancels and you can hear the tail rotor, the powerplant, and the gear noise in the transmission. As the machine retreats the rotor blade noise becomes much louder as the sound waves add again.