ChucK | Examples
version: 1.5.x.x (chai)

Chuck Examples

The following are example programs that demonstrate basic language features, tools, and techniques. All of these examples files can be found in the distribution (download page) under the folder examples. Additionally, they can be accessed from within miniAudicle, under "File > Open Example..." Many of these examples are also linked from the ChucK API Reference. Good luck and have fun!

Jump to Section



Various Basic Examples

A selection of examples that demonstrate basic sound generation, timing, and control in ChucK. As with all examples here, feel free to try and experiment!

Basic Demonstrations
time and duration
variable assignment and use
chucking & unchucking ugens
modulating ugen parameters
using command line arguments
mic input
ADSR method
a chuckian alarm clock (no warranties!)
digital delay
simple comb filter using Delay
echo effect
using Envelope
knuckleheads (time shifted phase locking)
knuckleheads++ (with glottal voicing)
function demo
po-tweet!
the uh, whole tone scale
sinosc + blit (bandlimited oscillators)
FM synthesis "by hand"
FM synthesis with two sinosc
FM (actual frequency modulation)
oscillators
mic input and simple comb filter
impulse generator
imp
low-frequency oscillator
lfo
recording (via WvOut)
clocks (useful when recording and other)
basic ring-mod (demonstrate ugen input)
sndbuf (file read/write/playback)
sndbuf.valueat() - random access samples
step ugen
unchuck
whirl
noise & filters
function test
math.isinf() also math.isnan()
input/output (including FileIO) examples
"Deep" Stuff
formant-based singing synthesis
audio dithering "by hand"
how phones dial
one pole envelope follower
karplus strong plucked string
plucked string with mandolin body excitation
tuned plucked string (a la jaffe/smith)
karplus strong comb-filter bank chugraph
say "ChucK" through synthesis
Shepard Tone generator
THX Deep Note emulator (info)
Reich's Clapping Music using glottal pulses
More Fun Experiments
variations on towers of hanoi sonification
hanoi (no sound) | hanoi2 | hanoi3
on-the-fly synchronization (concurrent)
Can't decide? Flip a coin with maybe!
Different shades of RNG
Okay, not that fun, but really useful


Language Features

These examples demonstrate features described in the ChucK Language Specification.

Types
Survey of chuck's primitive types
Object type (more later)
The 'auto' type
Polymorphism in ChucK
Analysis-related type
Working with the Type type
Querying active types in the VM
Vectors 3D + 4D
Using vec3 as a slewing interpolator
Arrays
store and retrieve values
appending to an array
for-each in array
for-each in array (with auto type)
arrays are automatically resized
(e.g., using append and popBack)
erasing elements in an array
array @=> assignment
instantiating multidimensional arrays
reassigning sub-arrays
array as function argument
multi-dimensional array instantiation
mixed associative and linear array
generating arrays containing ranges of values
resizing arrays
negative indexing of arrays
reversing an array
shuffling an array
zeroing the elements an array
Operators
operators for assignment
logical operators
pre/post increment
arithmetic operators
Time & Timing
time and duration
reasoning about time
Control Structures
for loop
for-each loop
repeat
until
do-until
while
do-while
break
break w/ nesting
continue w/ nested blocks
Philip's sequencer
Functions
function overloading
recursive function calls
objects as function arguments
Shreds & Concurrency
sporking shreds
sporking many shreds
Machine.add() .remove() .replace()
Virtual Machine functions
evaluating string as code
VM operations hodge-podge


Tools and Techniques

These examples demonstrate pratical tools ranging from unit generators, events, mouse / keyboard / joystick input, file I/O, MIDI, Open Sound Control, how to extend ChucK unit generators, and more.

Classes & Objects
learning about objects with .help()
Dinky instrument implemented as class
a file that used the class Dinky
Extending ChucK Unit Generators
chugraph (rhymes with "u-graph")
chugen (rhymes with "ugen")
chugin (rhymes with "plugin")
Events
event broadcast method
event signal method
extending events (creating custom events)
Input/Ouput
chout ("shout") and cherr ("Cher")
file directory access
file input: reading ints
file input: reading floats
file input: reading lines
file input: reading tokens
file input: reading strings
file input (binary mode): reading bytes
file input (binary mode): parsing a WAV file
file output
file output (binary mode): writing bytes
HID Input (Joystick, Mouse, Keyboard)
Joystick demo
Mouse demo
Keyboard demo
Gametrak demo
"SMELT: Small Musically Expressive Laptop Toolkit"
Keyboard (terminal only; see HID usage above)
MIDI
MIDI input
MIDI input with polophony
MIDI file reader / player!
MIDI output
Open Sound Control (OSC)
OSC message sender and receiver
OSC multiple message at different rate
OSC one sender to many receivers
OSC multicast (broadcast to local area hosts)
OSC message dumper
Serial I/O
reading byte(s)
reading ascii/binary
writing
listing serial devices
Arduino INO file
Stereo / Multi-channel
Stereo noise (using Pan2)
Stereo powerup
Stereo => arrays of mono UGens
Stereo Stooges
Multi-channel demos
Live Sampling and Granular Synthesis Using LiSa
Basics of live sampling using LiSa
Live sampling simple looping
LiSa2 stereo
Granular sampling examples
Granular synthesis example from Twilight (2013)
Granular synthesis example: Scream-o-Matic 2000
Loading an audio file into a LiSa
LiSa tracking mode examples
Input-driven LiSA trigger
String Utilities
String operations
String escape sequences
String input + tokenize (hacked; temporary)
(More) Unit Generators Examples
    > Filters
low pass filter
resonance low pass filter
high pass filter
resonance high pass filter
resonance filter with equal-gain zeros
band pass filter
band reject filter
    > STK ( Synthesis ToolKit ) demos
BandedWG (Banded Waveguide)
BlowBotl
BlowHole
Bowed
Brass
Clarinet
Flute
FrncHrn (requires chuck-1.4.1.0 or later)
HevyMetl => acoustic guitar (1.4.1.0 or later)
HevyMetl => power chords (1.4.1.0 or later)
HevyMetl => trumpet (1.4.1.0 or later)
HnkyTonk (1.4.1.0 or later)
KrstlChr (1.4.1.0 or later)
Mandolin
ModalBar
Moog (r.i.p. bob)
Rhodey (Rhodes synth)
A lovely littel number made with Rhodey...
Saxofony
Shakers
Sitar
StifKarp
VoicForm
Wurley (Wurlitzer model)
Unit Analyzers
    > Transformations
FFT
IFFT
DCT
Windowing
Flip / UnFlip
auto-correlation-based pitch detection
cross-correlation delay detection
(really bad) spectral cross-synthesis
    > Feature Extractors
Centroid
Chroma
Flux
Kurtosis
MFCC
RMS
RollOff
SFM
ZeroX
Feature Collector
Feature Collector (alt use)
Feature-based Genre Classification (part of chai)
ChucK for AI (ChAI)

see ChAI landing page and the AI Tools API reference for examples!