Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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...

share|improve this question

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}]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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