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!



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)
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
Super Mario Bros. theme, recreated in ChucK
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 (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
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
Dinky instrument implemented as class
class constructors and destructor
class static variables
learning about objects with .help()
a file that used the class Dinky
@import
@import CK files (see @import documentation)
Foo (target) |
import-test-1 (importer) |
import-test-1e (importer)
a more extensive example
ks-chord (target) |
import-test-2 (importer)
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"
S.M.E.L.T.
Keyboard (terminal only; see HID usage above)
kbhit | kbhit2
MIDI
MIDI input
gomidi | gomidi2
MIDI input with polophony
polyfony | polyfony2
MIDI file reader / player!
midifile-play | bwv772.mid
MIDI output
midiout | midiout2
Open Sound Control (OSC)
OSC message sender and receiver
s (sender) | r (receiver) |
r2 (receiver; alternate)
OSC multiple message at different rate
s-multi-msg | r-multi-msg
OSC one sender to many receivers
s-sender | r.ck
OSC multicast (broadcast to local area hosts)
s-multicast | r.ck
OSC message dumper
osc-dump
Serial I/O
reading byte(s)
byte | bytes
reading ascii/binary
ints-ascii | ints-binary | lines
writing
write-bytes | write
listing serial devices
list
Arduino INO file
ckserial.ino
Stereo / Multi-channel
Stereo noise (using Pan2)
stereo-noise
Stereo powerup
powerup2
Stereo => arrays of mono UGens
ugen-array
Stereo Stooges
moe2 | larry2 | curly2
Multi-channel demos
n-chan (i) | n-chan (n) | we-robot
Live Sampling and Granular Synthesis Using LiSa
Basics of live sampling using LiSa
readme-LiSa1 | readme-LiSa2
Live sampling simple looping
LiSa-simplelooping
LiSa2 stereo
LiSa-stereo
Granular sampling examples
LiSa-munger1 |
LiSa-munger2 |
LiSa-munger3
Granular synthesis example: Scream-o-Matic 2000
scream-o-matic |
data files
Loading an audio file into a LiSa
LiSa-load
LiSa tracking mode examples
LiSa-track1 | LiSa-track2 |
LiSa-track3 | LiSa-track4 |
LiSa-track5 | geetar.wav
Input-driven LiSA trigger
LiSa-trigger
String Utilities
String operations
strops | strops2
String escape sequences
escape
String input + tokenize (hacked; temporary)
readline | token
(More) Unit Generators Examples
> Filters
low pass filter
lpf
resonance low pass filter
rlpf
high pass filter
hpf
resonance high pass filter
rlpf
resonance filter with equal-gain zeros
resonz
band pass filter
bpf
band reject filter
brf
> STK ( Synthesis ToolKit ) demos
BandedWG (Banded Waveguide)
bandedwg | band-o-matic
BlowBotl
blowbotl | blowbotl2
BlowHole
blowhole
Bowed
bowed
Brass
brass
Clarinet
clarinet
Flute
flute
FrncHrn
frenchrn-aglo2
HevyMetl => acoustic guitar
hevymetl-acoustic-algo3
HevyMetl => power chords
hevymetl-dance-now
HevyMetl => trumpet
hevymetl-trumpet-algo3
KrstlChr
krstlchr-algo7
Mandolin
mandolin | mand-o-matic
Moog (r.i.p. bob)
moog | moogie
Rhodey (Rhodes synth)
rhodey
A lovely littel number made with Rhodey...
rhodey-song
Saxofony
saxofony
Shakers
shake-o-matic
Sitar
sitar
StifKarp
stifkarp | stif-o-karp
TubeBell
tubebell-algo5
VoicForm
voic-o-form
Wurley (Wurlitzer model)
wurley | wurley2 | wurley3
Unit Analyzers
> Transformations
FFT
fft | fft2 | fft3
IFFT
ifft | ifft2 | ifft3
DCT
dct
Windowing
win
Flip / UnFlip
flip
auto-correlation-based pitch detection
autocorr
cross-correlation delay detection
xcorr
(really bad) spectral cross-synthesis
xsynth
> Feature Extractors
Centroid
centroid
Chroma
chroma
Flux
flux | flux0
Kurtosis
kurtosis
RMS
rms
RollOff
rolloff
SFM
sfm
ZeroX
zerox
Feature Collector
features-combined
Feature Collector (alt use)
concat
Feature-based Genre Classification (part of chai)
features-extract | genre-classify | x-validate
ChucK for AI (ChAI)

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


AltStyle によって変換されたページ (->オリジナル) /