# oscillators.lib

This library contains a collection of sound generators. Its official prefix is `os`.

#### References

- https://github.com/grame-cncm/faustlibraries/blob/master/oscillators.lib

## Wave-Table-Based Oscillators

### `(os.)sinwaveform`

Sine waveform ready to use with a `rdtable`.

#### Usage

    sinwaveform(tablesize) : _

Where:

- `tablesize`: the table size

### `(os.)coswaveform`

Cosine waveform ready to use with a `rdtable`.

#### Usage

    coswaveform(tablesize) : _

Where:

- `tablesize`: the table size

### `(os.)phasor`

A simple phasor to be used with a `rdtable`. `phasor` is a standard Faust function.

#### Usage

    phasor(tablesize,freq) : _

Where:

- `tablesize`: the table size
- `freq`: the frequency in Hz

### `(os.)hs_phasor`

Hardsyncing phasor to be used with a `rdtable`.

#### Usage

    hs_phasor(tablesize,freq,reset) :  _

Where:

- `tablesize`: the table size
- `freq`: the frequency in Hz
- `reset`: a reset signal, reset phase to 0 when equal to 1

### `(os.)hsp_phasor`

Hardsyncing phasor with selectable phase to be used with a `rdtable`.

#### Usage

    hsp_phasor(tablesize,freq,reset,phase)

Where:

- `tablesize`: the table size
- `freq`: the frequency in Hz
- `reset`: reset the oscillator to phase when equal to 1
- `phase`: phase between 0 and 1

### `(os.)oscsin`

Sine wave oscillator. `oscsin` is a standard Faust function.

#### Usage

    oscsin(freq) : _

Where:

- `freq`: the frequency in Hz

### `(os.)hs_oscsin`

Sin lookup table with hardsyncing phase.

#### Usage

    hs_oscsin(freq,reset) : _

Where:

- `freq`: the frequency in Hz
- `reset`: reset the oscillator to 0 when equal to 1

### `(os.)osccos`

Cosine wave oscillator.

#### Usage

    osccos(freq) : _

Where:

- `freq`: the frequency in Hz

### `(os.)hs_osccos`

Cos lookup table with hardsyncing phase.

#### Usage

    hs_osccos(freq,reset) : _

Where:

- `freq`: the frequency in Hz
- `reset`: reset the oscillator to 0 when equal to 1

### `(os.)oscp`

A sine wave generator with controllable phase.

#### Usage

    oscp(freq,phase) : _

Where:

- `freq`: the frequency in Hz
- `phase`: the phase in radian

### `(os.)osci`

Interpolated phase sine wave oscillator.

#### Usage

    osci(freq) : _

Where:

- `freq`: the frequency in Hz

### `(os.)osc`

Default sine wave oscillator (same as oscsin). `osc` is a standard Faust function.

#### Usage

    osc(freq) : _

Where:

- `freq`: the frequency in Hz

## LFOs

Low-Frequency Oscillators (LFOs) have prefix `lf_` (no aliasing suppression, which is not audible at LF).

### `(os.)lf_imptrain`

Unit-amplitude low-frequency impulse train. `lf_imptrain` is a standard Faust function.

#### Usage

    lf_imptrain(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)lf_pulsetrainpos`

Unit-amplitude nonnegative LF pulse train, duty cycle between 0 and 1.

#### Usage

    lf_pulsetrainpos(freq, duty) : _

Where:

- `freq`: frequency in Hz
- `duty`: duty cycle between 0 and 1

### `(os.)lf_pulsetrain`

Unit-amplitude zero-mean LF pulse train, duty cycle between 0 and 1.

#### Usage

    lf_pulsetrain(freq,duty) : _

Where:

- `freq`: frequency in Hz
- `duty`: duty cycle between 0 and 1

### `(os.)lf_squarewavepos`

Positive LF square wave in [0,1]

#### Usage

    lf_squarewavepos(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)lf_squarewave`

Zero-mean unit-amplitude LF square wave. `lf_squarewave` is a standard Faust function.

#### Usage

    lf_squarewave(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)lf_trianglepos`

Positive unit-amplitude LF positive triangle wave.

#### Usage

    lf_trianglepos(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)lf_triangle`

Positive unit-amplitude LF triangle wave. `lf_triangle` is a standard Faust function.

#### Usage

    lf_triangle(freq) : _

Where:

- `freq`: frequency in Hz

## Low Frequency Sawtooths

Sawtooth waveform oscillators for virtual analog synthesis et al. The 'simple' versions (`lf_rawsaw`, `lf_sawpos` and `saw1`), are mere samplings of the ideal continuous-time ("analog") waveforms. While simple, the aliasing due to sampling is quite audible. The differentiated polynomial waveform family (`saw2`, `sawN`, and derived functions) do some extra processing to suppress aliasing (not audible for very low fundamental frequencies). According to Lehtonen et al. (JASA 2012), the aliasing of `saw2` should be inaudible at fundamental frequencies below 2 kHz or so, for a 44.1 kHz sampling rate and 60 dB SPL presentation level; fundamentals 415 and below required no aliasing suppression (i.e., `saw1` is ok).

### `(os.)lf_rawsaw`

Simple sawtooth waveform oscillator between 0 and period in samples.

#### Usage

    lf_rawsaw(periodsamps) : _

Where:

- `periodsamps`: number of periods per samples

### `(os.)lf_sawpos`

Simple sawtooth waveform oscillator between 0 and 1.

#### Usage

    lf_sawpos(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)lf_sawpos_phase`

Simple sawtooth waveform oscillator between 0 and 1 with phase control.

#### Usage

    lf_sawpos_phase(freq, phase) : _

Where:

- `freq`: frequency in Hz
- `phase`: phase between 0 and 1

### `(os.)lf_sawpos_reset`

Simple sawtooth waveform oscillator between 0 and 1 with reset.

#### Usage

    lf_sawpos_reset(freq,reset) : _

Where:

- `freq`: frequency in Hz
- `reset`: reset the oscillator to 0 when equal to 1

### `(os.)lf_sawpos_phase_reset`

Simple sawtooth waveform oscillator between 0 and 1 with phase control and reset.

#### Usage

    lf_sawpos_phase_reset(freq,phase,reset) : _

Where:

- `freq`: frequency in Hz
- `phase`: phase between 0 and 1
- `reset`: reset the oscillator to phase when equal to 1

### `(os.)lf_saw`

Simple sawtooth waveform oscillator between -1 and 1. `lf_saw` is a standard Faust function.

#### Usage

    lf_saw(freq) : _

Where:

- `freq`: frequency in Hz

## Bandlimited Sawtooth

### `(os.)sawN`

Bandlimited Sawtooth

`sawN(N,freq)`, `sawNp`, `saw2dpw(freq)`, `saw2(freq)`, `saw3(freq)`, `saw4(freq)`, `saw5(freq)`, `saw6(freq)`, `sawtooth(freq)`, `saw2f2(freq)` `saw2f4(freq)`

#### Method 1 (`saw2`)

Polynomial Transition Regions (PTR) (for aliasing suppression).

##### References

- Kleimola, J.; Valimaki, V., "Reducing Aliasing from Synthetic Audio Signals Using Polynomial Transition Regions," in Signal Processing Letters, IEEE , vol.19, no.2, pp.67-70, Feb. 2012
- https://aaltodoc.aalto.fi/bitstream/handle/123456789/7747/publication6.pdf?sequence=9
- http://research.spa.aalto.fi/publications/papers/spl-ptr/

#### Method 2 (`sawN`)

Differentiated Polynomial Waves (DPW) (for aliasing suppression).

##### Reference

"Alias-Suppressed Oscillators based on Differentiated Polynomial Waveforms", Vesa Valimaki, Juhan Nam, Julius Smith, and Jonathan Abel, IEEE Tr. Acoustics, Speech, and Language Processing (IEEE-ASLP), Vol. 18, no. 5, May 2010.

#### Other Cases

Correction-filtered versions of `saw2`: `saw2f2`, `saw2f4` The correction filter compensates "droop" near half the sampling rate. See reference for sawN.

#### Usage

    sawN(N,freq) : _
    sawNp(N,freq,phase) : _
    saw2dpw(freq) : _
    saw2(freq) : _
    saw3(freq) : _     // based on sawN
    saw4(freq) : _     // based on sawN
    saw5(freq) : _     // based on sawN
    saw6(freq) : _     // based on sawN
    sawtooth(freq) : _ // = saw2
    saw2f2(freq) : _
    saw2f4(freq) : _

Where:

- `N`: polynomial order, known at compile time
- `freq`: frequency in Hz
- `phase`: phase between 0 and 1

### `(os.)sawNp`

TODO: MarkDown doc in comments

### `(os.)saw2dpw`

TODO: MarkDown doc in comments

### `(os.)saw3`

TODO: MarkDown doc in comments

### `(os.)sawtooth`

Alias-free sawtooth wave. 2nd order interpolation (based on `saw2`). `sawtooth` is a standard Faust function.

#### Usage

    sawtooth(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)saw2f2`

TODO: MarkDown doc in comments

### `(os.)saw2f4`

TODO: MarkDown doc in comments

## Bandlimited Pulse, Square, and Impulse Trains

Bandlimited Pulse, Square and Impulse Trains.

`pulsetrainN`, `pulsetrain`, `squareN`, `square`, `imptrainN`, `imptrain`, `triangleN`, `triangle`

All are zero-mean and meant to oscillate in the audio frequency range. Use simpler sample-rounded lf_* versions above for LFOs.

#### Usage

    pulsetrainN(N,freq,duty) : _
    pulsetrain(freq, duty) : _ // = pulsetrainN(2)

    squareN(N,freq) : _
    square : _ // = squareN(2)

    imptrainN(N,freq) : _
    imptrain : _ // = imptrainN(2)

    triangleN(N,freq) : _
    triangle : _ // = triangleN(2)

Where:

- `N`: polynomial order
- `freq`: frequency in Hz

### `(os.)impulse`

One-time impulse generated when the Faust process is started. `impulse` is a standard Faust function.

#### Usage

    impulse : _

### `(os.)pulsetrainN`

Bandlimited pulse train oscillator.

#### Usage

    pulsetrainN(N,freq,duty) : _

Where:

- `N`: order, as a constant numerical expression
- `freq`: frequency in Hz
- `duty`: duty cycle between 0 and 1

### `(os.)pulsetrain`

Bandlimited pulse train oscillator. Based on `pulsetrainN(2)`. `pulsetrain` is a standard Faust function.

#### Usage

    pulsetrain(freq,duty) : _

Where:

- `freq`: frequency in Hz
- `duty`: duty cycle between 0 and 1

### `(os.)squareN`

Bandlimited square wave oscillator.

#### Usage

    squareN(N,freq) : _

Where:

- `N`: order, as a constant numerical expression
- `freq`: frequency in Hz

### `(os.)square`

Bandlimited square wave oscillator. Based on `squareN(2)`. `square` is a standard Faust function.

#### Usage

    square(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)imptrainN`

Bandlimited impulse train generator.

#### Usage

    imptrainN(N,freq) : _

Where:

- `N`: order, as a constant numerical expression
- `freq`: frequency in Hz

### `(os.)imptrain`

Bandlimited impulse train generator. Based on `imptrainN(2)`. `imptrain` is a standard Faust function.

#### Usage

    imptrain(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)triangleN`

Bandlimited triangle wave oscillator.

#### Usage

    triangleN(N,freq) : _

Where:

- `N`: order, as a constant numerical expression
- `freq`: frequency in Hz

### `(os.)triangle`

Bandlimited triangle wave oscillator. Based on `triangleN(2)`. `triangle` is a standard Faust function.

#### Usage

    triangle(freq) : _

Where:

- `freq`: frequency in Hz

## Filter-Based Oscillators

Filter-Based Oscillators.

#### Usage

    osc[b|rq|rs|rc|s](freq), where freq = frequency in Hz.

#### References

- http://lac.linuxaudio.org/2012/download/lac12-slides-jos.pdf
- https://ccrma.stanford.edu/~jos/pdf/lac12-paper-jos.pdf

### `(os.)oscb`

Sinusoidal oscillator based on the biquad.

#### Usage

    oscb(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)oscrq`

Sinusoidal (sine and cosine) oscillator based on 2D vector rotation, = undamped "coupled-form" resonator = lossless 2nd-order normalized ladder filter.

#### Usage

    oscrq(freq) : _,_

Where:

- `freq`: frequency in Hz

#### Reference

- https://ccrma.stanford.edu/~jos/pasp/Normalized_Scattering_Junctions.html

### `(os.)oscrs`

Sinusoidal (sine) oscillator based on 2D vector rotation, = undamped "coupled-form" resonator = lossless 2nd-order normalized ladder filter.

#### Usage

    oscrs(freq) : _

Where:

- `freq`: frequency in Hz

#### Reference

- https://ccrma.stanford.edu/~jos/pasp/Normalized_Scattering_Junctions.html

### `(os.)oscrc`

Sinusoidal (cosine) oscillator based on 2D vector rotation, = undamped "coupled-form" resonator = lossless 2nd-order normalized ladder filter.

#### Usage

    oscrc(freq) : _

Where:

- `freq`: frequency in Hz

#### Reference

- https://ccrma.stanford.edu/~jos/pasp/Normalized_Scattering_Junctions.html

### `(os.)oscs`

Sinusoidal oscillator based on the state variable filter = undamped "modified-coupled-form" resonator = "magic circle" algorithm used in graphics.

#### Usage

    oscs(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)quadosc`

Sinusoidal oscillator based on QuadOsc by Martin Vicanek.

#### Usage

    quadosc(freq) : _

where

- `freq`: frequency in Hz

#### Reference

- https://vicanek.de/articles/QuadOsc.pdf

## Waveguide-Resonator-Based Oscillators

Sinusoidal oscillator based on the waveguide resonator `wgr`.

### `(os.)oscwc`

Sinusoidal oscillator based on the waveguide resonator `wgr`. Unit-amplitude cosine oscillator.

#### Usage

    oscwc(freq) : _

Where:

- `freq`: frequency in Hz

#### Reference

- https://ccrma.stanford.edu/~jos/pasp/Digital_Waveguide_Oscillator.html

### `(os.)oscws`

Sinusoidal oscillator based on the waveguide resonator `wgr`. Unit-amplitude sine oscillator.

#### Usage

    oscws(freq) : _

Where:

- `freq`: frequency in Hz

#### Reference

- https://ccrma.stanford.edu/~jos/pasp/Digital_Waveguide_Oscillator.html

### `(os.)oscq`

Sinusoidal oscillator based on the waveguide resonator `wgr`. Unit-amplitude cosine and sine (quadrature) oscillator.

#### Usage

    oscq(freq) : _,_

Where:

- `freq`: frequency in Hz

#### Reference

- https://ccrma.stanford.edu/~jos/pasp/Digital_Waveguide_Oscillator.html

### `(os.)oscw`

Sinusoidal oscillator based on the waveguide resonator `wgr`. Unit-amplitude cosine oscillator (default).

#### Usage

    oscw(freq) : _

Where:

- `freq`: frequency in Hz

#### Reference

- https://ccrma.stanford.edu/~jos/pasp/Digital_Waveguide_Oscillator.html

## Casio CZ Oscillators

Oscillators that mimic some of the Casio CZ oscillators.

There are two sets: - A set with an index parameter - A set with a res parameter

The "index oscillators" outputs a sine wave at index=0 and gets brighter with a higher index. There are two versions of the "index oscillators": - with P appended to the name: is phase aligned with 'fund:sin' - without P appended to the name: has the phase of the original CZ oscillators

The "res oscillators" have a resonant frequency. "res" is the frequency of resonance as a factor of the fundamental pitch.

### `(os.)CZsaw`

Oscillator that mimics the Casio CZ saw oscillator. `CZsaw` is a standard Faust function.

#### Usage

    CZsaw(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 to 1. 0 = sine-wave, 1 = saw-wave

### `(os.)CZsawP`

Oscillator that mimics the Casio CZ saw oscillator, with it's phase aligned to `fund:sin`. `CZsawP` is a standard Faust function.

#### Usage

    CZsawP(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 to 1. 0 = sine-wave, 1 = saw-wave

### `(os.)CZsquare`

Oscillator that mimics the Casio CZ square oscillator `CZsquare` is a standard Faust function.

#### Usage

    CZsquare(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 to 1. 0 = sine-wave, 1 = square-wave

### `(os.)CZsquareP`

Oscillator that mimics the Casio CZ square oscillator, with it's phase aligned to `fund:sin`. `CZsquareP` is a standard Faust function.

#### Usage

    CZsquareP(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 to 1. 0 = sine-wave, 1 = square-wave

### `(os.)CZpulse`

Oscillator that mimics the Casio CZ pulse oscillator. `CZpulse` is a standard Faust function.

#### Usage

    CZpulse(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 gives a sine-wave, 1 is closer to a pulse

### `(os.)CZpulseP`

Oscillator that mimics the Casio CZ pulse oscillator, with it's phase aligned to `fund:sin`. `CZpulseP` is a standard Faust function.

#### Usage

    CZpulseP(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 gives a sine-wave, 1 is closer to a pulse

### `(os.)CZsinePulse`

Oscillator that mimics the Casio CZ sine/pulse oscillator. `CZsinePulse` is a standard Faust function.

#### Usage

    CZsinePulse(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 gives a sine-wave, 1 is a sine minus a pulse

### `(os.)CZsinePulseP`

Oscillator that mimics the Casio CZ sine/pulse oscillator, with it's phase aligned to `fund:sin`. `CZsinePulseP` is a standard Faust function.

#### Usage

    CZsinePulseP(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 gives a sine-wave, 1 is a sine minus a pulse

### `(os.)CZhalfSine`

Oscillator that mimics the Casio CZ half sine oscillator. `CZhalfSine` is a standard Faust function.

#### Usage

    CZhalfSine(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 gives a sine-wave, 1 is somewhere between a saw and a square

### `(os.)CZhalfSineP`

Oscillator that mimics the Casio CZ half sine oscillator, with it's phase aligned to `fund:sin`. `CZhalfSineP` is a standard Faust function.

#### Usage

    CZhalfSineP(fund,index) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `index`: the brightness of the oscillator, 0 gives a sine-wave, 1 is somewhere between a saw and a square

### `(os.)CZresSaw`

Oscillator that mimics the Casio CZ resonant sawtooth oscillator. `CZresSaw` is a standard Faust function.

#### Usage

    CZresSaw(fund,res) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `res`: the frequency of resonance as a factor of the fundamental pitch.

### `(os.)CZresTriangle`

Oscillator that mimics the Casio CZ resonant triangle oscillator. `CZresTriangle` is a standard Faust function.

#### Usage

    CZresTriangle(fund,res) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `res`: the frequency of resonance as a factor of the fundamental pitch.

### `(os.)CZresTrap`

Oscillator that mimics the Casio CZ resonant trapeze oscillator `CZresTrap` is a standard Faust function.

#### Usage

    CZresTrap(fund,res) : _

Where:

- `fund`: a saw-tooth waveform between 0 and 1 that the oscillator slaves to
- `res`: the frequency of resonance as a factor of the fundamental pitch.

## PolyBLEP-Based Oscillators

### `(os.)polyblep`

PolyBLEP residual function, used for smoothing steps in the audio signal.

#### Usage

    polyblep(Q,phase) : _

Where:

- `Q`: smoothing factor between 0 and 0.5. Determines how far from the ends of the phase interval the quadratic function is used.
- `phase`: normalised phase (between 0 and 1)

### `(os.)polyblep_saw`

Sawtooth oscillator with suppressed aliasing (using polyBLEP).

#### Usage

    polyblep_saw(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)polyblep_square`

Square wave oscillator with suppressed aliasing (using polyBLEP).

#### Usage

    polyblep_square(freq) : _

Where:

- `freq`: frequency in Hz

### `(os.)polyblep_triangle`

Triangle wave oscillator with suppressed aliasing (using polyBLEP).

#### Usage

    polyblep_triangle(freq) : _

Where:

- `freq`: frequency in Hz

#### Search

From here you can search these documents. Enter your search terms below.

#### Keyboard Shortcuts

Keys | Action
--- | ---
`?` | Open this help
`n` | Next page
`p` | Previous page
`s` | Search