Fall2008.ApostolicBlurchInjectorCk History

Hide minor edits - Show changes to output

Changed line 27 from:
SndBuf buf1 => dac;
to:
SndBuf buf1 => g;
Added lines 1-64:
(:source lang=chuck tabwidth=3 -trim :)
// apostolic-blurch-injector.ck
//
// Name:
// Class:
// Date:
//
// Imitates Frank Zappa's "Apostolic Blurch Injector".
//

// HID
Hid hi;
HidMsg msg;

// which keyboard
0 => int device;

// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;

// create an amplifier and connect it to the audio card
Gain g => dac;
0.0 => g.gain; // turn the volume down

// read the audio files
SndBuf buf1 => dac;
"data/kick.wav" => buf1.read;

SndBuf buf2 => g;
"data/snare-chili.wav" => buf2.read;

// create your own buffers below (give them different names from the ones above)
// ...

// infinite event loop
while( true )
{
// wait for event
hi => now;

// get message
while( hi.recv( msg ) )
{
// check
if( msg.isButtonDown() )
{
<<<"msg.which:", msg.which>>>;
0.5 => g.gain; // turn the volume up

if (msg.which == 44) // space bar?
0 => buf1.pos; // start playing

if (msg.which == 29) // z?
0 => buf2.pos;

// add more if statements like the above for each of your buffers
// ...

}
}
}
(:sourcend:)