# Control\_surface library banks with non sequential values

**URL:** <https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406>\
**Category:** Programming\
**Created:** [November 7, 2024, 1:59am UTC](https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406 "2024-11-07T01:59:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![morgankelsey](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@morgankelsey](https://forum.arduino.cc/u/morgankelsey)\
**Post date:** [November 7, 2024, 1:59am UTC](https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406/1 "2024-11-07T01:59:26Z")

</div>

Hi, I am making a 4 button foot controller, with two banks. I would like to:

- assign a non linear list of note numbers to each bank
- set the midi channel for those notes
- assign a random velocity to each note

This code works, but I can't figure out how to assign the midi channel:

```arduino
#include <Control_Surface.h> // Include the Control Surface library

USBMIDI_Interface midi;

const int NoteVals1 [] {
  55,
  51,
  49,
  47,
};

const int NoteVals2 [] {
  59,
  52,
  48,
  42,
};

// Instantiate 2 Banks
Bank<2> bank;
// Instantiate a Bank selector to control which one of the three Banks is active.
IncrementDecrementSelector<2> selector = {
    bank, // Bank to manage
    {15, 14}, // push button pins (increment, decrement)
    Wrap::Clamp, // No Wrap 
};

Bankable::ManyAddresses::NoteButton<2> myMultiFunctionNoteButton1 = {
  bank,
  6, // input pin 
  {
    NoteVals1[0], // Controller Nº to use when 1st bank is selected
    NoteVals2[0], // Controller Nº to use when 2nd bank is selected
  },
};

Bankable::ManyAddresses::NoteButton<2> myMultiFunctionNoteButton2 = {
  bank,
  7, // input pin 
  {
    NoteVals1[1], 
    NoteVals2[1], 
  },
};
Bankable::ManyAddresses::NoteButton<2> myMultiFunctionNoteButton3 = {
  bank,
  8, // input pin 
  {
    NoteVals1[2],    
    NoteVals2[2], 
  },
};
Bankable::ManyAddresses::NoteButton<2> myMultiFunctionNoteButton4 = {
  bank,
  9, // input pin 
  {
    NoteVals1[3],      
    NoteVals2[3],     
  },
};

void setup() { 
  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  Control_Surface.loop(); // Update the Control Surface
}

```

As far as assigning random velocities, I had this code working before I introduced ManyAddresses:

```arduino
int rand1;

void setup() { 
  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  
  for (int i = 0; i < 4; i++) {
    rand1 = random(80,115);
    footButtons[i].setVelocity(rand1);
  }
  
  Control_Surface.loop(); // Update the Control Surface
}

```

But I can't figure out the syntax for assigning setVelocity() to items when ManyAddresses is used. Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![PieterP](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@PieterP](https://forum.arduino.cc/u/PieterP)\
**Post date:** [November 9, 2024, 6:21pm UTC](https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406/2 "2024-11-09T18:21:28Z")

</div>

> [@morgankelsey](#):
>
> set the midi channel for those notes

You can pass the full MIDI address to the NoteButton constructor, e.g. `{55, Channel_1}`. See [https://tttapa.github.io/Control-Surface/Doxygen/d3/df7/midi-tutorial.html#midi\_md-midi-addresses](https://tttapa.github.io/Control-Surface/Doxygen/d3/df7/midi-tutorial.html#midi_md-midi-addresses) for details.

> [@morgankelsey](#):
>
> But I can't figure out the syntax for assigning setVelocity() to items when ManyAddresses is used. Any help is appreciated!

In older versions of Control Surface, you can use `footButtons[i].sender.setVelocity(rand1)`. If you upgrade to [`77ab308`](https://github.com/tttapa/Control-Surface/commit/77ab308d29ce7283369eb2a08ccbc038da378b5a), you can leave out the `.sender`.

---

<div class="post-metadata">

**Author:** ![morgankelsey](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@morgankelsey](https://forum.arduino.cc/u/morgankelsey)\
**Post date:** [November 9, 2024, 7:49pm UTC](https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406/3 "2024-11-09T19:49:43Z")

</div>

Thanks @PieterP

The full MIDI address isn't working for me for some reason.

This simple example works fine:

```arduino
#include <Control_Surface.h> // Include the Control Surface library

USBMIDI_Interface midi;

// Instantiate 2 Banks
Bank<2> bank;
// Instantiate a Bank selector to control which one of the three Banks is active.
IncrementDecrementSelector<2> selector = {
  bank, // Bank to manage
  {15, 14}, // push button pins (increment, decrement)
  Wrap::Clamp, // No Wrap 
};

Bankable::ManyAddresses::NoteButton<2> footButton1 = {
  bank, 6, {55, 59}
};

void setup() { 
  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  Control_Surface.loop(); // Update the Control Surface
}

```

If I try passing the full MIDI address it errors:

```arduino
Bankable::ManyAddresses::NoteButton<2> footButton1 = {
  bank, 6, {{55, Channel_15}, {59, Channel_15}}
};

```

the error I get is:

Compilation error: could not convert '{bank, 6, {{55, cs::Channel\_15}, {59, cs::Channel\_15}}}' from '' to 'cs::Bankable::ManyAddresses::NoteButton\<2\>'

---

<div class="post-metadata">

**Author:** ![PieterP](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@PieterP](https://forum.arduino.cc/u/PieterP)\
**Post date:** [November 9, 2024, 8:02pm UTC](https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406/4 "2024-11-09T20:02:04Z")

</div>

You'll need another pair of braces:

```cpp
Bankable::ManyAddresses::NoteButton<2> footButton1 {
  bank, 6, {{{55, Channel_15}, {59, Channel_15}}}
};

```

---

<div class="post-metadata">

**Author:** ![morgankelsey](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@morgankelsey](https://forum.arduino.cc/u/morgankelsey)\
**Post date:** [November 9, 2024, 8:31pm UTC](https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406/5 "2024-11-09T20:31:49Z")

</div>

Thanks so much, @PieterP !

Also got setVelocity() working properly.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 8, 2025, 8:32pm UTC](https://forum.arduino.cc/t/control-surface-library-banks-with-non-sequential-values/1319406/6 "2025-05-08T20:32:09Z")

</div>

Closed on May 8, 2025, 8:32pm UTC

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