# Midi - Control Surface - NoteChordButton Syntax

**URL:** <https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852>\
**Category:** Programming\
**Created:** [January 17, 2025, 7:02pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852 "2025-01-17T19:02:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![insultcomicdog](https://avatars.discourse-cdn.com/v4/letter/i/e9bcb4/32.png) [@insultcomicdog](https://forum.arduino.cc/u/insultcomicdog)\
**Post date:** [January 17, 2025, 7:02pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/1 "2025-01-17T19:02:07Z")

</div>

I have a set of buttons on my custom midi controller (Arduino Pro Micro) that I would like to send different preset chords to my DAW.

I'm using the awesome Control Surface library.

I figured out the syntax for one NoteChordButton:

```arduino
NoteChordButton A1_But8 {mux_1.pin(12), {MIDI_Notes::C(4), CHANNEL_16}, Bass::Double + Chords::Major};

```

These are the chords I would like to play from a set of buttons:

E 9sus4  
C# min7 (4)  
C Maj7  
D 9sus4  
E 9sus4  
C# min7(4)  
C Maj7  
D 9sus4

Does anyone familiar with this library know the correct syntax to create NoteChordButtons for these chords? This might question requires more music theory than programming expertise, which is why I'm a bit lost.

@PieterP

---

<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:** [January 17, 2025, 7:17pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/2 "2025-01-17T19:17:37Z")

</div>

You can find the definitions of the built-in chords here:

> <https://github.com/tttapa/Control-Surface/blob/b8a30b4b7040ae1abf162fd0a258beaa2de43626/src/MIDI_Constants/Chords/Chords.hpp#L40-L59>

You can easily add your own chords in a similar fashion, e.g.

```cpp
namespace cs::Chords {

/// 9sus4 consists of major fourth, perfect fifth, minor seventh, and major ninth:
const Chord<4> Dominant9sus4 = {{M4, P5, m7, P8 + M2}};

}

```

---

<div class="post-metadata">

**Author:** ![insultcomicdog](https://avatars.discourse-cdn.com/v4/letter/i/e9bcb4/32.png) [@insultcomicdog](https://forum.arduino.cc/u/insultcomicdog)\
**Post date:** [January 20, 2025, 4:11pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/3 "2025-01-20T16:11:18Z")

</div>

> [@insultcomicdog](#):
>
> ```arduino
> , {MIDI_Notes::C(4), CHANNEL_16}, Bass::Double + Chords::Major};
> 
> ```

Thanks for the quick reply @PieterP

I let the Arduino IDE update my local copy of Control Surface library which seems to have broken my midi apps which use multiplexers.

```arduino
// Instantiate a multiplexer
CD74HC4067 mux_1{4, {6, 7, 8, 9} , }; //input, S0-S3, optional enable
CD74HC4067 mux_2{14, {6, 7, 8, 9} , }; //input, S0-S3, optional enable

// MIC BYPASS
//B1 Button
CCButton B2_But1 {mux_2.pin(2), {28, CHANNEL_16},};

```

This is the error I get when the compiler gets to the line creating the button:

> Compilation error: 'using CD74HC4067 = class CS::AH::AnalogMultiplex\<4\> {aka class CS::AH::AnalogMultiplex\<4\>}' has no member named 'pin'; did you mean 'pins'?

Is there a syntax change for creating buttons using pins from multiplexers?

I tried:

```arduino
CCButton B2_But1 {mux_2.digitalRead(2), {28, CHANNEL_16},}

```

Which silences error but I get this new error with this code block here:

```arduino
// // Instantiate a program changer with 9 programs
ProgramChanger<9> programChanger {
  {
    10, // Vox Robo 1
    11, // Vox Robo 2
    12, // Vox Robo 3
    13, // Single Drone
    14, // Major Drone
    15, // Minor Drone
    16, // Transpostion
    17, // Instrument CTRL
    18, // Reflex Tune
  },
  CHANNEL_16, // MIDI channel to use
};

//B1 Buttons 1 and 2

IncrementDecrementSelector<9> selector = {
    programChanger, // what to select
    {mux_2.digitalRead(0), mux_2.digitalRead(1)}, // push button pins (increment, decrement)
    Wrap::Wrap, // wrap around if min/max program is reached
}

```

Error :

"Compilation error: could not convert '{CS::programChanger, {CS::mux\_2.CS::AH::AnalogMultiplex\<4\>::digitalRead(0), CS::mux\_2.CS::AH::AnalogMultiplex\<4\>::digitalRead(1)}, Wrap}' from '' to 'CS::CS::IncrementDecrementSelector\<9\>'"

This is a good reminder to not let the IDE autoupdate my libs!

---

<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:** [January 20, 2025, 8:40pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/4 "2025-01-20T20:40:46Z")

</div>

> [@insultcomicdog](#):
>
> I let the Arduino IDE update my local copy of Control Surface library

I'm not sure how that's possible. The Control Surface library is not available from the library manager in the Arduino IDE (if it is, then that version was published by someone else).  
Where did you download Control Surface from? Which version do you have installed now?

The `pin` method of the multiplexers has existed since the very first release of the Control Surface library. There hasn't been a syntax change related to it. The fact that it's missing indicates that something's wrong with your Control Surface installation.

> [@insultcomicdog](#):
>
> I tried:
> 
> ```arduino
> CCButton B2_But1 {mux_2.digitalRead(2), {28, CHANNEL_16},}
> 
> ```
> 
> Which silences error

No, that can't work. The `digitalRead()` function reads the current value (high or low) of the pin, you cannot use it this way (the `CCButton` constructor accepts a pin number, not high/low, and you cannot use it before the multiplexer has been initialized during the `setup()`).

> [@](#):
>
> "Compilation error: could not convert '{CS::programChanger, {CS::mux\_2.CS::AH::AnalogMultiplex\<4\>::digitalRead(0), CS::mux\_2.CS::AH::AnalogMultiplex\<4\>::digitalRead(1)}, Wrap}' from '' to 'CS::CS::IncrementDecrementSelector\<9\>'"

Something is seriously wrong here: first of all, you seem to be using a version of Control Surface that's quite old (the namespace `CS` was renamed to `cs` in September ‘23), and there's some strange nesting of the namespaces going on (`CS::CS` shouldn't happen). Did you edit the library files by any chance? Maybe one of the closing `}` was somehow removed?

I'd recommend removing ~/Arduino/libraries/Control-Surface and downloading the latest version from GitHub again: [GitHub - tttapa/Control-Surface: Arduino library for creating MIDI controllers and other MIDI devices.](https://github.com/tttapa/Control-Surface)

---

<div class="post-metadata">

**Author:** ![insultcomicdog](https://avatars.discourse-cdn.com/v4/letter/i/e9bcb4/32.png) [@insultcomicdog](https://forum.arduino.cc/u/insultcomicdog)\
**Post date:** [January 20, 2025, 9:06pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/5 "2025-01-20T21:06:58Z")

</div>

@PieterP

Ok I tried removing the lib and dling fresh from github. All my errors are gone. Thank you!

I originally got the Control Surface lib from github, and last compiled successfully in May 2023.

My IDE updated a bunch of different installed libs since May, so if Control Surface isn't available by the package manager it must've gotten changed another way.

My only changes to the lib have been adding the custom chords, which I just discovered is what's throwing the pin error.

I was missing a '}' in my chord edit

Thanks again for you help.

---

<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:** [January 20, 2025, 9:18pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/6 "2025-01-20T21:18:01Z")

</div>

> [@insultcomicdog](#):
>
> My only changes to the lib have been adding the custom chords, which I just discovered is what's throwing the pin error.

There's no need to edit the library for that, you can just add the chords in your sketch.

---

<div class="post-metadata">

**Author:** ![insultcomicdog](https://avatars.discourse-cdn.com/v4/letter/i/e9bcb4/32.png) [@insultcomicdog](https://forum.arduino.cc/u/insultcomicdog)\
**Post date:** [January 27, 2025, 5:22pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/7 "2025-01-27T17:22:55Z")

</div>

I'm made some good progress with my custom chord buttons.

I stuck on this one modification, where I want to split the notes of a chord between two buttons.

The D minor seventh is a four-note chord D-F-A-C.

I want to play the 'D' with a NoteButton button and the rest of the chord 'F-A-C' with a NoteChordButton.

This is my chord minus the 'D':

```arduino
const Chord<3> Dmin7 = {{P1 + P5, P1 + m7, P1 + P8 + m3}};

```

And Buttons:

```arduino
NoteButton A1_But1 {mux_1.pin(0), {MIDI_Notes::D(4), CHANNEL_16}};
NoteChordButton A1_But5 {mux_1.pin(4), {MIDI_Notes::D(4), CHANNEL_16}, Chords::Dmin7};

```

What's happening is the NoteChordButton is playing all four notes of the chord instead of just 'F-A-C'.

Is there a way to achieve what I'm trying to do? @PieterP

---

<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:** [January 27, 2025, 5:52pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/8 "2025-01-27T17:52:01Z")

</div>

`NoteChordButton`s always play their base note\*. In this case, replacing the second button by an F major chord should achieve what you want:

```cpp
NoteButton A1_But1 {mux_1.pin(0), {MIDI_Notes::D[4], CHANNEL_16}};
NoteChordButton A1_But5 {mux_1.pin(4), {MIDI_Notes::F[4], CHANNEL_16}, Chords::Major};

```

(If you're using an old version of Control Surface, you should use `F_(4)` instead of `F[4]`.)

* * *

(\*) The ChordButton implementation is quite simple:

> <https://github.com/tttapa/Control-Surface/blob/b8a30b4b7040ae1abf162fd0a258beaa2de43626/src/MIDI_Outputs/Abstract/MIDIChordButton.hpp#L55-L57>

---

<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:** [July 26, 2025, 5:52pm UTC](https://forum.arduino.cc/t/midi-control-surface-notechordbutton-syntax/1343852/9 "2025-07-26T17:52:13Z")

</div>

Closed on July 26, 2025, 5:52pm UTC

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