handle-program-change

copsmusic/midi-basic/handle-program-change

Analyze if the MIDI msg is a Program Change msg and send output Program Change data
handle-program-change
@/handle-program-change
Analyze if the MIDI msg is a Program Change msg and send output Program Change data
TRGpulse
Trigger the MIDI CC message analyzer when a MIDI message is received
CH_INnumber
Channel of the msg
Typenumber
Type of the msg
Data1number
First part of the midi msg
handle-program-change
PC
CH
PrgNum
TRG
CH_IN
Type
Data1
PrgNumnumber
Program Number
CHnumber
Channel
PCpulse
Triggered when a Progran Change 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 channel;
        
    if (isInputDirty<input_TRG>(ctx)) {

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

        if (type ==192) {     //Program Change
            
            emitValue<output_CH>(ctx,channel);  
            emitValue<output_PrgNum>(ctx,data1);
            emitValue<output_PC>(ctx,1);
        }
    }
}