// Sine wave oscillator
// usage: (osc freq phase)
(define osc (
        sin (* twopi (~ $1 $2))
    )
)

// Triangular wave oscillator
// usage: (tri freq phase)
(define tri (
        (let #ph (~ $1 $2))
        (- (* (min #ph (- 1 #ph)) 4) 1)
    )
)

// Square wave oscillator
// usage: (square freq phase)
(define square (
        (- (* (< (~ $1 $2) 0.5) 2) 1)
    )
)

// Pulse-Width-Modulation oscillator
// usage: (pwm freq duty)
(define pwm (
        (- (* (< (~ $1) $2) 2) 1)
    )
)

// White noise generator
// usage: (noise gain)
(define noise (
        (randf (neg $1) $1)
    )
)
