Pulse Wave Oscillator
Overview
The pulse wave oscillator programmatically generates a pulse waveform with specified pulse width. The basic_pulse_osc
is not bandwidth limited, while pulse_osc
is, using a technique called "PolyBLEP" to reduce aliasing artifacts that can occur when generating the waveform with a sharp discontinuity as the signal transitions from -1.0 to 1.0.
PolyBLEP works by precalculating a correction function that subtracts the waveform’s high-frequency components at discontinuities. This correction function is then applied to the generated waveform, effectively removing frequencies above the waveform’s Nyquist frequency to avoid aliasing artifacts.
Declaration
struct basic_pulse_osc
{
constexpr basic_pulse_osc(float width = 0.5);
constexpr void width(float width);
constexpr float operator()(phase p);
constexpr float operator()(phase_iterator i);
};
struct pulse_osc : basic_pulse_osc
{
constexpr pulse_osc(float width = 0.5);
constexpr float operator()(phase p, phase dt) const;
constexpr float operator()(phase_iterator i) const;
};
Expressions
basic_pulse_osc
is a model of BasicOscillator
and implements all valid expressions of BasicOscillator
. pulse_osc
is a model of BandwidthLimitedOscillator
and implements all valid expressions of BandwidthLimitedOscillator
.
In addition to valid expressions for BasicOscillator and BandwidthLimitedOscillator
, basic_pulse_osc
and pulse_osc
allow these expressions.
Notation
w
-
A floating point value from 0.0 to 1.0 representing pulse width.
ps
-
Object of type
basic_pulse_osc
orpulse_osc