Tuesday, June 5, 2012

ChucK reactions and cool discoveries

It has been really great learning to use ChucK, and making cool discoveries with each new day before me. ChucK to me is not a challenging language, but the challenge comes in understanding what you are doing. Understanding how to use the unit generators (I overheard the professor saying "unit generators" seems to be an old phrase, but I don't know what else to call them), and understanding the many STK
instruments available in ChucK will help an individual produce very cool music without much sweat. I played around with the clarinet, brass, mandolin, StifKarp (a plucked string), and many other instruments, and I was so amazed by some of the beautiful melodies I produced with very little code. Please see below my code for my first program using the StifKarp.

//connect a plucked string to the soundcard out
StifKarp inst => dac;

//sequence of data for the melody
[0,2,3,3,1,1,4,6,4,5,2,2,1,0,0,6] @=> int mel[];

//the major scale
[0,2,4,5,7,9,11,12] @=> int major[];

while (true){
    for (0=>int i;i<mel.cap(); i++) { //infinite loop
          Std.mtof( 48 + major[mel[i%mel.cap()]] ) => inst.freq; //set the note
          inst.noteOn( 0.5 ); //play a note at half volume
          300::ms => now; //compute audio for 0.3 sec
    }
}


The following reference on unit generators has been very helpful to me:

http://chuck.cs.princeton.edu/doc/program/ugen.html


** Understanding filters is key as well. All I can say is music programming in not just sitting down and writing a bunch of code, the programmer has to have a deep understanding of digital music as well.

1 comment:

  1. Yes, unit generators is an "old phrase" but that is not a bad thing in this context. It is a part of computer and electronic music. When you know what unit generators are, you can find them in other computer music languages and identify them.

    ReplyDelete