Skip to content

SynthPatch Reference: Fields and Engine Keys ​

A SynthPatch is the object that describes one built-in synthesizer instrument: a named preset plus the fields you override. This page is the reference for it: the shared patch fields and their ranges, the per-engine engineParams keys and the activeWhen gates on them, the enum name tables, and the fields the sample engine adds. Choosing a preset, routing modulation and playing a patch are on Built-in Synthesizer; how each physical model works is on Physical Models.

Patch fields ​

The patch exposes the shared controls every engine uses:

SYNTH · SUBTRACTIVEIDLE
ADSR envelope — how a note rises and falls

The same held A3, shaped by its amplitude envelope. Attack and decay set how the note reaches and leaves its peak; sustain is the level it holds while a key is down; release is the fade after the key lifts. The top outline is that envelope — drag a control and watch the shape, then press play to hear it. (Pull sustain all the way to zero and the note decays to silence while the key is still down: a plucked shape rather than a held one.)

Attack
8 ms
Decay
140 ms
Sustain
0.75
Release
280 ms

Cents, velocity, and key tracking

  • Cent — 1/100 of a semitone; 100 cents = one piano key, 1200 = an octave. Pitch and detune amounts are in cents.
  • Velocity — how hard a note was struck (0–127); presets use it to control brightness or loudness.
  • Key tracking — making a parameter (like filter cutoff) follow the note's pitch up the keyboard.

Ranges are what synthPatchParamInfo() reports; a value that is non-finite or outside its range is refused by name, and the same call returns each field's init value.

GroupFields
Oscillatorunison (1-7) and detuneCents (0-200), both subtractive only; driftCents (0-100), driftRateHz (0.01-20), drive (0-1), pitchOffsetCents (-4800 to 4800)
FiltercutoffHz (10-22000), resonanceQ (0.5-30), keyTrack (0-1), envToCutoffCents and velToCutoffCents (-9600 to 9600), hpCutoffHz (0-22000, 0 is off)
Output stagesampleHoldHz (0-192000, 0 is off; a non-zero rate below 100 Hz runs at 100), bitDepth (0-24, 0 is off; a non-zero depth below 1 runs at 1 bit)
Amp and filter envelopesampDelayMs / ampHoldMs and the filter* pair (0-5000); attack, decay and release times (up to 20000 ms; decay and release are three time constants, so the set time lands 95% of the way to the target: about 26 dB down for a release, less for a decay to a non-zero sustain); ampSustain / filterSustain (0-1); oneShot (amp only, boolean)
LFOs and glidelfoRateHz, lfo2RateHz (0-40), lfoToPitchCents (0-1200), glideMs (0-5000); lfoShape (below) picks the vibrato and tremolo LFOs' waveform at every destination, the filter included: 'random' is a smoothed sample-and-hold seeded per voice, so a bounce repeats it
Bodybody (none / guitar / violin / woodTube / brassBell / vocal), bodyMix (0-1)
Stereo and outputstereoSpread (0-1), gain (linear, 0-4), polyphony (1-64), busDrive (0-1)
EnumsengineMode, waveform (subtractive only), filterModel, filterOutput (svf only), lfoShape ('triangle' / 'sine' / 'random'): names from synthEnumTables(), or 'default' to keep the base
Voice start stateretrigger ('default' / 'free' / 'note')
Engine sectionengineParams (a key-to-number record)
Mod matrixmodRoutings (up to 8), see Modulation routing
Sample enginesampleBank, sampleSet, sampleLevel (0-8), sampleLoop, sampleStartOffset (0-0.999), sampleKeyTrack; see the sample engine
BindinguseGmPrograms (Python use_gm_programs) follows incoming GM bank and program changes, see GM and GS Fallback Bank

(Polyphony is how many notes can sound at once; a voice is one sounding note, and voice stealing cuts the oldest note when you run out.)

The delay stage holds an envelope at zero before its attack starts and the hold stage keeps it at the peak before the decay; both are in milliseconds (Delay and hold: DAHDSR). driftRateHz sets how fast the per-voice pitch drift wanders, and driftCents its depth (Envelopes and Modulation shows what that sounds like). The four delay/hold times and the drift frequency are automatable on a live instrument; a delay or hold change applies the next time its stage starts.

oneShot ignores note-off. With zero amp sustain, the voice ends when its envelope decays to silence. With positive sustain, it needs an engine that ends naturally, such as a finite FM envelope, a percussion strike, or a non-looping sample. A sustained one-shot patch with no natural end has an unbounded tail, so automatic-length bounces are refused; pass a positive totalFrames to render a bounded window.

retrigger chooses the seed used when each voice starts. 'default' keeps the base patch's choice; every catalog preset uses 'free'. 'free' varies oscillator start phases, unison jitter, drift, and each engine's noise stream from the voice pool slot and running note count, so repeated notes generally differ. 'note' derives those values from the MIDI note number alone, so playing the same note again after its tail ends renders the same samples. The setting applies to each voice's start state. It does not reset controllers, the bus DC blocker, a piano's shared soundboard, a plucked string's sympathetic halo, an organ's wind chest, or effect tails. The drumKit preset keeps its own mode for each drum piece.

Body resonance ​

The body field is NativeSynth's body/formant resonance layer — the resonant character of an instrument's physical shell or vocal tract. Acoustic guitars, harps, violin-family strings, woodwinds, brass, and choir/voice fallbacks use this layer; solid-body electrics can leave body at none.

body: 'vocal' is the vowel formant bank, and it is reachable on any patch rather than only on the vocal engine — a subtractive oscillator driven through it is a sung tone rather than a filtered saw. That is exactly how the GM fallback bank voices Lead 6 (voice) and Pad 4 (choir), which is why those two do not sound like the synth leads and pads around them.

Engine parameters ​

engineParams sets fields of the selected engine's own model section by key: bow force, breath pressure, lip tension, strike position, FM operator levels, mode ratios. Keys are the section's field names in lowerCamelCase (bowForce, ops0.level, ranks2.level), and absent keys keep the base section's value.

typescript
const audio = project.bounce({
  totalFrames: 48000,
  numChannels: 2,
  synthInstruments: [{ instrument: { engineMode: 'bowedString', engineParams: { bowForce: 0.9, bowPosition: 0.08 } } }],
});
python
patch = sonare.SynthPatch(
    engine_mode="bowedString",
    engine_params={"bowForce": 0.9, "bowPosition": 0.08},
)
audio = project.bounce(synth_instruments=[sonare.ProjectInstrumentBinding(instrument=patch)], total_frames=48000, num_channels=2)

Like the wrapper fields, a value that is out of range is refused. An unknown key, a key of another engine's section, a non-finite value, a fractional value for a whole-number field or a value outside the field's range is refused with an error that names the key (engine param 'bowForce': out of range [0, 1]). In Python the field is engine_params, and the keys stay lowerCamelCase. The command-line --synth option takes a preset name only, so patches and engineParams are available in the bindings, not the CLI.

synthEngineParamInfo(engineMode) lists the keys an engine accepts, and synthPatchParamInfo() lists every numeric wrapper field. Both return SynthParamInfo[] in the shape of the insert parameter descriptor: name, type ('number' or 'boolean', a switch given as 0 or 1), integer, min, max, default, unit and, for a gated field, activeWhen. For an engine field default is the base preset's value; for a wrapper field it is the init patch's. default is a number, or a boolean for a switch (the percussion gmKit is true), so narrow it before doing arithmetic. synthEngineParamInfo returns [] for default and sample. unit is one of none, cents, Hz, ratio, ms, s, count, m, dB, N (newtons), mm, deg, midiNote, bits or dBPerOct. Python spells them synth_engine_param_info and synth_patch_param_info.

typescript
synthEngineParamInfo('fm').slice(0, 2);
// [{ name: 'algorithm', type: 'number', integer: true, min: 0, max: 5, default: 3, unit: 'none' },
//  { name: 'velocityExponent', type: 'number', min: 0, max: 4, default: 1.72, unit: 'none' }]

In Python each entry is a frozen SynthParamInfo dataclass with the same fields in snake_case (name, type, default, unit, integer, min, max, active_when). active_when is None for an ungated field, and otherwise a tuple of alternatives, each a tuple of SynthParamCondition(key, scope, relation, value).

The FM operator algorithm is the algorithm key of the fm section. Build a control panel from these descriptors rather than copying the ranges.

Subtractive keys ​

The subtractive engine also has a section of its own, set through engineParams; every key leaves the sound unchanged at its default. A second oscillator a fixed interval from the played pitch comes from osc2Level (0 – 4, 0 is absent), osc2IntervalCents (-2400 – 2400) and osc2Dry (0 – 1, the share that bypasses the filter). noiseLevel (0 – 4) adds pre-filter white noise and noiseAm (0 – 1) a slow amplitude noise on the oscillators; bandNoiseLevel (0 – 4) adds a post-filter band of white noise between bandNoiseLowHz and bandNoiseHighHz, each edge following the key by bandNoiseLowKeyTrack / bandNoiseHighKeyTrack (0 – 1). pulseWidth (0.02 – 0.98, 0.5 is symmetric) sets the square oscillator's pulse, unisonWidth (0 – 1, 0 is centred) spreads the unison stack across the stereo field while keeping the mono sum of the centred stack, and velocityExponent (0 – 4, default 2) is the note-on level curve (velocity / 127)^exponent. sustainKeySlopeDb (0 – 6 dB, default 0, which is off) lowers the held level of every note above sustainKeyBreak (0 – 127 as a MIDI note, default 60) by that many decibels per semitone, so a slope of 1 leaves a note an octave above the break 12 dB quieter and the break itself is unchanged. The break is gated on a non-zero slope.

Gated fields: activeWhen ​

A field can be accepted yet have no effect, because another field switches its section off. activeWhen states when the field reaches the voice, as a list of alternatives: each alternative is a list of conditions that must all hold, and the field is live when at least one alternative holds. A condition is { key, scope, relation, value }: key is read from the same synthEngineParamInfo table when scope is 'engine', or from the SynthPatch when it is 'patch'; relation is one of 'eq', 'ne', 'gt', 'ge', 'lt', 'le'. A field with no activeWhen is not gated. If you set a field and hear nothing change, read its activeWhen: in the percussion section 93 of the 94 fields are gated, so noiseBurstCount does nothing while gmKit is on.

typescript
synthEngineParamInfo('percussion').find((p) => p.name === 'noiseBurstCount')?.activeWhen;
// [[{ key: 'gmKit',     scope: 'engine', relation: 'eq', value: false },
//   { key: 'noiseGain', scope: 'engine', relation: 'gt', value: 0 }]]

In the percussion section every field except gmKit needs gmKit off, because the GM kit chooses its own pieces; the layer fields add their own gate (noiseBurstCount needs noiseGain > 0, shellNumModes needs shellMix > 0). A field that reaches the voice through several layers carries one alternative per route: baseFreqHz is live when any sounding mode or shell layer uses it, so its list has one alternative for each. In pipeOrgan, the single-pipe fields (stopped, brightness, reed) act only while rankCount is 0, and the ranks0.* fields only while rankCount is above 0. The reed, brass, freeReed, harpsichord, bowedString and additive sections gate their fields the same way.

To build a panel, evaluate each gate against the current values and disable or hide the control when no alternative holds; the value is still stored and still validated, it just does not change the sound. Compare numbers with the relation, and a boolean switch or a wrapper enum name (body: 'violin') with eq / ne. A field that depends on performance (velocity, a controller, overlapping notes) or only saturates past some value carries no activeWhen, so its absence does not promise that the field is always audible.

How an engine parameter differs from a patch field (what each controls, and where each lives) is explained in Synthesis Basics.

The Synth Playground builds its model controls this way: it shows only the fields whose gate holds, so the percussion engine with gmKit on shows gmKit alone, and with the kit off it shows the modal fields that apply.

Enum name tables ​

Every enum field takes a name string: a number is a TypeError and an unknown name a RangeError. Read the authoritative tables from the runtime with synthEnumTables() so the names never drift:

typescript
import { init, synthEnumTables } from '@libraz/libsonare';

await init();
synthEnumTables();
// {
//   engineModes:      ['default', 'subtractive', 'fm', ..., 'sample', 'singing'],
//   waveforms:        ['default', 'sine', 'saw', 'square', 'triangle', 'noise'],
//   builtinWaveforms: ['sine', 'saw', 'sawtooth', 'square', 'triangle'],
//   filterModels:     ['default', 'svf', 'transistorLadder', 'diodeLadder', 'sallenKey', 'svf4Pole'],
//   filterOutputs:    ['default', 'lowPass', 'bandPass', 'highPass'],
//   bodyTypes:        ['default', 'none', 'guitar', 'violin', 'woodTube', 'brassBell', 'vocal'],
//   modSources:       ['none', 'ampEnv', 'filterEnv', 'lfo1', 'lfo2', 'velocity', 'keyTrack',
//                      'modWheel', 'random', 'breath', 'aftertouch', 'expressionCc', 'pitchBend'],
//   modDestinations:  ['none', 'pitchCents', 'cutoffCents', 'ampGain', 'panUnits', 'resonanceQ',
//                      'vibratoDepthCents', 'filterEnvDepth', 'lfo1RateScale', 'excitationForce',
//                      'excitationPosition', 'excitationBrightness', 'spectrumMorph'],
//   // ...plus controllerInputs, controllerAxes, articulations,
//   //    mpeDimensions, noteTrackings, sampleLoopModes, sampleKeyTracks,
//   //    retriggers, lfoShapes, partRigModes and sampleDescLoopModes
// }

Python spells the call synth_enum_tables() and returns the same tables under snake_case keys.

The same arrays are also exported as named constants (SYNTH_ENGINE_MODES, SYNTH_OSC_WAVEFORMS, SYNTH_FILTER_MODELS, SYNTH_FILTER_OUTPUTS, SYNTH_BODY_TYPES, SYNTH_MOD_SOURCES, SYNTH_MOD_DESTINATIONS, SYNTH_LFO_SHAPES, plus BUILTIN_SYNTH_WAVEFORMS). Note the index 0 in most tables is 'default' (keep the base value); modSources / modDestinations use 'none' instead.

Node and WASM expose this field as SynthPatch.retrigger, and Python uses the same SynthPatch.retrigger attribute. Its TypeScript union is SynthRetrigger, and SYNTH_RETRIGGERS is the exported name table ['default', 'free', 'note'], the same list synthEnumTables() returns as retriggers. The C API names the matching enum SonareSynthRetrigger and its values SONARE_SYNTH_RETRIGGER_BASE, SONARE_SYNTH_RETRIGGER_FREE, and SONARE_SYNTH_RETRIGGER_NOTE.

builtinWaveforms / BUILTIN_SYNTH_WAVEFORMS is a separate list: it belongs to the minimal built-in oscillator synth (setBuiltinInstrument), not to NativeSynth's waveform field. It has no 'default' entry, accepts 'sawtooth' as well as 'saw', and does not accept 'noise'. Its ADSR times are linear ramps over the set time, unlike the three-time-constant decay and release of a SynthPatch.

Host PCM: the sample engine ​

The sample engine reads its audio from a SampleBank you build yourself. Three steps: add mono float frames, map note-number and velocity ranges onto them, then bind the bank alongside a patch whose engineMode is 'sample'.

typescript
import { init, Project, SampleBank } from '@libraz/libsonare';

await init();

const bank = new SampleBank();
try {
  const index = bank.addSample(pcm, { rootKey: 60, sourceRate: 44100 });
  bank.addZone({ sampleIndex: index });          // an empty zone is the whole keyboard
  const audio = project.bounce({
    totalFrames: 24000,
    synthInstruments: [{ instrument: { engineMode: 'sample', sampleSet: 0, sampleBank: bank } }],
  });
} finally {
  bank.destroy();   // the WASM handle is NOT garbage-collected
}
python
import libsonare as sonare

with sonare.SampleBank() as bank:                      # closes the native handle
    index = bank.add_sample(pcm, root_key=60, source_rate=44100.0)
    bank.add_zone(0, sample_index=index)               # the whole keyboard, in set 0
    patch = sonare.SynthPatch(engine_mode="sample", sample_set=0, sample_bank=bank)
    audio = project.bounce(synth_instruments=[sonare.ProjectInstrumentBinding(instrument=patch)], total_frames=24000)

A zone is a note-number and velocity range pointing at one sample; every bound defaults on its own, so {} is the whole keyboard at every velocity and narrowing one axis leaves the other whole. Zones live in numbered sets, and a patch names the set it plays through sampleSet. Build the whole bank before the bounce that binds it starts — the sample pool is contiguous and moves as it grows, so adding to it while something sounds invalidates the voices reading it.

The patch fields the engine adds:

FieldMeaning
sampleBankThe bank to read PCM from. A JS binding convenience, not part of the patch itself; a 'sample' patch bound without one renders silence
sampleSetKeymap set in that bank (negative selects none)
sampleLevelLinear gain on the sample, before the voice's own amp stage
sampleLoopOverrides the loop mode the bank recorded for the sample
sampleStartOffsetAttack skip, as a fraction of the mapped region (0 to just under 1)
sampleKeyTrackWhether the sample follows the played key, or plays every key at its recorded pitch — the latter is what a one-shot drum wants

sampleLoop takes 'default' (keep what the bank recorded), 'none', 'continuous', or 'keyDown'. sampleKeyTrack takes 'default', 'on', or 'off'.

synthEnumTables() lists both as sampleLoopModes and sampleKeyTracks; in JavaScript they are also exported as the constants SAMPLE_LOOP_MODES and SAMPLE_KEY_TRACKS.

A sample's own loop points and loop mode are properties of the recording and belong on the SampleDesc you pass to addSample; sampleLoop is the per-patch override on top of that. A loop that comes out empty is dropped, so a malformed loop plays as an unlooped sample rather than wrapping over nothing.