Saw wave oscillator
Nucli

Saw wave oscillator

A basic sawtooth oscillator that generates a rising waveform from -1 to +1 before resetting at the end of each cycle. Includes adjustable frequency and output level, with identical output to both stereo channels.
LanguageNucli
Added16 Oct 2026
Views26

Free to use for anything. No credit needed.

No ratings yet

Log in to rate this code.

Code 20 lines


param freq = 220 (20 .. 2000)
param level = 0.3 (0 .. 1)

history phase = 0

let increment = freq / samplerate
let nextPhase = phase + increment

if (nextPhase >= 1) {
  nextPhase = nextPhase - 1
}

let saw = (nextPhase * 2) - 1
let output = saw * level

out1 = output
out2 = output

phase = nextPhase

Comments

No comments yet.

← Back to code