A command in the New menu to create a Sound as the sum of a number of sine waves with equidistant frequencies.
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.
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)·frequencyStep)·t)
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)"
Formula: ~ self + self [row - 1, col]
# Publish last row:
To Sound (slice): number_of_components
Scale amplitudes: 0.99
© ppgb, August 28, 2017