Home | MAX patches | Software | Using Falstad applets | Recording Audio| Links

# Supplements for Chapter 4: The Power of Autocorrelation

## Crafting an autocorrelation directly

We know that a cosine series A(t) with positive coefficients:

is an autocorrelation of a signal S(t):

Taking the autocorrelation of a signal wipes out the phases of the partials in the signal, thus there are infinitely many signals (differing only in phase of the partials) that have the exact same autocorrelation.

An autocorrelation can be constructed directly in Fourier by pressing Clear, then go to the cosine stalks at the bottom and raise whatever subset of them you wish; the result is a positive cosine series, and you are listening to an autocorrelation, of a hypothetical sound whose amplitudes squared give the positive amplitudes you are now using and listening to. The Fourier applet is restricted to a set of harmonically related partials.

In MAX Partials, the autocorrelation is displayed for any sound you create, although you are listening to the original sound, not its autocorrelation (keep in mind, for many sounds these are not very different - only slight timbre changes.) If you want to create a sound that is itself an autocorrelation of another sound, set all the phases of partials you will use to 0.25 (that corresponds to pi/2 - that sets the sine to 0 and only cosines contribute). MAX Partials is not restricted to a set of harmonically related partials. Note how a signal, this itself qualifies as an autocorrelation of another signal, looks very much like its own autocorrelation. The progression here, if you set the phases to 0.25, is signal (that you don't see or hear) to autocorrelation (that is in fact the signal you created, and what you hear) to autocorrelation of the autocorrelation, that is displayed by MAX partials.

## The Chorus effect: listen to the chorus effect (section 4.6)

Two voices in harmony: (one voice at 100 Hz and another at 150 Hz, a fifth above)

80 voices in harmony (40 slightly mis-tuned voices at 100 Hz and another 40 at 150 Hz, a fifth above)

### Determining the autocorrelation of a recorded sound in Audacity

Audacity (http://audacity.sourceforge.net/) is a free cross platform digital audio editor and one of the most capable, although there are some annoying aspects. The sonogram, called spectrogram, is available only in a little tab called Audio Trac at the upper left; the spectrum is available under Analyze (Plot Spectrum) in the menu bar; then, once you have plotted the spectrum, you can select various kinds of weighted autocorrelation (and the unweighted one we use, i.e. "Standard Autocorrelation") under "Algorithm". The length of the window in time can be change with the "Size" menu.

It appears unfortunately that the spectrum can only be given on 0 to 20,000 Hz, that compresses the low frequency data too much. There is a logarithmic option for frequency that alleviates this, but then you loose direct insight as to whether peaks are equally spaced. It seems that spectral intensity can only be plotted in dB, i.e. logarithmically. But Audacity is a mighty nice, powerful application in spite of these minor defects.

Sounds can be recorded directly in Audacity or imported in various formats.

## Fourier Cosine Calculator

Written by the author, this CDF file computes (provided as a .zip file) the cosine transform of a simple adjustable autocorrelation function at a frequency of your choice. It shows how the autocorrelation times the cosine conspires to give a large or small contribution depending on frequency, as the sum of the orange and blue areas in the product. (You may recieve a message "This file contains potentially unsafe dynamic content". This seems to be a general problem whenever the dynamic call to Manipulate is made in longer codes like this one in the current verison of CDF. Ignore and click Enable Dynamics. Otherwise if you are doubtful don't run the code. ).

Detailed explanation here:

### Relevant Wolfram Demonstration Project Apps:

CDF Player downloadable at http://www.wolfram.com/cdf-player/