Using Desmos: Creating Sounds with Tones
Created: 2025/3/10

This section covers how to use the tone function to play sounds in the Desmos Graphing Calculator. With a bit of creativity, you can even compose music!

tone ( Frequency, Gain )

The function tone(a)\mathrm{tone}(a) plays a sound at a frequency of a [Hz]a\ [\mathrm{Hz}]. You can specify frequencies between 20Hz20\,\mathrm{Hz} and 20000Hz20000\,\mathrm{Hz}.

For example, try entering:

1
tone(440)\mathrm{tone}(440)

A button to play the sound will appear above the expression, as shown in the image below.

By default, the sound is muted. Press the button to unmute it, and you should hear a sine wave at 440 Hz440\ \mathrm{Hz}.

You can also control the volume (gain) by adding a second argument:

1
tone(440,1.5)\mathrm{tone}(440,1.5)

The maximum gain depends on the frequency. Specifically, the maximum value is calculated using the formula min(10,660/frequency)\mathrm{min}(10,660/\textrm{frequency}). This means higher frequencies have a lower maximum gain.

Various Examples

Simple Melody

Click the PLAY / STOP button below the graph to play the melody.

The melody is created by changing the frequency. For more details on how to calculate the frequencies, check out this article on musical scales.

waon
Understanding Chords and Waves: Harmony and Dissonance

Beats

Here's an example of beats:

Volume
Freq: 425 Hz
Freq: 424 Hz

For more details, see this article:

beat
Exploring Beats: Visual and Auditory Experience
SHARE
Images are created with the Desmos Graphing Calculator, used with permission from Desmos Studio PBC.
© 2024 UNS Physics. All Rights Reserved.