Lesson 8

Wavetable

Additive computed every partial in real time. FM computed a rich spectrum from almost nothing. The third option is not to compute at playback at all: work the spectra out in advance, store them, and spend the running budget on looking things up.

A table is a stack, not a waveform

The word wavetable gets used loosely, and the loose usage hides the idea. A single stored waveform is not interesting: it is one spectrum, fixed forever, and lesson 1 established that a sound which never changes is not an instrument.

A wavetable proper is a stack of single-cycle waveforms, and the instrument has a control saying which one to read. Move that control and the spectrum changes to whatever the next frame holds. The control is usually called position, and it is the method's entire character.

The important consequence is that position is not a filter. A filter can only attenuate what the oscillator already produced, so it can never make a quiet partial loud. A wavetable can, because the next frame is simply a different list of numbers, and nothing constrains it to be a dimmer version of the last one.

Eight spectra, and a slider between them

Sweep the position. Nothing is being filtered; the table is being read at a different place.

  1. Sine
  2. Triangle
  3. Square
  4. Saw
  5. Bright
  6. Formant
  7. Comb
  8. Narrow

Press play to see the trace

Between
Saw
Blend
0%
Partials present
48
Oscillators
1

One oscillator, reading a stored table. The spectra were computed once and are now only being looked up and blended, which is the trade this method makes: memory instead of arithmetic. It is also why a wavetable can go somewhere a filter cannot. There is no setting of any filter that turns a saw into the comb frame, because a filter can only remove, and the comb is missing partials the saw has while keeping ones a low-pass would have taken first.

Position is the brightness control, and it is arbitrary

Each method so far has had one control that behaves as brightness. Subtractive has cutoff, FM has index, additive has whatever you decide to do with sixty-four envelopes. Wavetable has position, and it differs from the others in a way worth noticing: cutoff and index are physically monotonic, and position is whatever the table designer put in the frames.

Sweep the slider above and it mostly gets brighter, because the frames are ordered that way here. Reorder them and it would not. That freedom is the method's strength and the reason two wavetable instruments with identical engines can be completely different to play: the tables are the instrument.

An envelope on position is the standard gesture, exactly as an envelope on cutoff was in lesson 4 and an envelope on index was in lesson 7. Three methods, three completely different mechanisms, and the same musical move each time.

One honest note about the interpolation. The figure blends the two neighbouring spectra, which cannot cancel. A good deal of real hardware crossfades the two waveforms instead, which is cheaper and can partially cancel where the frames disagree about phase, producing a dip in the middle of a morph. The smoother behaviour here is a choice rather than the norm.

And then lesson 2 comes back

Storing the spectra solves the computation problem and creates a new one. A stored table contains however many partials were baked into it, and that number was decided without knowing what pitch you would play it at.

A table with 128 partials is entirely reasonable for a bass note. At C6 the fundamental is over a kilohertz, so only about twenty of those partials fit below Nyquist, and the other hundred-odd do not politely vanish. They fold, exactly as they did in lesson 2, and for exactly the same arithmetic reason.

The fix is mipmapping: store several truncated versions of the same table, one per register, and pick by pitch. It is the same idea as texture mipmaps in graphics, invented for the same reason, and the name was borrowed from there.

The same table, played too high

Start high with one table, then switch. Down at C2 it sounds identical either way.

Table selection

All 128 stored partials are rendered whatever the pitch. The ones that no longer fit do not disappear, they fold.

Pitch

C6 is 1046.5 Hz. At 48,000 Hz only 22 of the table's 128 partials fit underneath Nyquist.

Press play to see the trace

Partials this register can use, out of 128 stored

  1. C2128
  2. C3128
  3. C545
  4. C622
Stored partials
128
Rendered
-
Fit below Nyquist
22
Folding
106 partials

At C6, 106 of the 128 stored partials sit above Nyquist. With one table they are rendered anyway and fold back down into the audible range as inharmonic debris, which is lesson 2 arriving from a completely different direction: nothing is being generated naively here, a perfectly good stored spectrum is simply being used in the wrong register.

What this actually costs

The trade is memory for arithmetic, and the numbers are worth stating because they explain the method's history.

One frame of 2048 samples is 8 kilobytes at single precision. A table of 64 frames is half a megabyte. Mipmapping it across ten registers multiplies that again. A modern instrument with hundreds of tables is therefore hundreds of megabytes of precomputed spectrum, which is unremarkable now and was inconceivable in 1980.

Which is why the early wavetable instruments sound the way they do. The PPG Wave had tables of 64 frames at 8-bit resolution, and its characteristic grit is not a design choice but the sound of a severely limited memory budget. When memory got cheap the method did not change at all; it simply stopped being lossy, and reappeared as the dominant approach in software instruments.

Do the work in advance and you have the third escape. It buys a control no filter can imitate and costs storage rather than computation. Its one real trap is that a stored spectrum has no idea what pitch it will be asked to play at.

Every method so far has described a spectrum, whether by specifying it, generating it, or storing it. Lesson 9 stops describing sound altogether and simulates the object that would have made it, at which point the spectrum becomes an output rather than an input. It is also the one lesson that needs machinery stock Web Audio cannot provide.

Battuto is a free set of courses from Aphelion. We also make Phonon, a DAW built on everything in these lessons.