Presentation is loading. Please wait.

Presentation is loading. Please wait.

Harvestworks Part 1: ChucK basics Rebecca Fiebrink Princeton University 1.

Similar presentations


Presentation on theme: "Harvestworks Part 1: ChucK basics Rebecca Fiebrink Princeton University 1."— Presentation transcript:

1 ChucK! @ Harvestworks Part 1: ChucK basics Rebecca Fiebrink Princeton University 1

2 Introductions, etc. 2

3

4 ChucK in a nutshell Created by Ge Wang (Princeton => CCRMA) Textual programming language for audio synthesis & analysis Sample-level control (no audio vs control rate distinction) For both low-level synthesis and higher-level composition Easy, sample-synchronous concurrency Promotes readability, understandability at expense of speed Used for teaching, laptop performance 4

5 Workshop topics ChucK basics, making sound (1.5 hours?) Syntax, built-in UGens, concurrency Interactive performance (.5 hours?) Events, controllers, OSC New language directions & current research (.5 hours?) Real-time audio analysis, machine learning for controller mappings 5

6 Let’s ChucK! miniAudicle: http://audicle.cs.princeton.edu/mini/ Workshop examples: http://www.cs.princeton.edu/~fiebrink/ harvestworks2009/ Feel free to steal code liberally! 6

7 Unit generators Building blocks of sound generation Square wave Low-pass filter DAC Cut-off frequency=500, Q Freq = 100 7

8 A very simple UGen network 8 Sine wave DAC Freq = 440 See: instantiate.ck

9 The ChucK Operator 1.Virtual “patch cord” SinOsc s => dac; Noise n => LPF filter => dac; 2.Assignment operator 5.0 => float f; 9 See: time.ck

10 Time in ChucK Two jobs of the virtual machine: 1. Interpret ChucK code line by line, following instructions of the code 2. Output a stream of audio samples to the system DAC buffer ChucK ONLY outputs audio samples when time is “advanced”!! 10 See: while-loop.ck

11 Advancing Time – E.g., 1::second => now; or 1::samp => now; – ChucK ensures that exactly the number of audio samples are produced – All the other work of ChucK happens in between outputting samples, as if in a single instant in time 11 See: while-loop.ck; note loop construct and Std.rand2f function call

12 Playing back stored audio with SndBuf 12 SndBuf DAC Parameters: pos, rate, loop, other See: sndbuf.ck; note Std.rand2f for random number generation

13 ChucK Syntax Basics 13 See: while-loop.ck

14 Physical Modeling with ChucK STK – Ready to use physical models – All have noteOn(), noteOff(), freq() methods 14 See: mandolin.ck, clarinet.ck, mandolin2.ck

15 Additive synthesis + arrays Examples: additive_noarrays.ck, additive_sines_array.ck, additive_with_vibrato.ck Note array syntax, for-loop syntax 15

16 Analysis - resynthesis 16 Singing bowl strike: Peaks at 528, 1413, 2630, 4127, and 5877 Hz (add_bowl.ck)

17 Envelopes Can apply an envelope function of arbitrary time granularity by hand in ChucK – Singing bowl in time domain: exponential decay Ex: add_bowl_exp_envelope.ck 17

18 Built-in ChucK Envelopes Example: ADSR: attack, decay, sustain, release 18 Oscillator (e.g. SinOsc) Envelope Parameters DAC See: sine_ADSR.ck, add_bowl_with _ADSR

19 Other built-in UGens Filters Built-in, or create your own from filter equation lpf.ck, lpf_mouse.ck, resonance.ck, resonance_mouse.ck, run_clix.sh Reverb, echo, delay lines JCRev – the ketchup of PLOrk Noise, Impulse, [band-limited] saw/square/etc. Look-up tables 19

20 Getting audio input and using it adc object for audio in – Audio example: Plork beat science flute processing: – Example: echo.ck Live sampling: trueman_munger.ck, adc_munger.ck 20

21 Using sample granularity for FM 21 See: FM_byhand, FM_mouse, FM_stk

22 Concurrency 1 “Add shred” in miniAudicle See: Moe/Larry/Curly, OTF ChucK – Also note: OTF synchronization method 22  Time Shred 0 Shred 1

23 Shreds A shred is a running piece of code that’s getting executed line-by-line by the virtual machine. Multiple shreds can be running at once, in parallel; their timings are guaranteed to be sample-synchronous 23

24 Concurrency 1: Manually adding shreds “Add shred” in miniAudicle See: Moe/Larry/Curly, OTF ChucK – Also note: OTF synchronization method 24  Time Shred 0 Shred 1

25 Concurrency 2: Sporking shreds Sporking functions – See shred1.ck through shred4.ck; also functions handout 25 Shred 0 Shred 1 spork ~ fun1(); (parent shred) (child shred)

26 Why use ChucK? (Language reasons) Sample-level control – E.g. see FM_byhand.ck, while-loop.ck Concurrency for free – Spork or add as many shreds as you want; they’ll remain in synch with each other – E.g., see OTF examples, shred4.ck Event-driven interactivity (e.g., SMELT: coming up next) Integrated audio analysis (UAnae) – Leads to support for real-time AI / machine learning and music information retrieval 26

27 Why not use ChucK? Not optimized Not multicore No garbage collection 27

28 Coming up in Part 2 Making ChucK interactive! 28


Download ppt "Harvestworks Part 1: ChucK basics Rebecca Fiebrink Princeton University 1."

Similar presentations


Ads by Google