Skip to content

Reference library > Oscillators > SquareOscillator

SquareOscillator

SquareOscillator(frequency=440, width=0.5)

Produces a pulse wave with the given frequency and pulse width, where width of 0.5 is a square wave and other values produce a rectangular wave.

Examples

#-------------------------------------------------------------------------------
# Simple square wave oscillator shaped by an envelope
#-------------------------------------------------------------------------------
square = SquareOscillator(440)
envelope = ASREnvelope(0, 0.1, 0.5)
output = StereoPanner(square * envelope) * 0.5
output.play()

Last update: 2024-02-15
Created: 2023-12-03