Harmonic Osc

SourcesharmonicoscHeavy CPU

Additive oscillator — 16 sine partials with their own drawbars.

What it does

Additive oscillator — build a timbre from 16 sine partials.

Wraps daisysp::HarmonicOscillator<16>. Rather than summing sixteen separate sine oscillators, it takes one sinf of the phase and walks the partials with a two-term recurrence, so the cost is roughly two transcendentals plus sixteen multiply-adds per sample regardless of how many bars are up. The amplitude array is written once at boot with a single SetAmplitudes call against a file-scope constant array; the drawbars have no ports because sixteen handles is not a node anyone can wire. Amplitudes are clamped to 0-1 each and the whole set is scaled down if it sums above 1, because the DaisySP class documents that budget and does not enforce it.

Parameters

  • Partial Amplitudes

    amplitudes
    Default 0.29,0.14,0.09,0.07,0.05,0.04,0.04,0.03,0.03,0.02,0.02,0.02,0.02,0.02,0.01,0.01

    One bar per harmonic partial: bar 1 is the fundamental, bar 2 twice its frequency, and so on up to 16. This is the timbre — a 1/n slope sounds like a sawtooth, odd bars only sound like a square, and the fundamental alone is a plain sine. The bars are set once when the patch boots, not per sample, so nothing can modulate them at audio rate; use the Amp input for that. If the bars add up to more than 1 the whole set is scaled down together at build time, which keeps the timbre and lowers the level.

  • First Harmonic

    firstHarmonic
    Default 1Range 1 … 16

    Which harmonic the first bar actually controls. At the default of 1 the bars are harmonics 1 to 16 and the fundamental is present. Set it to 2 and the bars become harmonics 2 to 17, so the fundamental disappears and the pitch you hear jumps an octave while the timbre stays hollow — the classic way to get a thin, reedy tone out of an additive voice. Setup-time only.

Sixteen sine partials of one fundamental, each with its own drawbar. Freq sets the fundamental in Hz and is per-sample (modulatable); the bars are not — they are baked in at build time, so wire an envelope into Amp to play it. Partials that would land above half the sample rate are faded out by the DSP rather than aliasing.

Ports

In

  • Freq frequency
  • Amp amplitude

Out

  • Audio Out output

Audio Control

Inputs

Freq
Fundamental frequency in Hz. Per-sample, so it is modulatable. Defaults to 440.
Amp
Output level (a post-multiply VCA). Defaults to 1.0.

Outputs

Audio Out
The summed partials.

Rules and gotchas

  • The drawbars are setup-time, not per-sample. They are baked into the generated C++ as a constant array, so nothing in the patch can change the timbre while it runs — the Amp input is the only level control that moves.
  • The partial count is fixed at 16 and is not a parameter. Changing it would change which C++ is emitted, and bars you leave at zero cost one multiply-add each and nothing more.
  • If the bars sum to more than 1, the whole set is scaled down together at build time. The timbre is preserved and the level drops; individual bars are never clipped, because that would change the sound into a different one.
  • All bars at zero is allowed and emits silence, exactly as set. On hardware that is indistinguishable from a dead patch, so the Inspector warns when it happens — raise a bar before you flash rather than debugging the board.
  • First Harmonic above 1 removes the fundamental: the bars shift up the series, the perceived pitch rises, and the tone goes hollow. It is a setup-time value like the bars.
  • Partials above half the sample rate are faded out by the DSP itself rather than folding back, so a high Freq thins the tone out instead of aliasing into noise.