← All modules

@maru shared this instrument so you can build on it and use it in your DAW.

AvailableInstrument

FM Keys

A four-operator FM keyboard with no filter.

About

A four-operator FM keyboard with no filter. Four sine-wave operators, six ways of wiring them, an envelope on each, and velocity that changes the tone as well as the volume. From those it makes electric pianos, bells, brass, basses, pads and a wooden log drum.

The idea

An FM operator is an oscillator with an envelope, and nothing else. There is no cutoff, no resonance and no tone control anywhere in this instrument, and it still makes metal, glass, wood and breath. What decides which of those you get is the wiring. An operator either reaches the output, and you hear it, or it bends the pitch of another operator, and you hear what it does to that one. The algorithm chart at the centre of the face shows that wiring, because it is the one control whose effect you cannot guess.

Two choices make patches easy to play. Modulation depth scales with the note, so a patch keeps its timbre from the bottom of the keyboard to the top. And velocity drives modulation, not just loudness: playing harder adds overtones, so a patch feels played rather than triggered.

Controls

  • Algorithm picks one of six wirings. Stack runs all four operators in series and is the densest. Twin is two independent pairs, the shape of the classic FM electric piano. Fan is three modulators onto one carrier and stays clean further up. Split is one modulator into two carriers that share an envelope. Pair is two modulators onto one carrier with a bare sine beside it, the bell recipe. Additive has no modulation at all. A new algorithm applies from the next note.
  • Each operator has a Ratio, its pitch as a multiple of the played note. Whole numbers keep the sound pitched; the √2 family (0.71, 1.41, 2.83, 3.53) lands between the harmonics, which is how FM makes bells. The last five entries are fixed frequencies that ignore the keyboard, so they stay put as you play, like the click of a mallet.
  • Each operator has a Level and an envelope. Operators 1 and 2 have a full attack, decay, sustain and release; operators 3 and 4 have attack and decay only and always die away. A modulator that fades and leaves a pure sine behind is the signature FM gesture: the note starts as metal and ends as glass.
  • Feedback lets operator 4 modulate itself, from a pure sine at zero to a bright, sawtooth-like tone at the top. It is calculated rather than looped, so it cannot run away.
  • Vel → Index sets how much velocity opens the modulators. At zero the tone stays the same however hard you play.
  • Brightness scales all the modulation in a patch at once, to dull or push a preset without editing four levels.
  • Level sets the output volume.

The voice settings choose between eight-voice polyphony, monophonic and mono legato playing, with note priority and a glide of up to two seconds.

Getting started

FM Keys is an instrument played with MIDI notes, from a keyboard controller or an on-screen keyboard. Start with E-Piano Glass and then E-Piano Bark, the same electric piano played softly and hard. Then try Bright Bells, Warm Bass, Brassy, Airy Pad, Pluck Attack, Log Drum, Split Bell or Pure Tones, which turns all modulation off and shows what the four operators are on their own.

How it works.

Each voice builds four OscillatorNodes and four GainNodes, one envelope per operator, and wires them according to the selected algorithm. The modulation itself uses the fact that an AudioParam is a summing junction: a modulator's envelope feeds a GainNode whose output is connected to the target oscillator's `frequency` parameter, so the gain's value is added to the target's pitch sample by sample. That value is the peak frequency deviation in hertz. This is genuine frequency modulation rather than the phase modulation a DX-style chip runs, and for sine operators the two produce the same spectrum, which is what makes the approximation a fair one, and which stops being true exactly when feedback makes operator 4 non-sinusoidal.

The deviation for each connection is the modulating operator's index multiplied by the frequency of the operator it modulates, so every frequency in a patch scales with the played note together. The ratio between deviation and modulator frequency is therefore constant across the keyboard, and so is the spectrum. A deviation fixed in hertz would be a whole tone at the top of the keyboard and two octaves at the bottom, which is why nothing here is set in hertz except the five ratio entries that are meant to be, those are fixed-frequency operators, and they stay put while the keyboard moves under them.

The ratio control is stepped rather than continuous, and that is a usability decision with teeth. The musically meaningful ratios are a measure-zero subset of any continuous range, the whole numbers, plus a handful of irrationals, and everything between them is a detune that sounds like a mistake. Twenty positions cover the whole numbers from 0.5 to 8, the √2 family that produces inharmonic bell spectra, and five absolute frequencies.

Operator 4's feedback is closed form. A cycle in a Web Audio graph must contain a DelayNode, and the smallest available delay is a whole 128-sample render quantum, which would be a comb filter at a sample-rate-dependent frequency rather than feedback. Instead the steady state is computed: a sine phase-modulating itself at depth β has harmonic amplitudes 2·Jₙ(nβ)/(nβ), the Bessel series that also solves Kepler's equation, and a PeriodicWave built from those coefficients is that steady state exactly. It is deterministic, band-limited by the oscillator like any other periodic wave, and costs nothing per sample. The one thing it does not reproduce is the loop's build-up transient, which arrives fully formed here.

Velocity does two separate things. Carrier levels are scaled by velocity squared, the repo's standard curve, because loudness is not linear in amplitude and a straight mapping leaves the quiet end of the keyboard feeling dead. Modulator indices are scaled by a separate curve under the Vel → Index control, and because index is brightness that is what makes playing harder sound harder rather than only louder.

Envelope decays are scheduled as an exponential ramp to the sustain level and then a step onto it, because an exponential ramp cannot reach zero and most of this instrument's operators decay to exactly that. Releases start from wherever the envelope has actually got to rather than from the sustain level, so letting go during an attack fades from the partial level instead of jumping up first.

Levels, brightness and feedback are pushed onto sounding voices as they move, because those are the controls a player sweeps while holding a chord. The algorithm, the four ratios and the envelope times are read at note-on and take effect on the next note: rewiring a live graph or re-pitching a ringing operator would click, and a patch edit that lands on the next note is the honest behaviour rather than one worth hiding.

Voices are capped at eight with oldest-first stealing, and a re-pressed key replaces its own voice rather than summing with it. Nothing in the signal path is random, there is no exciter and no noise, and a four-operator FM voice has nothing to be random about, so the same patch, note and velocity produce the same waveform every time.

What would you make with FM Keys?

Describe what you want to make. Build it with the Studio agent.

Goes well with.

Prototype

A pickup-position model for tuned tine voices.

Prototype

A tonewheel organ with nine drawbars and no attack stage.

Prototype

Two oscillator banks with continuous frame morphing.