MIDI USB Control Change not working

Hello, I am new to MIDI and I am trying to make wireless MIDI switches. I know that this code works for notes just fine, as I tested it with a keyboard, but I want to use Control Changes. I've used the "controlChange(byte channel, byte control, byte value)" function from the documents, but it seems whatever values I put in here, my different software and devices can't recognize them.

The "rd" value is being read from another microcontroller, and is either 1 or 2 depending on which button is pressed.

#include "MIDIUSB.h"
#include <Wire.h>

#define SLAVE_ADDR 9

int rd;


// The setup function runs once when you press reset or power the board
void setup() {

  Wire.begin(SLAVE_ADDR);
  Wire.onReceive(receiveEvent);
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("Starting");
}

// The loop function runs over and over again forever
void loop() {
}

void noteOn(byte pitch) {
  MidiUSB.sendMIDI({0x09, 0x90, pitch, 127});
  MidiUSB.flush();
}

void noteOff(byte pitch) {
  MidiUSB.sendMIDI({0x08, 0x80, pitch, 0});
  MidiUSB.flush();
}


void receiveEvent(){

  rd = Wire.read();
  Serial.println(rd);
  startMIDI(rd);

}

void startMIDI(int rd){
  byte value = rd + 20;
  Serial.println(value);
  controlChange(0x01,value, 0x7F);
  delay(2000);
  Serial.println("sound");
  /*
  noteOn(value);
  delay(2000);
  noteOff(value);
  */
}

void controlChange(byte channel, byte control, byte value) {

  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};

  MidiUSB.sendMIDI(event);
  MidiUSB.flush();
}

Have you enabled CC reception in your host ?

What is this all about? And why does to comment above it say

When clearly it does nothing of the sort.

This is because although while you have a controlChange function you never call it so you never send anything. Which is why nothing is ever received.

What host ever requires this to be enabled? This does not make sense.

Hi, thanks for the response.

Sorry, I removed that comment, it was there from something that used to be there.

The wire stuff is receiving input from another microcontroller. When it receives an event, the control change function gets called. I'm basically pushing one of two buttons, and depending on which one it is, it sends 1 or 2.

Looks like a conflict there.

Steve

Hi Steve,

Could you explain what you mean by that?

Thanks

The order of parameters in the function call and the function that you're calling usually matters.

Steve

Seriously, most DAW's have a Midi filter, and with some (like Ableton) only 'key' is enabled by default, allowing only for noteOn and noteOff. Remore and Sync need to be enabled manually.

That is so true . Mind you since both are in a 7-bit range, at least something should be coming in, though not what is intended.

I have not found this to be the case when I have used Ableton. If I want to assign a control message to a parameter all I need to do is to send the control parameter while the parameter is selected.

Screenshot (48)
By default the first (primary) device has 'track' enabled, but until you enable 'remote' the system you are talking about won't work.

Thank you so much!! Checked off remote in ableton and it works exactly how I want now!

Guess I just need to figure out how to change this setting in other apps now

Thanks everyone!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.