Resources to Accompany
Musical Analysis and Synthesis in Matlab

by Mark R. Petersen

appearing in the MAA's College Mathematics Journal
Vol. 35, No. 5, November 2004, p.396-401

download article

Matlab Code

  • analyze.m
    Matlab function analyze(file)
    plots the waveform and power spectrum of a wav sound file.
  • synthesize.m
    Matlab function synthesize(file,f,d,p)
    creates a .wav audio file of a sound where the fundamental frequency
    and amplitudes(power) of the harmonics may be specified.
  • synthesize_fp.m
    Matlab function synthesize_fp(file,f,d,p,gamma)
    creates a .wav audio file of a sound where all frequencies,
    amplitudes(power) and phase may be specified.
  • FFT_Description.pdf
    Mathematical description of how these functions use Matlab's fast Fourier transform.

Musical Sound Clips

Figure 2: Analysis of piano notes using analyze.m
Download .wav sound file of a piano playing:
A0 A1 A2 A3 (low A) A4 (middle A) A5 (high A)

Figure 3: Analysis of several instruments using analyze.m
Download .wav sound file of instruments playing A4 (middle A):
tuning fork flute violin singer

Sound Library includes clips of numerous musical instruments and sounds.
Also see

Solutions to Selected Exercises

Download exercises

Other Resources

"Mathematical Harmonies" is a presentation I have given in both highschool and college classrooms. The mathematics of vibrating strings is presented in terms of sine functions instead of Fourier Series and differential equations, as in the CMJ article. Items in pdf format include:

Frequency of each note on a piano. Harmonics of A are shown below as vertical lines.