Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Midi Control Change is not sent

  1. #1
    Junior Member
    Join Date
    Jun 2019

    Midi Control Change is not sent

    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:

    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:
    //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);
    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();
            faderValuesOld[i] = faderValues[i];
        msec = 0;
    Here's my main loop, the display part is not so important.
    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;
          do {      // Check if new page is requested.... This is not relevant for Midi
            if ((debouncePagePlus.update() && debouncePagePlus.rose()) || (debouncePageMinus.update() && debouncePageMinus.rose())){
              if ( {pagePlusState = 1;}
              if ( {pageMinusState = 1;} 
                    // ... 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 ({
          //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();

    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
    673 | 808 | 101 | 673
    561 | 680 | 85 | 673

    If you need more, let me know.
    I'm actually frustrated it doesn't work slowly but surely.

  2. #2
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Isle in the Salish Sea
    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?

  3. #3
    Junior Member
    Join Date
    Jun 2019
    Quote Originally Posted by oddson View Post
    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:

    New and improved code here (works like a charm now!):

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts