Create Sound as tone complex...

A command in the New menu to create a Sound as the sum of a number of sine waves with equidistant frequencies.


the name of the resulting Sound object.
Start time (s)
End time (s)
the time domain of the resulting Sound.
Sampling frequency (Hz)
the sampling frequency of the resulting Sound.
determines whether the result is a sum of sines or a sum of cosines, i.e., whether the zero crossings or the maxima of the components are synchronized. This choice has little perceptual consequences.
Frequency step (Hz)
the distance between the components. In first approximation, this is the perceived fundamental frequency.
First frequency (Hz)
the lowest frequency component. If you supply a value of 0, First frequency is taken equal to Frequency step.
Ceiling (Hz)
the frequency above which no components are used. If you supply a value of 0 or a value above the Sound's Nyquist frequency, ceiling is taken equal to the Nyquist frequency.
Number of components
determines how many sinusoids are used. If you supply a value of 0 or a very high value, the maximum number of components is used, limited by Ceiling.

Example 1: a pulse train

A series of pulses at regular intervals, sampled after low-pass filtering at the Nyquist frequency, can be regarded as a sum of cosine waves. For instance, a 100-Hz pulse train, sampled at 44100 Hz, can be created with:

    Create Sound as tone complex: "train", 0, 1, 44100, "Cosine", 100, 0, 0, 0

Supplying the value 0 for firstFrequency yields an unshifted harmonic complex.

Example 2: a shifted harmonic complex

Some experiments on human pitch perception (residue pitch) use a number of sinusoidal components with harmonically related frequencies that are all shifted by a constant amount.

For instance, to get a sum of sine waves with frequencies 105 Hz, 205 Hz, and 305 Hz, you would use:

    Create Sound as tone complex: "train", 0.3, 1, 44100, "Sine", 100, 105, 0, 3


    Create Sound as tone complex: "train", 0.3, 1, 44100, "Sine", 100, 105, 350, 0

whichever you prefer.

Some of these experiments are described in Plomp (1967) and Patterson & Wightman (1976).


For the “sine” phase, the resulting Sound is given by the following formula:

x(t) = ∑i=1..numberOfComponents sin (2π·(firstFrequency + (i–1)·frequencyStept)

More flexibility?

Suppose you wanted to vary the relative strengths of the frequency components. You could achieve this by creating a Sound with the command discussed here, take its Fourier transform, run a formula on the resulting Spectrum, and take the inverse Fourier transform.

A more general approach is described shortly.

Suppose you need a sum of sine waves with frequencies 105, 205, 305, ..., 1905 Hz, and with relative amplitudes 1, 1/2, 1/3, ..., 1/19. You could build a script that computes the various components, and add them to each other as you go along. Instead of calling 19 scripts, however, you can achieve this with the following more general script:

    form: "Add waves with decreasing amplitudes"
       natural: "Number of components", "19"
    # Create a Matrix with frequency and amplitude information in each row:
    Create simple Matrix: "freqAndGain", number_of_components, 2, ~ 0
    Formula: ~ if col = 1 then row * 100 + 5 else 1 / row fi
    # Create a large Matrix with all the component sine waves:
    Create Matrix: "components", 0, 1, 10000, 1e-4, 0.5e-4, 1, number_of_components, number_of_components, 1, 1, ~ 0
    Formula: ~ object ["Matrix freqAndGain", 2] * sin (2 * pi * object ["Matrix freqAndGain", 1] * x)"
    # Integrate:
    Formula: ~ self + self [row - 1, col]
    # Publish last row:
    To Sound (slice): number_of_components
    Scale amplitudes: 0.99

© ppgb 20220122