Up N ChucKin

From CSWiki
Revision as of 03:38, 23 December 2006 by Kijjaz (talk | contribs) (Writing Your First Script)

Jump to: navigation, search

ChucK Workshops

Up N' ChucKin' is a workshop tutorial written/compiled by Adam Tindale for beginning ChucKers. If you are an experienced ChucKist I encourage you to try and run one in your area.


Curriculum

Here is a suggested and tested course of study for the workshop.


What the Chuck?

Give an overview of ChucK. Sounds simple, but it can be difficult. Usually start from the abstract and then move to the specific. What are the benefits of using this language? That is what they want to know.

ChucK is strongly timed. Users can have sample accurate control over processes. This is very useful for all kinds of things, including very low-level processes requiring precise and predictable timing including granular synthesis (which can be natively implemented in chuck), LPC, FOF's, matching phases or dealing with FFTs (a feature hopefully coming soon).

Concurrency. You can easily run many processes in parallel and synchronize them by time (strongly-time) make multiple copies of programs. This is much easier than in some other languages. Synchronization is extremely flexible.

On-the-fly-programming. How cool is this?

Simple syntax. Show some examples.

Good community. The mail list and the WIKI rock.

Lots of bugs. Seriously this is good. People can help fix them by reporting problems. If we don't know that it is broken we will never fix it! Reporting bugs is an important part of software development. It is a great way to get involved.

There are many other great things about ChucK. Talk about why you like it and how it is has helped you make music.

Getting ChucK installed

Take a gander to the ChucK release page for the latest versions of ChucK. You may want to only install the binary versions for simplicity. It is a good idea to show the compile process so they don't get scared off.

Running some examples

Go through the standard larry, curly and moe examples. Try running the patches in the examples directory, there are lots to choose from! Get them hooked. The real fun is about to begin.

Writing Your First Script

I like to go through a pretty standard drill to help newbies write ChucK code. Here we go.

What is the music equivalent of "Hello world"? A sinewave at 440. Lets make one in ChucK. First we need a sinewave. In ChucK we use the sinosc ugen. Now we ChucK it to the DAC. This makes a connection of a sinewave oscillator to the physical output. Just what we ordered.

	
    SinOsc s => dac;

Hold the phone. What is that s over there? Ok ok. ChucK allows you to create instances of Ugens and objects. This is great because you can address certain sinewaves and not others. You wouldn't want a bank of twenty sinewaves that only had one frequency? (maybe you would...) But, the point is that you need them all to have names in order to address them. In fact, that is the next thing we need to do!

Now we need to set the frequency of our sinewave to 440. No problem. ChucK works left to right. This can be strange if you have programmed in other languages before. You will get used to it. To set the frequency we send the float 440. (make sure you have the period!) to the freq parameter of s.

    440. => s.freq;

Now try saving this patch and then giving it to ChucK. If we were to save it as test.ck you would do this:

   %/> chuck test.ck


What happened? It seemed to do something and then came back to the prompt. This is the correct behaviour. We have not done a crucial step: manage time.

For simplicity we are going to have our program loop forever. To do this we will use a while loop. We will set the boolean condition to true and inside of the loop we will advance time by 1 second for every trip through the loop.

    while(true){
        1::second => now;
    }

Everything should work just fine now. You should hear your sinewave poking out of your speakers. This is the first of many terrible noises you will make.

Opening The Gates

Alright. Now that we have a functioning program we are going to modify it just a little bit and make big changes. First, let's add some effects! We'll start simple and add a gain that we will call fx.


    sinosc s => gain fx => dac;

You can change the gain like so:

    .5 => fx.gain;


All right, now our sinewave is softer. Cool, but it could be cooler. Let's make two simple changes. If we change gain for JCRev and .gain for .mix then things will be much cooler.

    sinosc s => JCRev fx => dac;
    .5 => fx.mix;

Fool around with the .mix level and see what happens!

Next thing on the agenda, do something with time! Inside of our while loop lets change the frequency of the sinewave. We will use a random number generator to get this done.

    while(true){
        1::second => now;
        std.rand2f(100.,1000.) => s.freq;
    }

Getting cooler. Try and adjust the unit of time and the mix parameter to make something better. Try adding multiple copies of this patch. See what happens when you add a copy, save over the file and then add it again. What do you notice?

At this point try swapping out JCRev for some of the other reverbs and sinosc for some of the other oscillators. Let them explore and guide them. This is a great way to transition into the next section.

Wrapup

Now it is time to show some advanced examples. Try to play up your strengths, show how you use ChucK for music, fun, synthesis, attacking your friend's computer... This will give the new ChucKers an idea of what is possible and some inspiration.

If you have any words of wisdom here is the place to put them. If you have found a certain "behaviour" that causes you trouble, let them know. We can all learn from each other's mistakes.

I like to mention the strengths and weaknesses of ChucK here. Then I reinforce where ChucK can be found: the website, the wiki, and some of the other excellent websites on ChucK.

Past (And Future) Workshops

NIME 2005

May 24, 2005

Ge Wang, Ananya Misra, Perry Cook, Ajay Kapur and Adam Tindale

This was a great workshop. Twenty victims...er ChucKists. Over 4 hours of ChucK with lots of examples and controllers.

Visit NIME.

University of Victoria

May 5, 2005

Adam R. Tindale

A two hour session for 5 new ChucKers.

Transmediale 2005

Februrary 6, 2005

Ge Wang

A Toplap event. A 3 hour workshop and 2 performances.

Share 2004

November 17, 2005

Ge Wang + Phil Davidson

An informal session for new ChucKers. The first infection.