sine oscillator

The purest tone there is: a smooth, steady hum at one pitch, with nothing else in it, and the building block of every other sound.

The sine oscillator node, at 220 Hz

In the menu: sources, then oscillators.

Inputs

Each setting has a knob, which disappears when something is connected to its input.

Outputs

What it does

A sine wave is the shape of anything that swings back and forth smoothly: a pendulum, a weight bouncing on a spring, the prong of a tuning fork. Sound is air pressure going up and down, and when it goes up and down in a sine wave you hear a single, plain pitch with no colour of its own: a tuning fork, a soft whistle, the beep of a test tone.

A sine wave at 220 Hz on a scope, over 20 milliseconds
The same wave on a spectrum analyser: a single peak, at 220 Hz

The spectrum analyser above shows which pitches are in a sound. For the sine wave there's just one: the note itself. Every other sound, a voice, a violin, a drum, is a mixture of many sine waves at different pitches and levels, and that mixture is what makes it sound like itself. The sine wave is the one ingredient that is nothing but pitch.

Compared with the other shapes

The sine, triangle, square and sawtooth oscillators make the four classic waveforms. Each has the same pitch, but a different colour, because each mixes in a different set of higher pitches, called harmonics. The sine has none; the triangle a few faint ones; the square more; the sawtooth the most:

The four waveforms, and the harmonics in each

Listen: sine, triangle, square and sawtooth, each playing the same A (8 seconds)

Played as a little tune, with an adsr shaping each note, the sine sounds soft and round, a little like a flute or an ocarina:


Listen: a phrase on a sine wave (5 seconds)

Frequency modulation

A sine wave on its own soon sounds dull, but two of them together can make an enormous range of sounds. Connect a second sine oscillator (the modulator) to the first one's phase modulation input, and it pushes the first back and forth through its cycle hundreds of times a second. That bends the smooth wave into a more complicated shape, full of new harmonics. The louder the modulator, the more it bends the wave, and the brighter and harsher the sound gets.

In this synth, a sine at 440 Hz modulates one at 220 Hz, and a slow triangle lfo turns the modulator's amplitude up and down. Watch the spectrum analyser fill up with harmonics as it does:

Frequency modulation: a triangle lfo sets the amplitude of a 440 Hz sine, which modulates the phase of a 220 Hz sine

Watch and listen: the harmonics growing and shrinking as the lfo turns the modulation up and down (16 seconds, WebM video)


The pitch of the modulator matters as much as its level. When it's a whole number of times the pitch of the note (twice, as here, or three times), the new harmonics fit the note, and it sounds like an instrument: a clarinet, a brass section, an organ. When it isn't, they don't fit, and the sound turns metallic, like a bell or a gong. Give the modulator its own envelope, so the modulation fades faster than the note, and you have a struck sound that starts bright and mellows as it rings, as real bells and electric pianos do:

A bell: the modulator plays at 3.5 times the note, with a quick envelope of its own; the note has a long one

Listen: the bell playing C, G, E and C (4 seconds)

This is called frequency modulation, FM for short, and it's how the most popular synthesizer of the 1980s, Yamaha's DX7, made all its sounds.

When you might use it

For slow movements, a wobble or a sweep, use a sine lfo: it makes the same wave far below the pitches you can hear, as a factor.

For music nerds

A tone with no timbre

A sine is a single partial: the fundamental, with no overtones. With nothing to give it a timbre, a sine is identified almost entirely by its pitch and loudness, which is why it's the tone of tuning forks, hearing tests and electronic test equipment, and why it's so easily masked in a mix: anything else playing the same pitch class buries it. Its nearest acoustic relatives are the flute (whose harmonics are weak) and the whistle.

Pitch is hard to hear at the extremes. Below about 60 Hz a sine is felt more than heard, and on small speakers that can't reproduce it, it vanishes entirely. A sub-bass that has to survive phones and laptops needs some second and third harmonic, which the ear uses to infer the missing fundamental: add a quiet triangle or a gently driven filter. At the top, above about 7 kHz, the third harmonic is beyond hearing, so a square or a triangle (which have no second harmonic) sounds just like a sine up there; for very high whistles, a sine is all you need.

FM: carrier, modulator, ratio and index

In FM terms, the oscillator you hear is the carrier, and the one connected to its phase modulation input is the modulator. Two numbers describe the result:

The harmonics of a 220 Hz sine modulated by a 440 Hz sine, at three modulator amplitudes

Unlike the harmonics of a filtered sawtooth, which fade smoothly as the filter closes, FM sidebands rise and fall unevenly as the index changes, which gives FM sweeps their characteristic "talking", vocal quality. Envelopes on the modulator's amplitude are the FM equivalent of a filter envelope: a fast decay gives the bright attack and mellow ring of a Rhodes or a DX bell; a slow swell gives brass.

Chaining operators widens the palette further: a third sine modulating the modulator, two modulators summed into one carrier, or a carrier's output fed back into its own phase modulation input, for a sawtooth-like tone that grows noisy as the feedback increases. A loop like that must go through a unit delay node, with an attenuation filter to set the amount; without a unit delay, the loop has no end, and Sonido stops playing the synth.

Phase reset

With nothing connected to phase reset, the oscillator runs freely and each note starts wherever the wave happens to be. For a sustained pad that's what you want; for a bass or a kick, each note starting at a random point makes its attack click and thump differently. Connecting the note's trigger to phase reset starts every note at the beginning of the cycle, rising through zero, so every attack is identical and click-free. For FM, reset both carrier and modulator from the same trigger, so the sidebands start in the same phase relationship each note.

For math nerds

The phase accumulator

The oscillator keeps a phase φ, the fraction of a cycle it has gone through, in double precision, and each sample moves it on by the frequency over the sample rate, wrapping at 1:

φ[n+1] = (φ[n] + f / f_s) mod 1

and outputs the sine of it, shifted by the phase modulation input m (in cycles; +phase-modulation-depth+ is 1):

y[n] = A sin 2π(φ[n] + m[n])

The sine is computed directly, in double precision, rather than read from a table, so it's exact to single-float output precision at any frequency, and the 53-bit phase gives a frequency resolution far below anything audible: the pitch error accumulates by less than a microsecond's worth of phase per day. The frequency and amplitude are read every sample, so modulating them is sample-accurate; the phase step is recomputed only when the frequency changes. The phase output is φ itself; a rising edge of phase reset sets φ to 0.

Phase modulation is frequency modulation

Adding m(t) to the phase is the same as adding its derivative to the frequency: the instantaneous frequency is f + dm/dt. For a sinusoidal modulator, that's a sinusoidal frequency deviation of β f_m Hz, and the result has the classic Bessel-function spectrum:

sin(2πf_c t + β sin 2πf_m t) = Σ J_n(β) sin 2π(f_c + n f_m)t, β = 2πA_m

where A_m is the modulator's amplitude. Components at negative frequencies fold back with their sign inverted (sin(−x) = −sin x), and where the folded components land on positive ones, as they do at integer ratios, they add with their signs: with f_m = 2f_c, the partial at f_c has amplitude J₀(β) + J₁(β). Since J_n(β) is small for |n| > β + 1 (Carson's rule), about β + 1 sidebands on each side are significant: about 2 at A_m = 0.15, 7 at A_m = 1.

Because the modulation is applied to the phase rather than the frequency, the carrier's average frequency is unchanged whatever the modulator does, so the pitch never drifts, even with a modulator that has a DC offset (that just shifts the phase). This is what the DX7 and most "FM" synthesizers actually implement.

Back to Sources: oscillators
Node reference
Contents