This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Add-ons / Standard Packages / Miscellaneous  /


The functions defined in Miscellaneous`Music` allow you to make conversions between cents and hertz, and play scales in one of the common tuning systems, or in a user-specified tuning system. In addition, a set of equal-tempered pitch/frequency equivalents is defined.
When you try the examples in this documentation, your computer display may not look exactly the same, since the graphic displays accompanying Mathematica's sound generation vary from platform to platform.

Creating a scale.

Scale creates a pitch sequence from a predefined interval list or an arbitrary list of numbers interpreted as intervals measured in cents.

  • This loads the package.
  • In[1]:= << Miscellaneous`Music`

  • JustMajor is an interval list. This plays a major scale in just intonation that starts at 440 Hz and lasts for 3 seconds.
  • In[2]:= Scale[JustMajor, 440, 3] // Show

    Out[2]= -Sound-

  • The list of intervals does not have to be in ascending or descending order. Here the starting frequncy is 880 Hz.
  • In[3]:= Scale[{100, 950, 350, 1200}, 880, 1] // Show

    Out[3]= -Sound-

    Predefined interval lists measured in cents.

    Converting between hertz and cents.

    The two functions HertzToCents and CentsToHertz convert a list of one type to its complementary type.

  • This takes a list of frequencies in hertz and gives the distance from one frequency to the next in cents.
  • In[4]:= HertzToCents[{400, 450, 525}]


  • Here is a list consisting of the frequencies in a one-octave, equal-tempered chromatic scale starting at 440 hertz.
  • In[5]:= alist = Table[ N[440 2^(i/12)], {i, 0, 12}]


  • This confirms that the distance between adjacent pairs of frequencies in alist is 100 cents.
  • In[6]:= HertzToCents[alist]


  • This gives the frequency that is 600 cents above the default frequency, 440 hertz, or in musical terminology, one-half octave above the pitch "A4".
  • In[7]:= CentsToHertz[{0, 600}]


  • Here is a list of all the frequencies of equal-tempered half-steps between 880 and 1760 hertz.
  • In[8]:= CentsToHertz[Range[0, 1200, 100], 880]


  • Here are the frequencies of a 36-tone octave, starting at 660 hertz.
  • In[9]:= CentsToHertz[Range[0, 1200, 33.333333], 660]


    The Miscellaneous`Music` package provides a list of equal-tempered pitch/frequency equivalents. Pitches are named in "pitch class/octave" notation, where the pitch class is given by a letter from A to G, and the octave is an integer from 0 and 7. Flat notes are designated with the appendage "flat" (as in "Bflat" for B-flat), and sharp notes are designated with the appendage "sharp" (as in "Gsharp" for G-sharp).
    Most chromatic equivalences are available, for example, C-flat is the same as B, and E-sharp is the same as F. Double-flats and double-sharps are not defined.

  • The difference between Aflat4 and Eflat5 is 700 cents in equal temperament.
  • In[10]:= HertzToCents[{Aflat4, Eflat5}]


  • This plays a perfect fifth.
  • In[11]:= Play[Sin[2 Pi Aflat4 t] + Sin[2 Pi Eflat5 t],
    {t, 0, 0.2}]

    Out[11]= -Sound-