Basic unit generator (UGen) base classes, simple signal generators, envelopes, and more.
Base class for all unit generator (UGen) types.
UGen()
Default constructor for UGen.
int buffered(int val)
Set the unit generator's buffered operation mode, typically used externally from hosts that embed ChucK as a component. If true, the UGen stores a buffer of its most recent samples, which can be fetched using global variables in the host language.
int buffered()
Get the ugen's buffered operation mode.
UGen chan(int num)
Get channel (as a UGen) at specified index.
int channels(int num)
Set number of channels. (currently NOT supported)
int channels()
Get number of channels.
float gain(float val)
Set the gain of the unit generator.
float gain()
Get the gain of the unit generator.
int isConnectedTo(UGen rhs)
Return true if this UGen's output is connected to the input of rhs; if either this UGen or rhs has more than one channel, this function returns true if any connections exist between the channels; return false if there are no connections.
float last()
Get the last sample value of the unit generator.
int op(int val)
Set the unit generator'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()
Get the unit generator's operation mode.
[ top ]
A gain control unit generator. (All unit generators can already change their own gain; this is an explicit way to add multiple outputs together and scale them.)
Gain()
Default constructor for Gain.
Gain(float gain)
Construct a Gain with default value.
[ top ]
An impulse generator. Can be used to set the value of the next sample; default for each sample is 0 if not set. Additionally, this can be used to generate a digital signal, one sample at a time.
Impulse()
Default constructor for Impulse.
float next(float next)
Set the value of next sample. (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()
Get value of next sample to be generated.
[ top ]
A step generator. Step behaves like Impulse, except that once a next value is set, that value is held for all following samples, until a different value is set.
Step()
Default constructor for Step.
Step(float value)
Construct a Step with default value.
float next(float next)
Set the next step value.
float next()
Get the next step value.
[ top ]
An interpolating sound buffer/player with single-channel output; can read audio data from a variety of uncompressed formats.
SndBuf()
Default constructor for SndBuf.
SndBuf(string path)
Construct a SndBuf with the 'path' to a sound file to read.
SndBuf(string path, float rate)
Construct a SndBuf with the 'path' to a sound file to read, and a default playback 'rate' (1.0 is normal rate)
SndBuf(string path, float rate, int pos)
Construct a SndBuf with the 'path' to a sound file to read, a default playback 'rate' (1.0 is normal rate), and starting at sample position 'pos'
int channel(int channel)
For sound file containing more than one channel of audio, select the channel to play.
int channel()
Get the selected chanel of audio this buffer is playing.
int channels()
Get number of channels available in the sound file.
int chunks(int frames)
Set chunk size, in frames, for loading the file from disk. Set to 0 to disable chunking.
int chunks()
Get chunk size, in frames, for loading the file from disk. 0 indicates that chunking is disabled.
int frames()
Get total number of sample frames in the file; same as .samples().
float freq(float freq)
Set loop rate (in file loops per second).
float freq()
Get loop rate (in file loops per second).
int interp(int interp)
Set interpolation mode: (0) drop sample; (1) linear interpolation; (2) sinc interpolation.
int interp()
Get interpolation mode: (0) drop sample; (1) linear interpolation; (2) sinc interpolation.
dur length()
Get total length of the file as a duration.
int loop(int loop)
Toggle looping file playback.
int loop()
Get whether file playback is set to loop.
float phase(float phase)
Set phase position, normalized to [0,1).
float phase()
Get 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 play position (between 0 and number of samples).
int pos()
Get play position (between 0 and number of samples).
float rate(float rate)
Set playback rate (relative to file's natural speed). For example, 1.0 is 'normal', 0.5 is half speed, and 2 is twice as fast.
float rate()
Get playback rate (relative to file's natural speed). For example, 1.0 is 'normal', 0.5 is half speed, and 2 is twice as fast.
string read(string read)
Read file for reading.
int ready()
Query whether the SndBuf is ready for use (e.g., sound file successfully loaded).
int samples()
Get total number of sample frames in the file; same as .frames().
float valueAt(int pos)
Get sample value at given position (in samples).
string write(string read)
Set file for writing (currently unsupported).
[ top ]
An interpolating sound buffer with two-channel output. Reads from a variety of uncompressed formats.
SndBuf2()
Default constructor for SndBuf2.
[ top ]
This Envelope subclass implements a traditional ADSR (Attack, Decay, Sustain, Release) envelope. It responds to simple `keyOn` and `keyOff` messages, keeping track of its state. by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
ADSR()
Default constructor for ADSR.
ADSR(dur attack, dur decay, float sustain, dur release)
Construct an ADSR with attack, decay, sustain, and release values. Attack, decay, and release values are durations; sustain is a float value typically between 0 and 1.
ADSR(float attack, float decay, float sustain, float release)
Construct an ADSR with attack, decay, sustain, and release values. Attack, decay, and release values are in seconds; sustain is a float value typically between 0 and 1.
float attackRate(float value)
Set attack rate.
float attackRate()
Get attack rate.
dur attackTime(dur value)
Set attack time.
dur attackTime()
Get attack time.
float decayRate(float value)
Set decay rate.
float decayRate()
Get decay rate.
dur decayTime(dur value)
Set decay time.
dur decayTime()
Get decay time.
float releaseRate(float value)
Set release rate.
float releaseRate()
Get release rate.
dur releaseTime(dur value)
Set release time.
dur releaseTime()
Get release time.
void set(float attackTime, float decayTime, float sustainLevel, float releaseTime)
Set attack, decay, sustain, and release all at once (in seconds).
void set(dur attackDuration, dur decayDuration, float sustainLevel, dur releaseDuration)
Set attack, decay, sustain, and release all at once.
int state()
Get state; attack=0, decay=1, sustain=2, release=3, done=4.
float sustainLevel(float value)
Set sustain level.
float sustainLevel()
Get sustain level.
int ATTACK
See state() function. Denotes that the envelope is in the attack stage.
int DECAY
See state() function. Denotes that the envelope is in the decay stage.
int DONE
See state() function. Denotes that the envelope has completed all stages.
int RELEASE
See state() function. Denotes that the envelope is in the release stage.
int SUSTAIN
See state() function. Denotes that the envelope is in the sustain stage.
[ top ]
This class implements a simple envelope generator which is capable of ramping to a target value by a specified rate. It also responds to simple `keyOn` and `keyOff` messages, ramping to 1.0 on `keyOn` and to 0.0 on `keyOff`. by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
Envelope()
Default constructor for Envelope.
Envelope(dur durationToTarget)
Construct an Envelope with duration to reach target (assumed to be 1.0); FYI this does not start the Envelope until .keyOn() is called.
Envelope(float secondsToTarget)
Construct an Envelope with duration (in seconds) to reach target (assumed to be 1.0); FYI this does not start the Envelope until .keyOn() is called.
Envelope(dur durationToTarget, float target)
Construct an Envelope with duration to reach target; FYI this does not start the Envelope until .keyOn() is called.
Envelope(float secondsToTarget, float target)
Construct an Envelope with duration (in seconds) to reach target; FYI this does not start the Envelope until .keyOn() is called.
dur duration(dur value)
Set duration to reach target.
dur duration()
Get duration to reach target.
int keyOff()
Get keyOff state.
int keyOff(int value)
Ramp to 0.0.
int keyOn()
Get keyOn state.
int keyOn(int value)
Ramp to 1.0.
dur ramp(dur durationToTarget, float target)
Over the given duration, ramp toward the specified target; returns the given duration.
dur ramp(float secondsToTarget, float target)
Over the given duration (in seconds), ramp toward the specified target; returns the given duration.
float rate(float value)
Set rate of change.
float rate()
Get rate of change.
float target(float value)
Set value to ramp to.
float target()
Get value to ramp to.
float time(float value)
Set time to reach target (in seconds).
float time()
Get time to reach target (in seconds).
float value(float value)
Set immediate value.
float value()
Get immediate value.
[ top ]
A non-interpolating digital delay-line. A fixed maximum length of 4095 and a delay of zero is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor. A non-interpolating delay line is typically used in fixed delay-length applications, such as for reverberation. by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
Delay()
Default constructor for Delay.
Delay(dur delay)
Construct a Delay with delay length and, implicitly, delay max.
Delay(dur delay, dur max)
Construct a Delay with delay length and delay max.
void clear()
Clear delay line.
dur delay(dur value)
Set length of delay.
dur delay()
Get length of delay.
dur max(dur value)
Set max delay (buffer size).
dur max()
Get max delay (buffer size).
void set(dur delay, dur max)
Set delay length and delay max; delay should be <= max.
[ top ]
A fractional-length digital delay-line using first-order linear interpolation. A fixed maximum length of 4095 and a delay of zero is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor. Linear interpolation is an efficient technique for achieving fractional delay lengths, though it does introduce high-frequency signal attenuation to varying degrees depending on the fractional delay setting. The use of higher order Lagrange interpolators can typically improve (minimize) this attenuation characteristic. by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
DelayL()
Default constructor for DelayL.
DelayL(dur delay)
Construct a DelayL with delay length and, implicitly, delay max.
DelayL(dur delay, dur max)
Construct a DelayL with delay length and delay max.
void clear()
Clear delay line.
dur delay(dur value)
Set length of delay.
dur delay()
Get length of delay.
dur max(dur value)
Set max delay (buffer size).
dur max()
Get max delay (buffer size).
void set(dur delay, dur max)
Set delay length and delay max; delay should be <= max.
[ top ]
A fractional-length digital delay-line using a first-order allpass filter. A fixed maximum length of 4095 and a delay of 0.5 is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor. An allpass filter has unity magnitude gain but variable phase delay properties, making it useful in achieving fractional delays without affecting a signal's frequency magnitude response. In order to achieve a maximally flat phase delay response, the minimum delay possible in this implementation is limited to a value of 0.5. by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
DelayA()
Default constructor for DelayA.
DelayA(dur delay)
Construct a DelayA with delay length and, implicitly, delay max.
DelayA(dur delay, dur max)
Construct a DelayA with delay length and delay max.
void clear()
Clear delay line.
dur delay(dur value)
Set length of delay.
dur delay()
Get length of delay.
dur max(dur value)
Set max delay (buffer size).
dur max()
Get max delay (buffer size).
void set(dur delay, dur max)
Set delay length and delay max; delay should be <= max.
[ top ]
An echo effect. by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
Echo()
Default constructor for Echo.
Echo(dur delay)
Construct an Echo with delay length and, implicitly, delay max.
Echo(dur delay, dur max)
Construct an Echo with delay length and delay max.
dur delay(dur value)
Set length of echo.
dur delay()
Get length of echo.
dur max(dur value)
Set max delay (buffer size).
dur max()
Get max delay (buffer size).
float mix(float value)
Set mix level (wet/dry).
float mix()
Get mix level (wet/dry).
void set(dur delay, dur max)
Set delay length and delay max; delay should be <= max.
[ top ]
A noise generator with multiple noise synthesis modes.
CNoise()
Default constructor for CNoise.
CNoise(string mode)
Construct a CNoise with synthesis mode. Supported modes are "white", "pink", "flip", and "xor".
float fprob(float fprob)
Probability [0-1] used for calculating XOR noise.
string mode(string mode)
Noise synthesis mode. Supported modes are "white", "pink", "flip", and "xor".
[ top ]
Base class for simple oscillator unit generators.
Osc()
Default constructor for Osc.
Osc(float freq)
Construct Osc at specified frequency.
Osc(float freq, float phase)
Construct Osc at specified frequency and phase.
float freq(float hz)
Set frequency of oscillator in Hertz; maintains phase.
float freq()
Get frequency of oscillator in Hertz.
dur period(dur value)
Set period of oscillator (inverse of frequency).
dur period()
Get period of oscillator (inverse of frequency).
float phase(float phase)
Set oscillator phase, in range [0,1).
float phase()
Get oscillator phase, in range [0,1).
float sfreq(float hz)
Set frequency of oscillator in Hertz; resets phase to 0.
int sync(int type)
Choose how to interpret input: (0) sync frequency to input; (1) sync phase to input; (2) frequency modulation (add input to internal frequency).
int sync()
Get current interpretation of input: (0) sync frequency to input; (1) sync phase to input; (2) frequency modulation (add input to internal frequency).
[ top ]
A sine wave oscillator.
SinOsc()
Default constructor for SinOsc.
SinOsc(float freq)
Construct SinOsc at specified frequency.
SinOsc(float freq, float phase)
Construct SinOsc at specified frequency and phase.
[ top ]
A triangle wave oscillator.
TriOsc()
Default constructor for TriOsc.
TriOsc(float freq)
Construct TriOsc at specified frequency.
TriOsc(float freq, float phase)
Construct TriOsc at specified frequency and phase.
float width(float width)
Set width of triangle wave (ratio of rise time to fall time).
float width()
Get width of triangle wave (ratio of rise time to fall time).
[ top ]
Sawtooth wave oscillator.
SawOsc()
Default constructor for SawOsc.
SawOsc(float freq)
Construct SawOsc at specified frequency.
SawOsc(float freq, float phase)
Construct SawOsc at specified frequency and phase.
float width(float width)
Whether sawtooth wave is to fall (0) or rise (1).
float width()
Whether sawtooth wave is to fall (0) or rise (1).
[ top ]
A pulse width oscillator.
PulseOsc()
Default constructor for PulseOsc.
PulseOsc(float freq)
Construct PulseOsc at specified frequency.
PulseOsc(float freq, float phase)
Construct PulseOsc at specified frequency and phase.
float width(float width)
Set width of duty cycle [0,1).
float width()
Get width of duty cycle [0,1)/.
[ top ]
A square wave oscillator (same as PulseOsc with 0.5 duty cycle).
SqrOsc()
Default constructor for SqrOsc.
SqrOsc(float freq)
Construct SqrOsc at specified frequency.
SqrOsc(float freq, float phase)
Construct SqrOsc at specified frequency and phase.
float width()
Set width of duty cycle (always 0.5).
[ top ]
A phasor oscillator; linearly rises from 0 to 1; can be used as a phase control.
Phasor()
Default constructor for Phasor.
Phasor(float freq)
Construct Phasor at specified frequency.
Phasor(float freq, float phase)
Construct Phasor at specified frequency and phase.
[ top ]
Base class for subgraph-based user-created in-language unit generators.
Chugraph()
Default constructor for Chugraph.
UGen inlet
Terminal for sources chucked into this ugen.
UGen outlet
Terminal for the output of this ugen.
[ top ]
Base class for user-created in-language unit generators.
Chugen()
Default constructor for Chugen.
[ top ]
Base class for multi-channel unit generators.
UGen_Multi()
Default constructor for UGen_Multi.
UGen chan(int which)
Get UGen representing a specific channel of this UGen, or null if no such channel is available.
[ top ]
Base class for stereo unit generators.
UGen_Stereo()
Default constructor for UGen_Stereo.
float pan(float val)
Pan between left and right channels, in range [-1,1], with -1 being far-left, 1 far-right, and 0 centered.
float pan()
Pan between left and right channels, in range [-1,1], with -1 being far-left, 1 far-right, and 0 centered.
int panType(int val)
Set the panning type: (1) constant power panning, (0) unity gain anti-panning.
int panType()
Get the panning type: (1) constant power panning, (0) unity gain anti-panning.
UGen left
Left channel (same as .chan(0)).
UGen right
Right channel (same as .chan(1)).
[ top ]
A stereo-to-mono unit generator for mixing stereo signal to mono.
Mix2()
Default constructor for Mix2.
[ top ]
A mono-to-stereo unit generator for stereo panning.
Pan2()
Default constructor for Pan2.
[ top ]