I have tried various ways to combine Manipulate and Sound/SoundNote that would allow me to vary the frequency of a sound while it is being produced. The addition of Dynamic didn't help, but did increase the variety of error messages. Is this just not possible?

Manipulate[EmitSound[Sound[SoundNote[n, 3]]], {n, 0, 10}]

My goal to listen to, or observe, the beat frequencies produced as a tone becomes closer to or further away from twice the frequency of a second, steady tone. My underlying issue is to develop insight into how original idea of an octave.

  • 2
    $\begingroup$ It is not possible to vary the frequency of a SoundNote[] continuously in Mathematica. The underlying technology, MIDI, does support this through sending "pitch bend" events (what the modwheel on many keyboards does), but Mathematica doesn't support this. I'm not sure if you can have a continuous variation if you use a wave output (not MIDI). $\endgroup$
    – Szabolcs
    Commented Mar 10, 2013 at 17:45
  • $\begingroup$ If I had to do this, I'd use a different program, not Mathematica. You could try PureData, which is free (but not trivial to set up). Perhaps you can even connect another program to Mathematica and let Mathematica control it. $\endgroup$
    – Szabolcs
    Commented Mar 10, 2013 at 19:21
  • $\begingroup$ You could also try ChucK $\endgroup$
    – Szabolcs
    Commented Mar 10, 2013 at 19:23
  • $\begingroup$ I'll try ChucK. I imagined Manipulate would do for sound what it does for color: Manipulate[Graphics[{RGBColor[r, 0, 0], Disk[]}], {r, 0, 1}]. I can imagine the underlying issues are not to same, but it doesn't seem that they would have to be. $\endgroup$ Commented Mar 10, 2013 at 19:29
  • $\begingroup$ I played a bit with ChucK many years ago. It's a command line program, and maybe it can be connected to Mathematica in a sufficiently convenient way. The link I gave you is to a ChucK IDE, which seems to be much easier to use. You can run programs concurrently and change parameters in real time using sliders. $\endgroup$
    – Szabolcs
    Commented Mar 10, 2013 at 19:40

4 Answers 4


The reason you are getting error messages is because you need to constrain the values of the SoundNote to integers. For instance:

 Manipulate[EmitSound[Sound[SoundNote[n, 3]]], {n, 1, 10, 1}]

works fine.

  • $\begingroup$ I see that it does work. Thanks. However, it doesn't do what I hoped to do, which was manipulate a continuous tone. The following doesn't work: Sound[Manipulate[Play[Sin[m 1000 t], {t, 0, 10}], {m, 5, 10, 1}]]. Could it be made to do so? $\endgroup$ Commented Mar 10, 2013 at 19:12
  • $\begingroup$ Trying beat frequency demo. $\endgroup$ Commented Mar 10, 2013 at 19:16
  • $\begingroup$ This isn't working for me. First try it produced $Aborted... I upped to dynamic evaluation timeout to 10 and then it just produced Null $\endgroup$
    – Michael
    Commented Aug 30, 2021 at 0:45
  • $\begingroup$ Move the slider to change the note. If you don't hear anything then make sure your system can produce sound. $\endgroup$
    – bill s
    Commented Aug 30, 2021 at 13:11

I think that varying a parameter of a sound continuously, while it is being played is not possible in Mathematica. A workaround is to use an external program. ChucK is a real-time audio programming language that can run many threads ("shreds") concurrently, and allows dynamically adding/removing shreds from the system. We can create shreds that vary parameters from within Mathematica.

Here's a working, continuously adjustable solution based on ChucK:

First, you need to download the chuck binary and put it some place accessible. I put it in ~/bin.

Then I wrote this chuck script, and put it in ~/chuck:

/* snd.ck */

public class MyState {
    static int freq;

500 => MyState.freq;

SinOsc s => dac;

while (true) {
    MyState.freq => s.freq;
    50::ms => now;

Then I started a chuck host from a terminal using chuck --loop.

Finally, I did this in Mathematica:

(* this will start playing the sound by adding the above defined shred *)

Run["~/bin/chuck + snd.ck"]

(* we'll use this script to adjust the static MyState.freq variable in chuck *)
script = FileNameJoin[{$TemporaryDirectory, "adjust.ck"}]

 Export[script, IntegerString[s] <> " => MyState.freq;", "String"];
 Run["~/bin/chuck + " <> script];
 {{s, 440}, 200, 1000, 1}

Kill chuck from the terminal to stop the sound. Of course there are better ways to do stop/start the sound, without killing chuck, but I was lazy. (You'd need to add/remove shreds that perform a specific task.) This is just a simple example showing how to control ChucK from within Mathematica, using sliders.


There is a nice Wolfram demonstration


that lets you listen to beat frequencies of sine waves. You will need to edit the .cdf in order to listen to any beat frequencies near the octave.

  • $\begingroup$ This is a good demo. Thanks. $\endgroup$ Commented Mar 10, 2013 at 20:08

This also work

Manipulate[ControlActive[n, EmitSound[Sound[SoundNote[n, 3]]]], {n, 1, 10, 1}]

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.