Tone

In the Desmos Graphing Calculator, Desmos Geometry Tool, and Desmos 3D, and Desmos Notebook, you can use the tone function to bring sound to your graph or notebook.

Frequency and Gain

Tone takes frequency and gain as inputs.

To get started, all you need is a frequency. The inputs for frequency range from 20Hz to 20000Hz, but these frequencies may not all be audible.

In a new expression line, try typing tone\(\mathbf{(a)}\). This will prompt you to create a slider for \(a\), with a default range from \(110\) to \(880\).

When you add the tone function to your graph, a Tone icon Tone icon. Screenshot. will appear in the expression line containing the function. An Unmute All/Mute All button Unmute All/Mute All icon. Screenshot. will also appear.

Your graph will always start muted. Click Unmute All/Mute All or press Alt+M to unmute or mute every tone in your graph or notebook. To toggle an individual tone’s sound on and off, press the Tone icon in its expression line or press Alt+Shift+H.

You can also use a gain input in your tone function. Gain is a multiplier on the amplitude of the sound wave. Larger amplitudes sound louder to our ears. In Desmos, gain generally falls between \(0\) and \(1\), but the right sounding gain depends on frequency. For very low frequencies, we allow gain to go as high as \(10\). For high frequencies, we restrict it further to protect your hearing. We determine the maximum gain using the formula \(Max\) \(gain = min(10, 660/frequency)\).

Frequency Maximum allowed gain
66 or below 10
165 4
330 2
660 1
1320 0.5
6600 0.1

Try typing tone\(\mathbf{(440,b)}\). This will prompt you to create a slider for \(b\) with a default range from \(0\) to \(1\) automatically. You can start playing with the frequency and tone examples in our introduction to tone example graph.

 

Making Music with Tone

You can use frequency to create musical notes in the calculator. On a piano, 440Hz is the frequency for A4. In the western music scale, there are 12 half steps in an octave, and the frequencies follow a logarithmic relationship.

In other words, the scale is multiplicative instead of additive like we would see with a linear relationship. So, to go up an octave we multiply the frequency by 2, and to go down an octave, we divide the frequency by 2.

One helpful equation for this scale is \(f\left(x\right)=440\cdot2^{ x/12}\). When \(x=0\), you will hear A4. Then, each whole number represents a half step up on the keyboard: \(x=1\) is B flat, \(x=2\) is B, \(x=3\) is C, and so on. Once you reach \(x=12\), you will have A5, which is one octave above A4. You can explore this relationship between frequency and musical notes in our playing with notes on a piano example graph.

This is just one way to build a scale. With the relationship between notes and frequencies, you can build any scale using the tone expression.

Once you have the frequency of musical notes, you can string them together to create a melody. You can listen to an example in our Playing a Melody graph or play with gain to create some fun sound effects. Or, try the Tone Piano notebook.

 

Learn More

Please write in with any questions or feedback to support@desmos.com.