examples\chuck\abcFile.ck
DbAbc abc; // instance of abc parser + performer
Wurley inst => dac;
.8 => inst.gain;

me.dir() + "cooleys.abc" => abc.open => int success;
if(!success)
{
    <<< "Problem with abc file">>>;
    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">>>;
home .. topics .. interface .. reference .. examples .. tipjar