Skip to main content

Node

Enum Node 

Source
#[non_exhaustive]
pub enum Node {
Show 35 variants Square { freq: Value, duty: Value, }, Triangle { freq: Value, }, Sawtooth { freq: Value, }, Sine { freq: Value, }, Noise { color: NoiseColor, }, Fm { freq: Value, ratio: f32, index: Value, }, Super { wave: SuperWave, freq: Value, voices: u32, detune_cents: f32, }, Seq {
Show 14 fields bpm: f32, steps_per_beat: u32, wave: SeqWave, duty: Value, fm: FmKnobs, pluck: PluckKnobs, piano: PianoKnobs, kit: KitStyle, bass: BassKnobs, sf2: Sf2Knobs, swing: f32, humanize: f32, env: Adsr, notes: Vec<SeqNote>,
}, Impact { hardness: f32, velocity: f32, }, Dust { density: f32, decay: f32, }, Env { adsr: Adsr, }, Tracks { tracks: Vec<Track>, master: Vec<Node>, }, Mix { inputs: Vec<Node>, }, Mul { inputs: Vec<Node>, }, Chain { stages: Vec<Node>, }, Lowpass { cutoff: Value, q: f32, }, Highpass { cutoff: Value, q: f32, }, Bandpass { cutoff: Value, q: f32, }, Notch { cutoff: Value, q: f32, }, Peak { cutoff: Value, q: f32, gain_db: f32, }, Lowshelf { cutoff: Value, gain_db: f32, }, Highshelf { cutoff: Value, gain_db: f32, }, Gain { amount: Value, }, Bitcrush { bits: u8, }, Downsample { factor: u32, }, Delay { secs: f32, feedback: f32, }, Reverb { room: f32, mix: f32, }, Modal { modes: Vec<Mode>, mix: f32, }, Drive { amount: Value, shape: DriveShape, aa: Option<bool>, }, RingMod { freq: Value, }, Flanger { rate: f32, depth: f32, feedback: f32, mix: f32, }, Phaser { rate: f32, depth: f32, feedback: f32, mix: f32, }, Chorus { rate: f32, depth: f32, mix: f32, }, Duck { trigger: Box<Node>, amount: f32, attack: f32, release: f32, }, Compress { threshold: f32, ratio: f32, attack: f32, release: f32, makeup: f32, },
}
Expand description

A node in the synthesis graph. Every node evaluates to a mono signal.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Square

Square/pulse wave with variable duty cycle. duty may be a modulator (e.g. an lfo) for PWM — the classic moving chiptune lead.

Fields

§freq: Value

Frequency in Hz.

§duty: Value

Fraction of the period spent “high”, 0..1 (0.5 = symmetric square).

§

Triangle

Triangle wave.

Fields

§freq: Value

Frequency in Hz.

§

Sawtooth

Sawtooth wave.

Fields

§freq: Value

Frequency in Hz.

§

Sine

Sine wave.

Fields

§freq: Value

Frequency in Hz.

§

Noise

Noise source (percussion / explosion / texture). White by default; pink is warmer (−3 dB/oct, good for wind/rumble), brown darker still.

Fields

§color: NoiseColor

Spectral colour of the noise.

§

Fm

Two-operator FM: a carrier at freq is phase-modulated by an operator at freq * ratio with modulation index. Bells, e-piano, metallic basses. Slide index down for a struck/plucked attack.

Fields

§freq: Value

Carrier frequency in Hz.

§ratio: f32

Modulator frequency as a multiple of the carrier (e.g. 2.0, 3.5).

§index: Value

Modulation index (depth). Higher ⇒ brighter / more sidebands.

§

Super

Unison “super” oscillator: voices detuned copies of a band-limited saw/square, summed for a fat, wide lead or pad (the supersaw). Detune is spread symmetrically across detune_cents.

Fields

§wave: SuperWave

Oscillator shape for every voice.

§freq: Value

Centre frequency in Hz (modulatable).

§voices: u32

Number of detuned voices (1..=16).

§detune_cents: f32

Total detune spread in cents across all voices.

§

Seq

A note sequencer: plays notes on a tempo grid, each with its own pitch, length, and a shared per-note ADSR. This is how you write real melodies, basslines, and drum patterns (rests = gaps between notes).

Fields

§bpm: f32

Tempo in beats per minute.

§steps_per_beat: u32

Grid resolution: steps per beat (4 = sixteenth notes).

§wave: SeqWave

Instrument used for every note.

§duty: Value

Duty cycle when wave is square (may be modulated for PWM).

§fm: FmKnobs

FM voice knobs (wave: "fm"), flattened onto the node.

§pluck: PluckKnobs

Plucked-string knobs (wave: "pluck"), flattened onto the node.

§piano: PianoKnobs

Piano tone knobs (wave: "piano", engine ≥ 3), flattened onto the node.

§kit: KitStyle

Drum-kit voicing when wave is kit. Omitted ⇒ classic (the original kit, byte-identical); acoustic/electronic/808 are alternate synthesized kits.

§bass: BassKnobs

Bass tone knobs (wave: "bass"), flattened onto the node.

§sf2: Sf2Knobs

SoundFont sampler settings (wave: "sampler"), flattened onto the node.

§swing: f32

Swing, 0..1: every off-beat grid step is delayed by this fraction of a step (0 = straight, ~0.55 = classic shuffle). Off-beats are odd steps, so set steps_per_beat to the swung subdivision.

§humanize: f32

Humanize, 0..1: deterministic per-note timing and velocity jitter (from the doc’s seed) so repeats stop sounding machine-perfect. 0.1–0.25 is a tasteful player; 1 is sloppy.

§env: Adsr

Per-note amplitude envelope.

§notes: Vec<SeqNote>

The notes to play.

§

Impact

Impact exciter: a short excitation burst that models the contact force of a strike — a single raised-cosine force pulse whose width is set by hardness (hard = brief, bright click; soft = wider, duller thud), scaled by velocity. On its own it is a faint tick; its job is to excite a resonant body — put it before a modal bank (or any resonant filter) in a chain: chain[ impact, modal ] is a struck object. The harder the strike, the more high modes it lights up.

Fields

§hardness: f32

Strike hardness, 0..1 (1 = hardest / brightest / shortest contact).

§velocity: f32

Strike velocity / level, 0..1.

§

Dust

Sparse stochastic impulses — a Poisson click train. density events per second fire at random times with random ± amplitude, each decaying over decay seconds (0 = bare single-sample impulses). The grain generator behind crackle textures: fire, rain, geiger ticks, sparks, debris. Feed it through a bandpass/highpass (for tone) or a modal (for pitched debris). Its randomness draws from the layer’s deterministic stream, so like noise it is edit-stable within its own mixer layer.

Fields

§density: f32

Mean events per second.

§decay: f32

Per-grain decay time in seconds (0 = single-sample impulses).

§

Env

ADSR amplitude envelope with an sfxr-style punch transient.

Fields

§adsr: Adsr

Envelope shape.

§

Tracks

The mixing console — only valid as the document root. Each track is a mono graph placed on the stereo stage with its own pan and gain (sampler tracks keep their native stereo); master is a processor chain applied to the stereo bus (compressor glue, reverb — the reverb runs with decorrelated left/right tails). This is how multi- instrument music gets a real stereo image instead of a mono sum.

Fields

§tracks: Vec<Track>

The mixer channels.

§master: Vec<Node>

Processors applied to the stereo master bus, in order.

§

Mix

Sum (layer) all inputs.

Fields

§inputs: Vec<Node>

Branches to add together.

§

Mul

Multiply all inputs (typically source × envelope).

Fields

§inputs: Vec<Node>

Branches to multiply together.

§

Chain

Serial pipe: stage 0 is a source, each later stage processes the prior output.

Fields

§stages: Vec<Node>

Ordered processing stages.

§

Lowpass

Resonant low-pass filter.

Fields

§cutoff: Value

Cutoff frequency in Hz.

§q: f32

Resonance / quality factor.

§

Highpass

Resonant high-pass filter.

Fields

§cutoff: Value

Cutoff frequency in Hz.

§q: f32

Resonance / quality factor.

§

Bandpass

Band-pass filter.

Fields

§cutoff: Value

Center frequency in Hz.

§q: f32

Resonance / quality factor.

§

Notch

Notch (band-reject) filter: removes a narrow band around cutoff (hum / resonance removal).

Fields

§cutoff: Value

Center frequency in Hz.

§q: f32

Quality factor (higher ⇒ narrower notch).

§

Peak

Peaking EQ: boost or cut a band around cutoff by gain_db (surgical tone shaping — act on the brightness/centroid the analyzer reports).

Fields

§cutoff: Value

Center frequency in Hz.

§q: f32

Quality factor (bandwidth).

§gain_db: f32

Gain in dB (positive boosts, negative cuts).

§

Lowshelf

Low shelf: boost/cut everything below cutoff by gain_db (add weight or thin out lows).

Fields

§cutoff: Value

Shelf corner frequency in Hz.

§gain_db: f32

Gain in dB.

§

Highshelf

High shelf: boost/cut everything above cutoff by gain_db (air / de-ess).

Fields

§cutoff: Value

Shelf corner frequency in Hz.

§gain_db: f32

Gain in dB.

§

Gain

Scale the signal by a (possibly modulated) factor.

Fields

§amount: Value

Multiplier.

§

Bitcrush

Quantize amplitude to bits of resolution for crunch.

Fields

§bits: u8

Bit depth, 1..16.

§

Downsample

Sample-rate reduction by an integer factor for lo-fi grit.

Fields

§factor: u32

Hold each sample for this many samples.

§

Delay

Feedback delay (echo / comb).

Fields

§secs: f32

Delay time in seconds.

§feedback: f32

Feedback amount, 0..1.

§

Reverb

Schroeder-style reverb.

Fields

§room: f32

Room size, 0..1 (larger ⇒ longer tail).

§mix: f32

Dry/wet mix, 0..1.

§

Modal

Modal resonator bank: a set of damped sinusoidal partials (modes) excited by the incoming signal — a struck/resonant object’s body. Bells, glass, metal bars, wood, ceramic, coins, and the resonant ping of UI/impact sounds, none of which the oscillators can voice cleanly. Each mode is one 2-pole resonator (a constant-peak-gain bandpass), so a bank is N parallel resonators — cheap, stable, deterministic. Use it as a chain stage after an excitation: chain[ impact, modal ]. The excitation’s brightness lights the modes; the modes’ frequencies and decays define the timbre. Author modes explicitly — the cookbook lists frequency/decay tables for common materials to copy and tune.

Fields

§modes: Vec<Mode>

The resonant partials (1..=64). Each is a damped sine.

§mix: f32

Wet/dry mix, 0..1 (1 = pure resonance; lower keeps some of the raw excitation transient for extra attack click).

§

Drive

Waveshaper for saturation / distortion. amount is pre-gain; shape chooses the curve (warm tanh, aggressive hard clip, or foldback).

Fields

§amount: Value

Drive amount (pre-gain into the shaper).

§shape: DriveShape

Distortion curve.

§aa: Option<bool>

Antiderivative anti-aliasing. The waveshaper’s harmonics fold back as inharmonic alias dirt at the base rate; ADAA suppresses that for a clean, hi-fi distortion. Honoured only when the document’s engine is ≥ 1 (so legacy documents stay bit-exact); within an engine-1 document it is on by default — set false to hear the raw aliasing curve. Omitted ⇒ follow the engine.

§

RingMod

Ring modulation: multiply the signal by a sine carrier at freq. Metallic, clangorous, robotic textures.

Fields

§freq: Value

Carrier frequency in Hz.

§

Flanger

Flanger: a very short modulated delay with feedback — the classic jet sweep / metallic whoosh. Stronger and more resonant than chorus.

Fields

§rate: f32

LFO rate in Hz.

§depth: f32

Modulation depth, 0..1.

§feedback: f32

Feedback amount, 0..1 (more ⇒ more resonant).

§mix: f32

Dry/wet mix, 0..1.

§

Phaser

Phaser: swept all-pass notches — a hollow, swooshing movement for pads, lasers, and sci-fi textures.

Fields

§rate: f32

LFO sweep rate in Hz.

§depth: f32

Sweep depth, 0..1.

§feedback: f32

Feedback amount, 0..1.

§mix: f32

Dry/wet mix, 0..1.

§

Chorus

Chorus: a short modulated delay mixed with the dry signal for thickening and width.

Fields

§rate: f32

LFO rate in Hz.

§depth: f32

Modulation depth, 0..1.

§mix: f32

Dry/wet mix, 0..1.

§

Duck

Sidechain duck: gain-reduces the chained signal whenever trigger is loud — the pumping that glues a bass or pad to the kick. The trigger is rendered silently (it only steers the gain); chain the audible kick separately in the mix.

Fields

§trigger: Box<Node>

The signal whose loudness drives the ducking (e.g. the kick seq).

§amount: f32

Duck depth, 0..1 (1 = fully silent at the trigger’s peak).

§attack: f32

Gain-reduction attack in seconds.

§release: f32

Recovery time in seconds (the “pump” length).

§

Compress

Dynamic-range compressor: tames peaks above threshold (dBFS) by ratio, with attack/release ballistics, then applies makeup gain (dB). The glue behind loud, punchy game audio.

Fields

§threshold: f32

Threshold in dBFS (e.g. -18).

§ratio: f32

Compression ratio (e.g. 4 = 4:1).

§attack: f32

Attack time in seconds.

§release: f32

Release time in seconds.

§makeup: f32

Make-up gain in dB.

Implementations§

Source§

impl Node

Source

pub fn is_processor(&self) -> bool

True if this node only makes sense as a non-first stage of a chain (it transforms an incoming signal rather than generating one).

Source

pub fn children(&self) -> Children<'_>

Every direct child of this node — the nested graphs of the combinator variants: mix/mul inputs, chain stages, a tracks’ layers then its master chain, and a duck’s trigger. The ONE traversal definition every walker shares, so a new variant can never be silently skipped the way the hand-written walkers were (the duck-trigger omissions in the vary and MIDI walkers were exactly that class). The match is exhaustive on purpose: adding a variant without a children decision is a compile error, never a silent skip.

Source

pub fn children_mut(&mut self) -> ChildrenMut<'_>

Mutable form of children.

Source

pub fn walk(&self, f: &mut impl FnMut(&Node))

Apply f to this node and every descendant, depth-first (parents before children, in document order).

Source

pub fn walk_mut(&mut self, f: &mut impl FnMut(&mut Node))

Mutable form of walk.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Node

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for Node

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for Node

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more