wavetable oscillator

Plays a waveform it has learned from up to four others you connect to it, and morphs smoothly from one to the next, so a sound can change its whole character as it plays.

The wavetable oscillator node, with a bank of four waveforms and its position part way through

In the menu: sources, then oscillators.

Inputs

Frequency, position and amplitude each have a knob, which disappears when something is connected to its input.

Outputs

What it does

The other oscillators each play one shape of wave. The wavetable oscillator plays whatever shapes you give it. Connect up to four waveforms to its inputs a to d, and it records one cycle of each, the moment they're connected: this set of waveforms is its bank. It then plays from the bank, at its own frequency, and its position chooses which waveform: 0 is the first, 1 the last, and the others are spread evenly between. In between, it blends smoothly from one to the next.

The view at the bottom of the node shows the bank: each waveform in it, and the blends between them, one behind another from the back (the first) to the front (the last). The bright line is the waveform being played, at its place among them.

In this synth, four oscillators fill the bank with a sine, a triangle, a sawtooth and a square, and a slow lfo sweeps the position back and forth. Watch the bright line move through the bank, and the scope show the shape changing:

Four oscillators at the same frequency fill a wavetable oscillator's bank, and a triangle lfo sweeps its position

Watch and listen: the position sweeping through the bank (16 seconds, WebM video)


The waveforms it plays at seven positions through the bank

Playing notes

The bank holds one cycle of each waveform, so once it's learned it can be played at any pitch. To play notes, connect the note's frequency to the wavetable oscillator and to all its source oscillators, so they play together. Each time a note starts (each note being a fresh copy of the synth), it learns the bank anew, which takes one cycle of the note and a few milliseconds, and fades the sound in as it arrives: each note starts a moment late, but without a click.

In this voice, a slow envelope moves the position through each note, so each note starts as a pure sine and grows brighter until it's a square, two and a half seconds later:

A playable wavetable voice, with an adsr scanning the position through each note

Listen: three notes, each morphing from a sine to a square (9 seconds)

What to put in the bank

Anything that repeats at the note's frequency can be a waveform in the bank, so a whole patch can become one waveform: a sawtooth through a resonant filter, an FM pair of sine oscillators, a sine shaper's phase distortion, a sound with its harmonics mixed by hand from several sine oscillators. The wavetable oscillator learns the shape, and the patch that made it can then keep running (as here) or be changed and captured again with the capture trigger. Some ideas:

Each waveform is scaled to the same peak level when it's learned, so quiet and loud sources come out equally loud, and only their shapes matter. If you connect fewer than four, they're spread over the whole position: with only a and d connected, the position morphs from a to d; with a, c and d, c sits in the middle.

When you might use it

For music nerds

Wavetable synthesis

Wavetable synthesis was pioneered by Wolfgang Palm in the PPG Wave of the early 1980s, and carried on by Waldorf, and in software synthesizers such as Serum and Vital: an oscillator reading single cycles from a table of waveforms, with a position control that scans through it. Its strength is timbre that moves in ways a filter can't: a filter only takes harmonics away, smoothly from the top down, but a wavetable can move harmonics anywhere, bring new ones in, or swap the whole spectrum for another.

This oscillator's bank is learned from the patch rather than chosen from a list, so its tables are whatever you can build. Morphing is linear crossfading between neighbouring waveforms, as on most modern wavetable synths; early wavetable synths often stepped audibly from one wave to the next instead.

Phase and level alignment

Crossfading two waveforms only sounds smooth if they line up: a sine crossfaded with the same sine half a cycle later would cancel out in the middle. So each learned waveform is turned in its cycle so that its fundamental rises through zero at the start, as a sine's does, and scaled to the same peak; its average (any DC offset) is removed. The fundamental then never cancels in a morph. Higher harmonics may still partly cancel midway, where two waveforms have them in opposite phase (as the sawtooth and the square do for some of theirs), and that's part of each pair's morph character: try morphs in both directions of the bank.

Pitch, and why sources should match it

The node records one cycle as the number of samples its own frequency says a cycle lasts. If a source plays at a different frequency, what's recorded isn't one of its cycles, but a slice of the wave that doesn't join up, and the learned waveform will have a jump in it. So keep every source at the node's frequency, from the same note to frequency converter, as the synths above do. A source an octave higher works too: two of its cycles fit in one, giving a waveform an octave up in the bank. Below 20 Hz, it records a 20 Hz cycle.

For math nerds

Capture

When a waveform is connected, the node is made, or capture rises, the node records the next ⌈f_s / f⌉ + 2 samples of every connected input (f at least 20 Hz), in the audio thread. A separate thread then makes each recording into a frame: the cycle is resampled to 2,048 points by linear interpolation, transformed, rotated so the fundamental's phase is that of a sine, and scaled to a peak of 1 unless it's essentially silent (peak minus offset below 10⁻⁴):

F(φ) = x(φ − s) / peak, s = (arg X₁ + π/2) / 2π

and the frame's eleven band-limited levels are built from its spectrum exactly as the sawtooth oscillator's tables are (see that page), with the average (bin 0) removed. The finished bank replaces the old one; the audio thread notices and crossfades from the old bank to the new over 441 samples (10 ms). The first bank of a new node replaces a silent one, so a note's first sound fades in from silence.

Morphing and playing

With K frames and position P, the oscillator plays

u = P (K − 1), y = (1 − (u − ⌊u⌋)) F_⌊u⌋(φ) + (u − ⌊u⌋) F_⌊u⌋+1(φ)

where each F is read at the level (and fade to the next level) for the node's frequency, so the output is band-limited at any pitch, and φ is the usual phase accumulator, shifted by the phase modulation input. Morphing is per sample, so the position can move at any speed, even at audio rates (which turns into a kind of amplitude modulation between the frames, with sidebands of its own). Each sample costs two table reads per frame involved: up to four, or eight during a bank crossfade.

Back to Sources: oscillators
Node reference
Contents