This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Play

Play
creates an object that plays as a sound whose amplitude is given by f as a function of time t in seconds between and .
  • Play returns a Sound object, which displays in StandardForm as a button that can be clicked to play the sound.
  • Play treats the variable t as local, effectively using Block.
  • Play has attribute HoldAll, and evaluates f only after assigning specific numerical values to t.
  • In some cases it may be more efficient to use Evaluate to evaluate f symbolically before specific numerical values are assigned to t.
  • The following options can be given:
DisplayFunctionAutomaticfunction for generating output to display
PlayRangeAllthe range of amplitude levels to include
SampleDepth8how many bits to use to represent each amplitude level
SampleRate8000how many times per second amplitude samples should be generated
  • Play produces stereo sound. The left-hand channel is given first.
  • Play generates sound output on any number of channels.
Play a "middle A" sine wave for 1 second:
Play a "middle A" sine wave for 1 second:
In[1]:=
Click for copyable input
Out[1]=
Play two sounds in sequence:
Play any function:
Frequency modulation:
Play a sawtooth function:
Play a square wave:
Play on two different stereo channels:
Play on four channels:
Automatically select the range of function values to use for amplitudes:
Take function values 0 through 50 to span the full range of amplitudes:
Lower sample rates lead to lower-quality sounds, but less data:
Generate beat notes:
Play the Riemann zeta function:
Play a sum of non-commensurate sine waves:
A simple function that gives a "sound effect":
Sum of pure tones with changing frequencies:
Make a vibrato-like effect:
Play a waveform and a note-based sound in sequence:
Play the waveform and note at the same approximate time:
Frequency components higher than the sampling rate will be missed:
Bizarre aliasing can occur close to the sample rate:
New in 2 | Last modified in 6