receive(usb-midi)

e/usb-midi/receive(usb-midi)

No description
receive(usb-midi)
@/receive(usb-midi)
MIDI@/usb-midi
RCVpulse
receive(usb-midi)
MSG
DONE
MIDI
RCV
DONEpulse
MSGe/midi/message
To use the node in your project you should have the e/usb-midi library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

node {
    void evaluate(Context ctx) {
        if (!isInputDirty<input_RCV>(ctx)) return;

        auto MIDI = getValue<input_MIDI>(ctx);

        auto rx = MIDI->read();

        if (rx.header != 0) {
            typeof_MSG msg = {};
            msg.type = rx.header << 4;
            msg.channel = rx.byte1 & 0b00001111;
            msg.data1 = rx.byte2;
            msg.data2 = rx.byte3;

            emitValue<output_MSG>(ctx, msg);
            emitValue<output_DONE>(ctx, 1);
        }
    }
}