handle-note-on-off

copsmusic/midi-basic/handle-note-on-off

Analyze if the MIDI msg is a Note msg and send output Note data
handle-note-on-off
@/handle-note-on-off
Analyze if the MIDI msg is a Note msg and send output Note data
TRGpulse
Trigger the midi message analyzer when a message in received
CH_INnumber
Channel of the msg
Typenumber
Type of the msg
Data1number
First part of the MIDI msg
Data2number
Second part of the MIDI msg
handle-note-on-off
NoteOn
NoteOff
CH
Note
Vel
TRG
CH_IN
Type
Data1
Data2
Velnumber
Velocity
Notenumber
Note number
CHnumber
Channel
NoteOffpulse
Triggered when a NoteOff is detected
NoteOnpulse
Triggered when a NoteON is detected
To use the node in your project you should have the copsmusic/midi-basic 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

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    int type;
    int data1;
    int data2;
    int channel;
        
    if (isInputDirty<input_TRG>(ctx)) {

        channel = getValue<input_CH_IN>(ctx);
        type    = getValue<input_Type>(ctx);
        data1   = getValue<input_Data1>(ctx);
        data2   = getValue<input_Data2>(ctx);

        if (type == 144) {     //NoteON 
            
            emitValue<output_CH>(ctx,channel);  
            emitValue<output_Note>(ctx,data1);
            emitValue<output_Vel>(ctx,data2);
            emitValue<output_NoteOn>(ctx,1);
/*            
            Serial.print("channel = "); Serial.println( channel);
            Serial.print("note = "); Serial.println( data1);
            Serial.print("velocity = "); Serial.println( data2);
*/            
        }

        if (type ==128) {     //NoteOFF
            
            emitValue<output_CH>(ctx,channel);  
            emitValue<output_Note>(ctx,data1);
            emitValue<output_Vel>(ctx,0);
            emitValue<output_NoteOff>(ctx,1);

/*            
            Serial.print("channel = "); Serial.println( channel);
            Serial.print("note = "); Serial.println( data1);
            Serial.print("velocity = "); Serial.println( data2);
*/            
        }
    }
}