control-change

awgrover/x-midi/control-change

Set the inputs, send the control change on pulse ("send").
control-change
@/control-change
Set the inputs, send the control change on pulse ("send").
CCnumber
Controller Number
Valnumber
Controller Value
Chnumber
MIDI Channel
sendpulse
Send when triggered
control-change
CC
Val
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.println(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 controller_number = getValue<input_controller_number>(ctx);
      auto control_value = getValue<input_control_value>(ctx);
    	// note, velocity, channel
    	xod::awgrover__midi::MIDI.sendControlChange(controller_number, control_value, 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 CC/"));DEBUG_SERIAL.print(channel);
      DEBUG_SERIAL.print(F(" "));DEBUG_SERIAL.print(controller_number);
      DEBUG_SERIAL.print(F(" V "));DEBUG_SERIAL.println(control_value);
    }
}