ChucK Class Library Reference

Basic Unit Generators

UGen

Gain

Step

Osc

Phasor

SinOsc

TriOsc

SawOsc

PulseOsc

SqrOsc

SndBuf

SndBuf2

Noise

Impulse

HalfRect

FullRect

UGen_Multi

UGen_Stereo

Mix2

Pan2

Chubgraph

Chugen

UGen

: Object

Base class for all UGen types in ChucK.

member functions

UGen chan(int num)

Return channel at specified index.

int channels(int num)

Set number of channels. (Not currently supported.)

int channels()

Return number of channels.

float gain(float val)

Set the gain of the ugen.

float gain()

Return the gain of the ugen.

int isConnectedTo(UGen right)

Return true if this ugen's output is connected to the input of the argument. Return false otherwise.

float last()

Return the last sample value of the unit generator.

int op(int val)

Set the ugen's operation mode. Accepted values are: 1 (sum inputs), 2 (take difference between first input and subsequent inputs), 3 (multiply inputs), 4 (divide first input by subsequent inputs), 0 (do not synthesize audio, output 0) or -1 (passthrough inputs to output).

int op()

Return the ugen's operation mode.


Gain

: UGen : Object

Gain control. (Note: all unit generators can themselves change their gain. This is a way to add multiple outputs together and scale them.)

examples


Step

: UGen : Object

Step generator - like Impulse, but once a value is set, it is held for all following samples, until value is set again.

examples

member functions

float next(float next)

The step value.

float next()

The step value.


Osc

: UGen : Object

Base class for simple oscillator unit generators.

member functions

float freq(float hz)

Frequency of oscillator in Hertz (cycles per second).

float freq()

Frequency of oscillator in Hertz (cycles per second).

dur period(dur value)

Period of oscillator (inverse of frequency).

dur period()

Period of oscillator (inverse of frequency).

float phase(float phase)

Oscillator phase, in range [0,1).

float phase()

Oscillator phase, in range [0,1).

float sfreq(float hz)

No description available

int sync(int type)

Mode for input (if any). 0: sync frequency to input, 1: sync phase to input, 2: frequency modulation (add input to set frequency)

int sync()

Mode for input (if any). 0: sync frequency to input, 1: sync phase to input, 2: frequency modulation (add input to set frequency)


Phasor

: Osc : UGen : Object

Phasor oscillator. Linearly rises from 0 to 1. Can be used as a phase control.


SinOsc

: Osc : UGen : Object

Sine wave oscillator.

examples


TriOsc

: Osc : UGen : Object

Triangle wave oscillator.

member functions

float width(float width)

Width of triangle wave (ratio of rise time to fall time).

float width()

Width of triangle wave (ratio of rise time to fall time).


SawOsc

: TriOsc : Osc : UGen : Object

Sawtooth wave oscillator.

member functions

float width(float width)

Whether falling sawtooth wave (0) or rising sawtooth wave (1).

float width()

Whether falling sawtooth wave (0) or rising sawtooth wave (1).


PulseOsc

: Osc : UGen : Object

Pulse width oscillator.

member functions

float width(float width)

Length of duty cycle [0,1).

float width()

Length of duty cycle [0,1).


SqrOsc

: PulseOsc : Osc : UGen : Object

Square wave oscillator (pulse with 0.5 duty cycle).

member functions

float width()

Length of duty cycle (always 0.5)


SndBuf

: UGen : Object

Interpolating sound buffer with single-channel output. Reads from a variety of uncompressed formats.

examples

member functions

int channel(int channel)

If the sound file contains more than one channel of audio, select which channel to play.

int channel()

If the sound file contains more than one channel of audio, the selected channel to play.

int channels()

Number of channels available in the sound file.

int chunks(int frames)

Chunk size, in frames, for loading the file from disk. Set to 0 to disable chunking.

int chunks()

Chunk size, in frames, for loading the file from disk. 0 indicates that chunking is disabled.

float freq(float freq)

Loop rate (in file loops per second).

float freq()

Loop rate (in file loops per second).

int interp(int interp)

Interpolation mode. 0: drop sample, 1: linear interpolation, 2: sinc interpolation

int interp()

Interpolation mode. 0: drop sample, 1: linear interpolation, 2: sinc interpolation

dur length()

Total length of the file.

int loop(int loop)

Toggle for looping file playback.

int loop()

Toggle for looping file playback.

float phase(float phase)

Phase position, normalized to [0,1).

float phase()

Phase position, normalized to [0,1).

float phaseOffset(float value)

Advance the playhead by the specified phase offset in [0,1), where 0 is no advance and 1 advance the entire length of the file.

float play(float play)

Same as .rate.

float play()

Same as .rate.

int pos(int pos)

Set position (between 0 and number of samples).

int pos()

Current position (between 0 and number of samples).

float rate(float rate)

Playback rate (relative to file's natural speed). For example, 0.5 is half speed and 2 is twice as fast.

float rate()

Playback rate (relative to file's natural speed). For example, 0.5 is half speed and 2 is twice as fast.

string read(string read)

Load file for reading.

int samples()

Total number of sample frames in the file.

float valueAt(int pos)

Sample value at given position (in samples).

string write(string read)

Set file for writing (currently unsupported).


SndBuf2

: SndBuf : UGen : Object

Interpolating sound buffer with two-channel output. Reads from a variety of uncompressed formats.


Noise

: UGen : Object

White noise generator.

examples


Impulse

: UGen : Object

Pulse generator - can set the value of the current sample. Default for each sample is 0 if not set.

member functions

float next(float next)

Value of next sample to be generated. (Note: if you are using the UGen.last method to read the output of the impulse, the value set by Impulse.next does not appear as the output until after the next sample boundary. In this case, there is a consistent 1::samp offset between setting .next and reading that value using .last.)

float next()

Value of next sample to be generated.


HalfRect

: UGen : Object

Half wave rectifier.


FullRect

: UGen : Object

Full wave rectifier.


UGen_Multi

: UGen : Object

Base class for multi-channel unit generators.

member functions

UGen chan(int which)

Returns the ugen representing a specific channel of this ugen, or null if no such channel is available.


UGen_Stereo

: UGen_Multi : UGen : Object

Base class for stereo unit generators.

member variables

UGen left

Left channel (same as .chan(0)).

UGen right

Right channel (same as .chan(1)).

member functions

float pan(float val)

Panning between left and right channels, in range [-1,1], with -1 being far-left, 1 far-right, and 0 centered.

float pan()

Panning between left and right channels, in range [-1,1], with -1 being far-left, 1 far-right, and 0 centered.


Mix2

: UGen_Stereo : UGen_Multi : UGen : Object

Unit generator for mixing stereo signal source to mono.


Pan2

: UGen_Stereo : UGen_Multi : UGen : Object

Spread mono signal to stereo.

examples


Chubgraph

: UGen : Object

Base class for chubgraph-based user unit generators.

examples

member variables

UGen inlet

Terminal for sources chucked into this ugen.

UGen outlet

Terminal for the output of this ugen.


Chugen

: UGen : Object

Base class for chugen-based user unit generators.

examples