Sanic Boom

Harmonics

Add harmonic overtones to waveforms

The harmonics() function adds overtones to basic waveforms, creating richer timbres.

Basic Usage

[C4 E4 G4] |> sine |> harmonics(count: 4) |> reverb(0.3)

Parameters

ParameterTypeDefaultDescription
countint-Number of harmonics to add
fallofffloat1.0Amplitude falloff (1/n^falloff)
oddboolfalseOnly odd harmonics (hollow sound)

Or specify exact harmonics:

[C4 E4] |> sine |> harmonics(2, 3, 5)  // Only 2nd, 3rd, 5th

Examples

Rich Pad

[C4 E4 G4 B4] |> sine |> harmonics(count: 6) |> reverb(0.5)

Hollow Clarinet-like

[C4 G4] |> sine |> harmonics(count: 8, odd: true)

Bright Bell

[E5 G5] |> sine |> harmonics(count: 4, falloff: 0.5) |> delay(1/8)

How It Works

Harmonics are integer multiples of the fundamental frequency:

  • 2nd harmonic = 2x frequency (octave)
  • 3rd harmonic = 3x frequency (octave + fifth)
  • 4th harmonic = 4x frequency (two octaves)

The falloff parameter controls how quickly harmonics get quieter:

  • falloff: 1.0 = natural (1/n amplitude)
  • falloff: 2.0 = steep (1/n² amplitude)
  • falloff: 0.5 = bright (slower falloff)

On this page