^ programmer's guide | std classes | std uana

ChucK basic unit generators

UGen | UGen_Stereo | UGen_Multi | Mix2 | Pan2
dac | adc | blackhole
Gain | Impulse | Step | Noise
Osc | Phasor | SinOsc | TriOsc | SawOsc | SqrOsc | PulseOsc
SndBuf | SndBuf2
HalfRect | FullRect
Chugraph | Chugen


foundation

UGen

UGen is the base class for all unit generator types in ChucK. There is no value in instantiating a member of this class.

UGen.functions Description
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.

UGen_Multi

UGen_Multi is a subclass of UGen and the base class for multi-channel unit generators.

UGen_Multi.functions Description
see UGen
UGen chan(int which), chan(int which, UGen) Get/set the ugen representing a specific channel of this ugen, or null if no such channel is available.

UGen_Stereo

UGen_Stereo is subclass of UGen_Multi and the baseclass for stereo unit generators.

UGen_Stereo.functions Description
see UGen_Multi
UGen left() Get/set left channel (same as chan(0)).
UGen right() Get/set right channel (same as chan(1)).
float pan(), pan(float val) Get/set panning between left and right channels, in range [-1,1], with -1 being far-left, 1 far-right, and 0 centered.

Pan2

Pan2 is a subclass of UGen_Stereo and is used to spread a mono signal to stereo.

Pan2.functions
see UGen_Stereo
see moe2.ck

Mix2

Mix2 is a subclass of UGen_Stereo and is used to mix stereo input down to mono channel.

Mix2.functions
see UGen_Stereo

dac

dac is a subclass of UGen and represents the digital-to-analog converter - abstraction for underlying audio output device.

dac.functions Description
see UGen
UGen left() input to left channel
UGen right() input to right channel
UGen chan(int n) returns nth channel (from UGen)

adc

adc analog-to-digital converter - abstraction for underlying audio input device

adc.functions Description
see of UGen
UGen left() output of left channel
UGen right() output to right channel
UGen chan(int n) returns nth channel (from UGen)

blackhole

blackhole sample rate sample sucker (like dac, ticks ugens, but no more).

blackhole.functions
see of UGen
see fm.ck

Gain

Gain gain control to add N outputs together and scale them. NOTE - all unit generators can themselves change their own gain.

Gain.functions Description
see UGen
float gain(float val) Set the gain of the ugen.
float gain() Return the gain of the ugen.
see i-robot.ck
Noise n => Gain g => dac;
SinOsc s => g;
.3 => g.gain;
while( true ) { 100::ms => now; }

wave forms

Impulse

Impulse pulse generator - can set the value of the current sample. The default for each sample is 0 if not set.

Impulse.functions Description
see Ugen
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.
Impulse i => dac;
while( true ) {
    1.0 => i.next;
    100::ms => now;
}

Step

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

Step.functions Description
subclass of Ugen
float next(float s), float next() Set/read the step value.
see : step.ck
 -1.0 => float amp;
 // square wave using Step
 while( true ) {
     -amp => amp => s.next;
     800::samp => now;
 }

Noise

Noise white noise generator

Noise.functions
see Ugen
see wind.ck, powerup.ck

oscillators


Osc

Osc base class for simple oscillator ugens.

Osc.functions Description
float freq(), freq(float hz) Get/set frequency of oscillator in Hertz (cycles per second).
dur period(), period(dur value) Get/set period of oscillator (inverse of frequency).
float phase(), phase(float phase) Get/set oscillator phase, in range [0,1).
float sfreq(float hz) (same as freq).
int sync(), sync(int type) Get/set mode for input (if any). 0: sync frequency to input, 1: sync phase to input, 2: frequency modulation (add input to set frequency)

Phasor

Phasor simple ramp generator (0 to 1). Can be used for phase control.

Phasor.functions Description
see Osc

SinOsc

SinOsc sine oscillator.

SinOsc.functions
see Osc
see: whirl.ck

TriOsc

TriOsc a triangle wave oscillator.

TriOsc.functions Description
see Osc
float width(), width(float) Get/set width of the triangle wave (ratio of rise time to fall time).

SawOsc

SawOsc a sawtooth wave oscillator.

SawOsc.functions Description
see Osc
float width(), width(float) Get/set whether falling sawtooth wave (0) or rising sawtooth wave (1).

SqrOsc

SqrOsc a square wave oscillator (pulse with fixed width of .5).

SqrOsc.functions Description
see Osc
float width() returns .5

PulseOsc

PulseOsc a pulse wave oscillator with variable width.

PulseOsc.functions Description
subclass of Osc
float width(), width(float w) Get/set length of duty cycle (0-1)

sound files

SndBuf

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

SndBuf.functions Description
see Ugen
int channel(), channel(int channel) Get/set channel if the sound file contains more than one channel of audio, select which channel to play.
int channels() Number of channels available in the sound file.
int chunks(), chunks(int frames) Get/set chunk size, in frames, for loading the file from disk. Set to 0 to disable chunking.
float freq(), freq(float freq) Get/set loop rate (in file loops per second).
int interp(int interp) Get/set interpolation mode. 0: drop sample, 1: linear interpolation, 2: sinc interpolation
dur length() Get total length of the file.
int loop(), loop(int loop) Get/set toggle for looping file playback.
float phase(), phase(float phase) Get/set 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(), play(float play) Same as rate().
int pos(), pos(int pos) Get/set position (between 0 and number of samples).
float rate(), rate(float rate) Get/set 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.
int frames() 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).
see: sndbuf.ck

SndBuf2

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

SndBuf2.functions
subclass of SndBuf

basic signal processing

HalfRect

HalfRect half wave rectifier. For input values < 0, output is 0. Otherwise input.

HalfRect.functions
see UGen

FullRect

FullRect full wave rectifier. For input values < 0, output is -input. Otherwise input.

FullRect.functions
see UGen

ZeroX

ZeroX zero crossing detector. Emits a single pulse at the the zero crossing in the direction of the zero crossing. NB: there is also a ZeroX UAna.

ZeroX.functions
see UGen
see zerox.ck

extending

Chugraph

Chugraph Base class for chugraph-based user unit generators.

Chugraph.functions Description
see UGen
UGen inlet(), inlet(UGen) Terminal for sources chucked into this ugen.
UGen outlet(), outlet(UGen) Terminal for the output of this ugen.
see chugraph.ck

Chugen

Chugen Base class for chugen-based user unit generators.

Chugen.functions
see UGen
see chugen.ck
home .. language .. program .. examples