/usr/share/doc/chuck/examples/hid/keyboard-organ.ck is in chuck 1.2.0.8.dfsg-1.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | // HID
Hid hi;
HidMsg msg;
// which keyboard
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;
// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;
// patch
BeeThree organ => JCRev r => Echo e => Echo e2 => dac;
r => dac;
// set delays
240::ms => e.max => e.delay;
480::ms => e2.max => e2.delay;
// set gains
.6 => e.gain;
.3 => e2.gain;
.05 => r.mix;
0 => organ.gain;
// infinite event loop
while( true )
{
// wait for event
hi => now;
// get message
while( hi.recv( msg ) )
{
// check
if( msg.isButtonDown() )
{
Std.mtof( msg.which + 45 ) => float freq;
if( freq > 20000 ) continue;
freq => organ.freq;
.5 => organ.gain;
1 => organ.noteOn;
80::ms => now;
}
else
{
0 => organ.noteOff;
}
}
}
|