// header: default note length and Key
"X:1\nM:4/4\nL:1/4\nK:C\n" => string header;
// two measures of 1/4 notes
"|C D E F| G A B c" => string scale;
// one measure of 1/8 notes (repeated)
"|:C/ D/ E/ F/ G/ A/ B/ c/:|" => string scale2;
// one measure of 1/16 notes (repeated)
"|:C/4 D/4 E/4 F/4 G/4 A/4 B/4 c/4 " +
"C/4 D/4 E/4 F/4 G/4 A/4 B/4 c/4:|" => string scale3;
DbAbc abc; // instance of abc parser + performer
Wurley inst => dac;
.8 => inst.gain;
header + scale + scale2 + scale3 => abc.open => int success;
if(!success)
{
<<< "Problem with abc code">>>;
me.exit();
}
AbcMsg mmsg;
while(abc.read(mmsg, 0/*track*/))
{
if(mmsg.when > 0::second)
mmsg.when => now;
if((mmsg.status & 0xF0) == 0x90)
{
// note down
mmsg.data1 => float midiNote;
mmsg.data2 / 127.0 => float velocity;
Math.mtof(midiNote) => inst.freq;
inst.noteOn(velocity);
// send midiNote and velocity to instrument
}
else
if((mmsg.status & 0xF0) == 0x80)
{
// note up
mmsg.data1 => float midiNote;
Math.mtof(midiNote) => inst.freq;
inst.noteOff(1.);
}
else
{
// other control information (like pitch-bend)
}
}
<<<"Done">>>;