The ChucK Compiler and Virtual Machine
Let’s start with the compiler/virtual machine, both of which runs in the same 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.
Synposis (a man-esque page)
chuck -- [ options|commands ] [ +-=ˆ] ﬁle1 ﬁle2 ﬁle3 ... [ options ] =halt|loop|audio|silent|dump|nodump|about| srate
<N>|bufsize <N>|bufnum <N>|dac<N> |adc<N> | remote <hostname>|port<N> |verbose<N> | probe|remote <hostname>|port<N> [ commands ] =add|remove|replace|status|time|kill [ +-=ˆ] = shortcuts for add, remove, replace, status
ChucK can run 1 or more processes in parallel and interactively. The programmer only needs to specify them all on the command line, and they will be compiled and run in the VM. Each input source ﬁle (.ck suffix by convention) will be run as a separate ’shred’ (user-level ChucK threads) in the VM. They can ’spork’ additional shreds and interact with existing shreds. Thanks 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 keep track of their own time, so to speak.
Additionally, more shreds can be added/removed/replaced manually at run-time, using on-the-ﬂy programming [ Wang and Cook 2004 ] - (see publications and http://on-the-ﬂy.cs.princeton.edu/).
[ options ] :
--halt / -h
(on by default) - tells the vm to halt and exit if there are no more shreds in the VM.
--loop / -l
Tells the ChucK VM to continue executing even if there no shreds currently in the VM. This is useful because shreds can be added later on-the-ﬂy. Furthermore, it is legal to specify this option without any input ﬁles. For example:
The above will ’inﬁnite time-loop’ the VM, waiting for incoming shreds.
--audio / -a
(on by default) - enable real-time audio output.
--silent / -s
Disable real-time audio output - computations in the VM is not changed, except that the actual timing is no longer clocked by the real-time audio engine. Timing manipulations (such as operations on ’now’) still function fully. This is useful for synthesizing audio to disk or network. Also, it is handy for running a non-audio program.
--dump / +d
dump the virtual instructions emitted to stderr, for all the ﬁles after this ﬂag on the command line, until a ’nodump’ is encountered (see below). For example:
%>chuck foo.ck +d bar.ck
Will dump the virtual ChucK instructions for bar.ck (only), with argument values, to stderr. --dump can be used in conjunction with --nodump to selectively dump ﬁles.
--nodump / -d
(default state) cease the dumping of virtual instructions for ﬁles that comes after this ﬂag on the command line, until a ’dump’ is encountered (see above). For example:
%>chuck +d foo.ck -d bar.ck +d doo.ck
Will dump foo.ck, then doo.ck - but not bar.ck.
These are useful to debug ChucK itself, and for other entertainment purposes.
Set 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 ﬁle. Not all sample rates are supported by all devices!
set 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:
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.
--chan(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.
Opens N number of output channels on the audio device. by default (N) is 2.
--about / --help
Prints the usage message, with the ChucK URL
Utilizes a callback for buffering (default).
Utilizes blocking for buffering.