Skip to content

Instantly share code, notes, and snippets.

@konsumer
Created September 22, 2012 20:56
Show Gist options
  • Save konsumer/3767813 to your computer and use it in GitHub Desktop.
Save konsumer/3767813 to your computer and use it in GitHub Desktop.
Plays creepy random sitar music when Tony types.
Hid hi;
HidMsg msg;
hi.openKeyboard( 0 );
Sitar sit => PRCRev r => dac;
fun void pluk( int code ) {
Math.random2( 0, 11 ) => float winner;
Std.mtof( 57 + Math.random2(0,3) * 12 + winner ) => sit.freq;
Math.random2f( 0.4, 0.9 ) => sit.noteOn;
if( Math.randomf() > .5 ) {
.1::second => now;
} else {
0.2::second => now;
}
}
while( true ) {
hi => now;
while( hi.recv( msg ) ) {
if( msg.isButtonDown() ) {
pluk( msg.which);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment