From CSWiki
Revision as of 19:00, 17 May 2008 by Dzaslavs (talk | contribs) (David's Final Project: The CheesyChucK (TM, no not really) sampler)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

David's Final Project: The CheesyChucK (TM, no not really) sampler

What is the CheesyChucK Sampler?

It is a sampler, written in ChucK, that is very cheesy. Basically you have some sound files, and you have some ChucK code that will play those sound files when you hit keys on your computer keyboard. It sounds bad and is very cheesy indeed (hence the name), but it's actually kind of fun to play with, because (and this is the big secret of CheesyChucK) the amusement you get from playing with CheesyChucK disguises how bad it sounds.

Using the CheesyChucK Sampler

Using the CheesyChucK Sampler is very easy, once you've gotten past the hard parts. First, you will need a computer, preferably Linux or Mac. Theoretically this might work on Windows as well, but don't count on it. You will need to install ChucK on this computer, or have it already installed and working. Then to use CheesyChucK, you can just download the file (37MB) from http://www.princeton.edu/~dzaslavs/public_html/mus316/cheesychuck.zip and unzip it into any directory, then go into that directory and run ./cheesychuck from the command line.

Once you have started the program, you can push keys and it will hopefully make sound. The keyboard interface is fairly simple at first: the keys A,S,D,F,J,K,L,semicolon are mapped to the eight notes of the diatonic scale. The keys in the row above represent the chromatic notes in between; this layout is meant to emulate the white keys and black keys of a piano. So if you push ASDFJKL; in order you get an ascending diatonic scale, or if you push AWSEDFTJIKOL; in order you get an ascending chromatic scale. If you hold down shift while pushing any of these keys, the notes produced are an octave higher. This spans the entire two-octave range of the sampler.

Where it gets complicated is (musical) key changes. You can push the minus (keyboard) key to go down a (musical) key, and the equals (keyboard) key to go up a (musical) key. The (musical) key changes create (keyboard) key changes so that the main/"white" (keyboard) keys are always in the (musical) key. To rephrase this sensibly, say that the middle-row keys ASDFJKL; start out representing the notes CDEFGABC. If you push equals twice to move the key up two half-steps to D, some of the notes represented by the middle-row keys will change to be in the D major scale. So the keys ASDFJKL; now represent the notes C#,D,E,F#,G,A,B,C# in that order. At the same time, the keys in the top row reconfigure themselves so that they take over the notes (C and F) that have been bumped out of the middle row, and furthermore these new notes actually appear in the proper spot relative to the notes that are now in the middle row. So pushing QASEDRFJIKOLP would give you a C chromatic scale when the sampler is in the key of D (if the Q key worked, that is - but it doesn't; this is a bug). If you think about it (not too hard), CheesyChucK is really a proof-of-concept experiment in dynamic keyboard layouts.

There are also patch changes to consider. The CheesyChuck sampler comes with 12 different patches, each of which provides all 25 notes of its two-octave range. The distinctive sound of each patch is constructed by adding together a series of sine waves at multiples of the note's base frequency, with amplitudes varying as a function of the harmonic. Sometimes the amplitudes are chosen according to some mathematical pattern, like instrument 11 which has two peaks at harmonics 1 and 9 with gradual tails in either direction, or instrument 5 which uses only the odd harmonics with amplitude inversely related to harmonic number (the harmonic series, of sorts). Some other patches have amplitudes chosen to emulate some real instrument, like patch 10 which roughly emulates a tuba, and other patches are designed just to sound cool. The number keys 1-9 are used to choose the patch during operation of the CheesyChucK sampler: when pressed by themselves, keys 1-9 choose patches 1-9 respectively, and with shift held down, keys 1-3 select patches 10-12. Number 0 selects a special "percussion" patch consisting of recorded sounds, occasionally useful as sound effects.

Additionally, the CheesyChucK Sampler has recording capability. If you push space bar, it will record everything you play until you push space bar again, at which point it begins to loop that recording. The recording keeps looping using the same patch, but if you change key, the notes of the recording will be automatically transposed into the new key so they sound just as consonant as they did before.

The contents of this section are reproduced in the README file. Except for that sentence. And that one. And that one. And, well, that one and this one. There, done. Oh wait, that sentence isn't in the README file either...


For your listening pleasure/torment I present a live, raw, mostly unprocessed audio recording of a CheesyChucK jam session, courtesy of WvOut Inc. at http://www.princeton.edu/~dzaslavs/mus316/recording.mp3 This is essentially the Quaker Oatmeal song, "Heart and Soul", with improvisational segments thrown in between the melodies. It is meant to showcase the different patches available. Warning: don't start this with your volume turned up.

There are a lot of clicks in the given example; these come from the sound files in the patches that the sampler uses. These sound files have sharp cutoffs because the R part of ChucK's ADSR ugen doesn't seem to be working on them, thus leading to the clicks. Unfortunately, I didn't have time to go through and soften the notes' releases manually. I tried some click reduction and low-pass filtering on the final recording (since the clicks are the only things in the file with a significant component over ~8000 Hz) but they didn't seem to help enough, and in some cases even made the sound quality worse, so for now I'm just going to accept them as a fact of CheesyChucK. (Tapestrea probably would have been good for this but I've never used it and I don't think this is the time to learn.)

Future Progress

Since the CheesyChucK sampler is a proof-of-concept of sorts, there may or may not be something in the works that expands on that concept. I'd like to get rid of some of the bugs, expand the range of the sampler, produce better sounds, maybe add the ability to synthesize new sounds on-the-fly, give it a better GUI, etc. which could turn this into a nifty toy that people might actually like to play with.