I am trying to generate a sound with pitch that goes up and down like a sine wave from 0 to 2Pi. So the pitch should be Sin[2Pi t] as t steps from 0 to 1. I thought the way to do this would be somehow in pseudocode like make

f = Integrate[E^(Sin[x] + 2), x];

And then

Play[Sin[f[t]], {t,0,2Pi}]

But it seems Mathematica can't integrate E^(Sin[x] + 2)?

So then I just fooled around and did

Integrate[(Sin[t] + 2), t]
2 t - Cos[t]
Play[Sin[(1.2^(2 t - 1 Cos[t])*1000)], {t, 0, 2 Pi}]

and it doesn't do what I want either...


1 Answer 1


There are two basic approaches. In one, you define the data that will be played as a list, in the other, you define a function and Mathematica fills out the list. To define things directly:

t = Range[100000]/11025;
f0 = 200;
wav = Sin[2 Pi (f0 + 10 Sin[2 Pi t]) t]; 
ListPlay[wav, SampleRate -> 11025]

enter image description here

Variable t defines the time, 11025 is the (arbitrarily chosen) sampling rate, f0 is the center frequency, and the inner Sin gives the frequency modulation.

To let Mathematica make the decisions, you can use Play instead of ListPlay:

Play[Sin[2 Pi (200 + Sin[2 Pi 5 t]) t], {t, 0, 4}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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