Superposition of Sound Waves

Manipulate[
Column[{
Show[
Plot[Sin[f1*2Pi*t],{t,0,0.02},PlotStyle->{RGBColor[.33,.6,.7],Thickness[0.0075]}],
Plot[Sin[f2*2Pi*t+offset],{t,0,0.02},PlotStyle->{RGBColor[.48,.11,.56],Thickness[0.0075]}],
Plot[Sin[f1*2Pi*t]+Sin[f2*2Pi*t+offset],{t,0,0.02},PlotStyle->{RGBColor[.6,.73,.36],Thickness[0.01]}],
PlotRange->{{0,0.02},{-2,2}},Ticks->None,ImageSize->400],
"",
If[f1≠oldf1,
EmitSound[{
Sound[Play[Sin[f1*2Pi*t],{t,0,1}],{0,0.1}]
}]],
If[f2≠oldf2,
EmitSound[{
Sound[Play[Sin[f2*2Pi*t+offset],{t,0,1}],{0,0.1}]
}]],
Button["play result",EmitSound[{
Sound[Play[Sin[f1*2Pi*t]+Sin[f2*2Pi*t+offset],{t,0,1},PlayRange->{-1,1}],{0,1}]
}]],
oldf1=f1;oldf2=f2;
},Alignment->Center],
{{f1,200,"blue wave"},200,500,25},
{{f2,200,"purple wave"},200,500,25},
{{offset,0,"offset"},0,2Pi,Pi/16},
{{oldf1,200},ControlType->None},
{{oldf2,200},ControlType->None},AutorunSequencing->{1,2,3}
]

CAPTION

This Demonstration shows two sound waves and their sum. By adjusting the waves' frequencies and their offset from each other, you can hear a variety of resultant patterns representing the sum of the two waves. It is even possible to allow the two waves to cancel each other out completely by setting them to the same frequency and adjusting the offset to π, yielding a result that is silent.

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Superposition of Sound Waves" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/SuperpositionOfSoundWaves/

Contributed by: Alan Joyce

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »