MIDI controller - change CC address and channel on the fly?

Hi! Im using Control Surface by Pieter P (great library) and everything is well,
It has some pots that send CC messages, but wanted to be able to change the CC address and the midi channel on the fly, and don't know if it's possible after initializing CCPotentiometer.

Something like this but after initializing:

CCPotentiometer potentiometers[] = {
  {A0, {potCC[0], CHANNEL_1+ midiChannel-1}},
  {A1, {potCC[1], CHANNEL_1+ midiChannel-1}},
  {A2, {potCC[2], CHANNEL_1+ midiChannel-1}},
  {A3, {potCC[3], CHANNEL_1+ midiChannel-1}},
  {A6, {potCC[4], CHANNEL_1+ midiChannel-1}},
  {A7, {potCC[5], CHANNEL_1+ midiChannel-1}},
  {A8, {potCC[6], CHANNEL_1+ midiChannel-1}},
  {A9, {potCC[7], CHANNEL_1+ midiChannel-1}},
  {A10, {potCC[8], CHANNEL_1+ midiChannel-1}},
potCC[3] = 2 //CC address: 2
(...)
potCC[3] = 5 //CC address: 5
};

Thanks!!

Probably, but let's ask @PieterP . Also this is not quite the right section, sure with midi you can create audio, but i would put this in the 'programming' section or 'communication'

Thanks! I thought it was in the correct category as it says "Sound processing and generation, using WAV and MP3 players, using MIDI"

Anyways I worked it out!!
I used the hardware filtering example and the midi.sendCC function.

This library is great (well also the Arduino community) :smile:

(...)
FilteredAnalog<> potInput[potesCant] = {A0,A1,A2,A3,A6,A7, A8,A9,A10};


(...)

void setup() {
  FilteredAnalog<>::setupADC();
  (...)
  potAddress[0] = {100, CHANNEL_1+ midiChannel-1}; //100 here is the CC you want to send midi to
  potAddress[1] = {1, CHANNEL_1+ midiChannel-1};
  potAddress[2] = {2, CHANNEL_1+ midiChannel-1};
  potAddress[3] = {3, CHANNEL_1+ midiChannel-1};
  potAddress[4] = {4, CHANNEL_1+ midiChannel-1};
  potAddress[5] = {5, CHANNEL_1+ midiChannel-1};
  potAddress[6] = {6, CHANNEL_1+ midiChannel-1};
  potAddress[7] = {7, CHANNEL_1+ midiChannel-1};
  potAddress[8] = {8, CHANNEL_1+ midiChannel-1};
  potAddress[9] = {9, CHANNEL_1+ midiChannel-1};
}

void loop() {
  (...)
  static Timer<millis> timerPot = 1; // ms
  if (timerPot){
    for (int i= 0; i<potesCant; i++){
      if (potInput[i].update()){
        Serial.println(potInput[i].getValue());
        midiusb.sendCC(potAddress[i],potInput[i].getValue());
      }
    }
  }
}
1 Like

I don't have much time right now, but this should get you on the right track: https://tttapa.github.io/Control-Surface-doc/new-input/Doxygen/df/df5/md_pages_FAQ.html#faq-change-address-runtime

Thank you Pieter!
I think what you pointed me to is for a more previsible solution, like cycling different CC.
I am thinking of using arbitrary CC numbers that can be changed individually for different pots.

I might be wrong, anyways I was able to do it the other way.
But you are very kind :slight_smile:

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