triangle oscillator

A soft, mellow tone, a little brighter than a sine wave, from a wave that ramps steadily up and down.

The triangle 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 triangle wave climbs in a straight line from its bottom to its top, then falls in a straight line back down, like a ball bounced steadily between two walls. It has no sudden jumps, as the square and sawtooth have, but it does have sharp corners where it turns, and these give it a little more colour than the perfectly smooth sine. It sounds soft, round and slightly hollow: somewhere between a flute and a muted clarinet.

A triangle wave at 220 Hz on a scope
Its spectrum: the note, and faint harmonics at 3, 5, 7… times its pitch

Like the square wave, it has only the odd-numbered harmonics, but they're much weaker, and fall away quickly, which is why it sounds so much gentler than the square:

The four waveforms, and the harmonics in each

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


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

When you might use it

For slow, even sweeps up and down, of a filter's cutoff or a sound's pan, use a triangle lfo, which makes the same wave as a factor at far lower frequencies.

For music nerds

The triangle's harmonics are the odd ones, at levels of 1/k², falling at 12 dB per octave: the third harmonic is at 1/9 of the fundamental (−19 dB), the fifth at 1/25 (−28 dB), the seventh at 1/49 (−34 dB). So it's dominated by its fundamental, with just enough of the third and fifth to give it a slightly hollow, woody edge. Through a low pass filter it soon becomes indistinguishable from a sine, so filter sweeps on a triangle are subtle; it's a sound to use as it is, or to brighten with drive, wavefolding or FM rather than to filter.

Its gentleness makes it the natural choice where a sound has to sit underneath others: sub-basses that need to be heard on laptop speakers, soft pads, ocarinas, recorders, and the "wooden" percussion of a marimba (a triangle with a fast-decaying envelope and a touch of pitch drop). The NES's triangle channel, which carried the bass in most of its music, played a coarsely stepped (4-bit) triangle, whose steps add a faint buzz this smooth one doesn't have.

For math nerds

The oscillator keeps a phase φ like the others (see the sine oscillator), and reads a band-limited table of the triangle

tri(φ) = −(8/π²) Σ over odd k of cos 2πkφ / k²

which runs from −1 at φ = 0 to +1 at φ = ½ and back. It's kept as one cycle of 2,048 samples in eleven versions, each with half the harmonics of the last, and the oscillator plays from the one whose harmonics all fit below half the sample rate, exactly as the sawtooth oscillator does (see that page for the details, and for the fade between versions that keeps a sliding note click-free). A reset sets φ to ¼, where the wave rises through 0.

Since its harmonics fall as 1/k², a triangle aliases far less than a sawtooth even without band-limiting: computed point by point at 2 kHz, the first harmonic to fold back, the 13th, is 44 dB below the fundamental. Still, the folded harmonics land on inharmonic frequencies, where they're easy to hear, so this oscillator band-limits the triangle just as it does the sawtooth, and the cost is the same: one table read, or two while it's fading between versions.

Back to Sources: oscillators
Node reference
Contents