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
| Parameter | Type | Default | Description |
|---|---|---|---|
count | int | - | Number of harmonics to add |
falloff | float | 1.0 | Amplitude falloff (1/n^falloff) |
odd | bool | false | Only odd harmonics (hollow sound) |
Or specify exact harmonics:
[C4 E4] |> sine |> harmonics(2, 3, 5) // Only 2nd, 3rd, 5thExamples
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)