program-change

awgrover/x-midi/program-change

Set the inputs, send on pulse ("send")
program-change
@/program-change
Set the inputs, send on pulse ("send")
Prg#number
Program Change Number
Chnumber
MIDI Channel
sendpulse
Send when triggered
program-change
Prg#
Ch
send
sent
sentpulse
Pulse when sent
To use the node in your project you should have the awgrover/x-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

{{#global}}
#include <MIDI.h>
namespace xod {
namespace awgrover__midi {
  #ifndef MIDI47_DEFAULT_INSTANCE
    // create one 'MIDI' object only once
    #define MIDI47_DEFAULT_INSTANCE
    bool MIDI_DefaultInited=0; // control setup once

    MIDI_CREATE_DEFAULT_INSTANCE(); // MIDI

    #define DEBUG_SendText(body) /* nothing, see the "debug" node */

    void midi_setup() {
      // this should be in setup
      // ( call as xod::awgrover__midi::midi_setup(); in evaluate)
      if (!MIDI_DefaultInited) {
        // this will reset the serial port to 31250 for the midi's serial port
        MIDI.begin(MIDI_CHANNEL_OMNI); // Enable Soft Thru, everything at the input is sent back
        MIDI_DefaultInited = 1;
        DEBUG_SendText( Serial.print(millis());Serial.print(F(" MIDI.begin()")); )
      }
    }
  #endif
}}
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
     xod::awgrover__midi::midi_setup();
    
    if (isInputDirty<input_send>(ctx)) {
        auto channel = getValue<input_channel>(ctx);
        auto program_number = getValue<input_program_number>(ctx);
      	xod::awgrover__midi::MIDI.sendProgramChange(program_number, channel);
        emitValue<output_sent>(ctx,1);
        // only if xod "Debugger" is on
        DEBUG_SERIAL.print(millis());DEBUG_SERIAL.print(F(" "));
        DEBUG_SERIAL.print(F("Sent progchg/"));DEBUG_SERIAL.println(channel);
        DEBUG_SERIAL.print(F(" "));DEBUG_SERIAL.println(program_number);
    }
}