Esempio n. 1
0
void VirtualPad::press(u8 v, bool aftertouch)
{
    if (aftertouch)
    {
        if (!isButton)
        {
            app_aftertouch_event(index, v);
        }
    }
    else
    {
        app_surface_event(
            index == LP_SETUP ? TYPESETUP : TYPEPAD,
            index,
            v);
    }
    
    held = aftertouch || v != 0;
    velocity = v;
}
Esempio n. 2
0
static void processPacket(const unsigned char *data, int length)
{
    // parse MIDI (very naively)
    while (length > 0)
    {
        unsigned char status = data[0];
        
        // Wipe out channel (bottom four bits)
        status &= 0xF0;
        
        if (length >= 3)
        {
            switch (status)
            {
                case NOTEON:
                case NOTEOFF:
                    app_surface_event(TYPEPAD, data[1], data[2]);
                    length -= 3;
                    break;
                    
                case CC:
                    app_surface_event(TYPEPAD, data[1], data[2]);
                    length -= 3;
                    break;
                    
                case POLYAFTERTOUCH:
                    app_aftertouch_event(data[1], data[2]);
                    length -= 3;
                    break;
                    
                default:
                    break;
            }
        }
        else
        {
            // We expected at least three bytes and didn't get them, so bail
            length = 0;
        }
    }
}