Haunted House

Origo is a funnyface (0,0)

ambientic monotonic pieceus

Posted by Gasten on August 18, 2007

Yey! I’ve finished a piece! It’s a inspired a bit by Kraftwerks ‘Klingklang,’ even if mine isn’t deserved to be mentioned in the same sentence as Kraftwerks … track.

What started out as a test of a theory about how you could use ChucK’s spork-keyword to trigger notes, but still have plenty of room for per-sample synthesis, turned out to be an exercise in FM synthesis, reverb controlling, arrays, and on using BPM as a timer: all of which I have wanted to play around with.

It turned out pretty good, actually. You could pretty easily create more layers of sounds by either baking more spork-calls inside the main loop, or by creating sub-main loops that controls – or sequences – a …hm… a low pitched square-wave with lots of sweeping filters on top of it?

Of course, the code:

// A monotone ambient piece made by Martin "Gasten" Ahnelöv 

65.0 => float bpm;
60::second / bpm => dur  beat;

// The note-sheet we are using
[
    72, 74, 76, 77, 79, 81, 83,
    84, 86, 88, 87, 91
] @=> int noteIndex[];

// Patch. Leaving out what actually makes the sound to 
// make sure that the first note don't breaks when the second comes in.
Gain g => PRCRev rev => dac;

0.2 => g.gain; 
0.6 => rev.mix;

fun void newNote(int keynum, dur notedur) {
    // Beginning of the patch. for the namespace's sake.
    SinOsc mod1 => SinOsc mod2 => SinOsc car => ADSR env => g;
   
    // A couple of variants of envelope-settings to make things more dynamic
    if (maybe && maybe) { env.set(15::ms, 8::ms, 0.5, 355::ms); } 
    else if (maybe && maybe) { env.set(4::ms, 2::ms, 1.0, 650::ms); }
    else { env.set(10::ms, 12::ms, 0.8, 500::ms); }
    
    // sync: FM
    2 => car.sync;
    2 => mod2.sync;

    35.0 => mod1.gain;
    keynum/8 => mod1.freq; // A number around 10 

    100.0 => mod2.gain;
    4.0 => mod2.freq;

    Std.mtof(keynum) => car.freq;
    
    // Play it!
    env.keyOn();
    notedur => now;
    env.keyOff();

   1::second => now; // One second to make sure the Release will be heard
}

while ( true ) {
    // Play random note for one, or in some cases two, beats
    if ( maybe || maybe ) {
        spork ~ newNote(noteIndex[Std.rand2(0,11)], beat);
    } else {
        spork ~ newNote(noteIndex[Std.rand2(0,11)], beat*2); // Half-note
    }
   
    beat => now;    // Wait a beat, or wait a beat more
    while (maybe) {
        beat => now; 
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: