ChucK : Programming Guide

Virtual Machine Options

version: 1.4.x.x (numchucks)

The ChucK Compiler + Virtual Machine

Let's start with the compiler and virtual machine (VM), both of which run in the same chuck process. By now, you should have built/installed ChucK (guide), and perhaps taken the tutorial. This guide is intended to be more complete and referential than the tutorial. Additionally, see the language specification.

SYNOPSIS (a man-esque page)

chuck --[options|commands] [+-=^] file1 file2 file3 ...
   [options] = halt|loop|audio|silent|dump|nodump|about|probe|
   [commands] = add|remove|replace|remove.all|status|time|kill
   [+-=^] = shortcuts for add, remove, replace, status

chuck version: 1.4.x.x (numchucks)

(run 'chuck --about' to print the above information)


[source ChucK files]:
ChucK can run one or more programs in parallel. The programmer only needs to specify a list of programs on the command line, and chuck will compile and run them all concurrently in the VM. Each input source file (.ck suffix) will be run as a separate 'shred' (strongly-timed ChucK process) in the VM. They can 'spork' additional shreds and interact with existing shreds. Due to the ChucK timing mechanism, shreds don't necessarily need to know about each other in order to be precisely 'shreduled' in time - they only need to attend to their own behavior with respect with time. For example:

 %> chuck

Addtionally, shreds can be added/removed/replaced manually at run-time, using on-the-fly programming commands (skip ahead!).


--about / --help
prints ChucK usage message, with the ChucK URL.

prints version information.

--halt / -h
(on by default) - sets the vm to halt and exit if there are no more shreds in the VM.

--loop / -l
sets the ChucK VM to continue executing even if there no shreds currently in the VM. This effectively runs a local "chuck server" allowing shreds to be added/remove/replaced on-the-fly from a second terminal window or from a different machine. Note it is perfectly valid to specify this option without any input files. For example:
 %> chuck --loop

the above will 'time-loop' the VM, waiting for incoming shreds.

--audio / -a
(on by default) - enable real-time audio output

--silent / -s

disables real-time audio output - computations in the VM is not changed, except that the actual timing is no longer clocked by real-time audio. Timing manipulations (such as operations on 'now') still function logically in full. This is useful for rendering audio to file. Also, it can be handy for running a non-audio program.

--log(N) / --verbose(N) / -v(N)
sets the report level to (N). 0 is none, 10 is all, default is 1. Set higher levels to see more detailed information regarding ChucK’s internal operation.

sets the internal sample rate to (N) Hz. by default, ChucK runs at 44100Hz on OS X and Windows, and 48000Hz on linux/ALSA. even if the VM is running in --silent mode, the sample rate is still used by some unit generaters to compute audio, this is important for computing samples and writing to file. Not all sample rates are supported by all devices.

sets the internal audio buffer size to (N) sample frames. larger buffer size often reduce audio artifacts due to system/program timing. smaller buffers reduce audio latency. The default is 512. If (N) is not a power of 2, the next power of 2 larger than (N) is used. For example:

 %> chuck --bufsize950

this sets the buffer size to 1024.

opens audio output device #(N) for real-time audio. by default, (N) is 0.

opens audio input device #(N) for real-time audio input. by default, (N) is 0.

--channels(N) / -c(N)
opens (N) number of input and output channels on the audio device. by default, (N) is 2.

--in(N) / -i(N)
opens (N) number of input channels on the audio device. by default (N) is 2.

--out(N) / -o(N)
opens (N) number of output channels on the audio device. by default (N) is 2.

--remote(hostname) / @(hostname)
sets the hostname to connect to if accompanied by the on-the-fly programming commands.
(host) can be name or ip of the host. default is (localhost).

--port(N) / -p(N)
sets the port to listen on if not used with on-the-fly programming commands.
sets the port to connect to if used with on-the-fly programming commands.

probes the system for all audio devices and MIDI devices, and prints them.

(default: auto) specifies whether ChucK should automatically load ChuGins (auto) or disable ChuGin loading (off).

adds (path) to the list of paths searched for ChuGin to load. Any .ck files in the ChuGin path are also loaded and executed when chuck is run. By default, on Mac OS X the paths consist of /usr/lib/chuck and /Library/Application Support/ChucK/ChuGins. On Windows the only default path is C:\Program Files\ChucK\chugins. On Linux, the only path in the default list is /usr/lib/chuck.

loads a specific ChuGin at the location specified by (path). This can be used to load ChuGins not in the default list of paths (see --chugin-path).

utilizes a callback system for real-time audio (default).

--blocking (no longer available)
utilizes blocking behavior for real-time audio.

--deprecate:{stop|warn|ignore} (default: warn) specifies how to handle deprecated classes, UGens, and functions. "stop" will cause a program to not compile if it uses any deprecated features. "warn" will issue a warning. "ignore" will cause the program to compile normally without complaint. For example, $ chuck --deprecate:stop will cause chuck to stop compilation if uses any deprecated features.

--dump / +d
dumps the virtual instructions emitted to the console (stderr), for all the files after this flag on the command line, until a 'nodump' is encountered (see below). For example:

 %> chuck +d

this command will dump the virtual ChucK instructions for (only), with argument values, to the console. --dump can be used in conjunction with --nodump to selectively dump files.

--nodump / -d
(this is the default) ceases the dumping of virtual instructions for files that comes after this flag on the command line, until a "dump" is encountered (see above). For example:

 %> chuck +d -d +d

will dump, then — but not

These are useful internally for debugging ChucK itself. Or if one is curious about what the ChucK virtual machine.

runs chuck in interactive (shell) mode. Can dymically run code specified within { }, for example:

 chuck %> { <<< "hello there" >>>; } 

For the origins of ChucK shell, see this 2006 paper.

(from here, we go to)
On-the-fly Programming Commands

(or return to the)
Programmer's Guide

chuck | soundlab | cs | music | ccrma