Midi Control Change is not sent

Status
Not open for further replies.

zeol

New member
hi all,
In the past few days I was tinkering around with the teensy in order to build a slider controller for mixing application.
Everything was working fine, but was a bit wonky (analog read not averaged etc.) so I went ahead and fixed that.

For some reason, the teensy now wont send MIDI messages (as far as I can tell), but it still reaches the function where it should do so. It get's noticed as a MIDI device in all programs I've tried though!

Here are the relevant constructors:

Code:
elapsedMillis msec = 0;
int faderValues[6] = {0};                     // Array to store the read out fader positions
int faderValuesOld[6] = {0};                  // Array to store the old fader positions
int faderValuesAvg[6] = {0};                  // Array to store and calculate the average fader position
int faderValuesMap[6] = {0};                  // Array to store the average values, mapped between 0-127

  // Everything MIDI - CCs 20-31 are unused)
const int channel = 1;
const int faderCCi[6] = {20,21,22,23,24,25};
const int fader1CC = 20;    //don't Need These anymore since the Array is implemented. for compatibility only.
const int fader2CC = 21;
const int fader3CC = 22;
const int fader4CC = 23;
const int fader5CC = 24;
const int fader6CC = 25;

Here's the relevant Code:
Code:
//This function updates all fader values, maps them between 0-127 and stores them in the faderValues [Array]
void updateFaderValues(){
  for (int i = 5; i >= 0; i--){
    faderValues[i] = analogRead(inputPins[i]);                                                        // read new Values from faders
    faderValuesAvg[i] = (faderValuesAvg[i] + faderValues[i] + faderValuesOld[i]) / 3;                 
    faderValuesMap[i] = map(faderValuesAvg[i],0,1023,0,127);                                          // map(analogRead(inputPins[i]),0,1023,0,127);
  }
  return;
}

void updateMIDI(){
    // check if fader values changed
     if (faderValues != faderValuesOld) {
      for (int i = 5; i >= 0; i--){
        usbMIDI.sendControlChange(faderCCi[i], faderValuesMap[i], channel);
        //not needed usually, doesn't help with the problem either: usbMIDI.send_now();
        printDebug();
        faderValuesOld[i] = faderValues[i];
      }
    }
    msec = 0;
}

Here's my main loop, the display part is not so important.
Code:
void loop(void) {  
    if (msec >= 20) {updateFaderValues();}                                          // Read all fader positions and store into arrays
    if (msecDisplay >= 20) {                                                               // If this value is too small, Display will not update (depends on speed of calculation of all Parameters/arrays etc.)
      msecDisplay = 0;
      u8g2.clearBuffer();
      u8g2.firstPage();
  
      do {      // Check if new page is requested.... This is not relevant for Midi
        if ((debouncePagePlus.update() && debouncePagePlus.rose()) || (debouncePageMinus.update() && debouncePageMinus.rose())){
          if (debouncePagePlus.read()) {pagePlusState = 1;}
          if (debouncePageMinus.read()) {pageMinusState = 1;} 
          updateCurrentPage();
        }
                // ... then draw the contents
        drawPageContent(currentPage);                // Draw the currently selected set of parameters to the display  
      } while (u8g2.nextPage()); 
    }
    if(msec >= 20) {updateMIDI();}                  // calls the function above
   
    while (usbMIDI.read()){
      //ignore incoming messages
    }
}



I really don't get why it's not sending midi messages anymore (it did send them in an older version!), because it's running the printDebug(); :confused:

Here's the generated output of the printDebug() from the moment, the midi cc should change. Displayed are Fader-ADC read | Running Average of last 3 reads | average mapped between 0.127 | value before new read was done, Also how they change, when i move a fader
Code:
673 | 808 | 101 | 673
561 | 680 | 85 | 673




If you need more, let me know. :confused:
I'm actually frustrated it doesn't work slowly but surely. :( :(
 
The Rule is full code for a reason....

But if the debug is firing I can't see that the send CC wouldn't also. So how are you confirming no CC is being sent?
 
The Rule is full code for a reason....

But if the debug is firing I can't see that the send CC wouldn't also. So how are you confirming no CC is being sent?

My DAW didn't receive MIDI, some VSTs did not attach anything to MIDI Learn, but it was always shown as a MIDI device.
I actually got it working by following this procedure: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P7bZSAS

New and improved code here (works like a charm now!): https://pastebin.com/FyZCHsyy
 
Status
Not open for further replies.
Back
Top