Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/oscillators/polyblep is a sine, saw, square or triangle oscillator with an f32 phase accumulator and octave, semitone and cent offsets. Saw and square subtract the two-sample polynomial BLEP residual at each edge; the triangle is a leaky integrator (×0.999 per sample) of the blepped square. The per-waveform math is the shared voice stage code in voices/stages, the functions the subtractive voice's oscillator calls, so the two cannot diverge. Pitch is frequency × 2^(octave + semitone/12 + cents/1200).

Parameters

PathSetterRange as codedDefaultUnit
waveformsetOscillatorNodeWaveformRounded, then 0..3: sine, saw, square, triangle1 (saw)index
frequencysetOscillatorNodeFrequency0 to 20000440Hz
gainsetOscillatorNodeGain0 to 11linear
octavesetOscillatorNodeOctave−3 to +30octaves
semitonesetOscillatorNodeSemitone−12 to +120semitones
centssetOscillatorNodeCents−100 to +1000cents

Lifecycle

initOscillatorNode(sampleRate) → setters → oscillatorNodeTick(state) per sample → resetOscillatorNode, which zeroes the phase and triangle state and keeps the settings. For note starts, resetOscillatorNodePhase(state, phase) wraps a phase in cycles and seeds the triangle integrator to match it, so a triangle started at phase 0 begins at its trough. There is no sample-rate prepare; build a new state for a new rate.

When to use it

A plain oscillator for a synth voice, a test tone or a modulation source that must match the subtractive voice's oscillator sample for sample.

Limits

  • Mono sample tick. The tick returns the sample before gain; the caller multiplies by gain, as the Graph node does.
  • The pitch Math.pow runs every tick. Changes apply on the next sample with no smoothing.
  • The clamps are conditional, so a NaN setting passes through.
  • resetOscillatorNode at phase 0 leaves the triangle integrator at 0, which the source notes gives a unipolar startup transient.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Parameters

ParameterTypeSetter
Waveform waveformfloatsetOscillatorNodeWaveform
Frequency frequencyfloatsetOscillatorNodeFrequency
Gain gainfloatsetOscillatorNodeGain
Octave octavefloatsetOscillatorNodeOctave
Semitone semitonefloatsetOscillatorNodeSemitone
Cents centsfloatsetOscillatorNodeCents

Ports

  • Out outoutput · audio · mono

One sample per oscillatorNodeTick call.

Dependencies

Dependents

No other node imports this one.

Used by

No plugin with a published composition uses this node yet.