Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
NoteChordButton.ino

NoteChordButton

This is an example of the NoteChordButton class of the Control_Surface library.

Boards: 🛈
AVR, AVR USB, Nano Every, Due, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Teensy 3.x, ESP32, ESP8266

Connect 7 momentary push buttons between pins 2-8 and ground. These will play chords when pressed.

Connect a rotary encoder to pins 0 & 1. This will transpose the MIDI chords.

Written by Pieter P, 15-04-2019
https://github.com/tttapa/Control-Surface

#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI interface to use for the Control Surface.
constexpr Channel channel = Channel_1; // MIDI channel to send to
// Instantiate a transposer that transposes from -12 semitones to +12 semitones.
Transposer<-12, +12> transp;
// Instantiate an encoder selector with the encoder wired to pins 0 and 1
// with 4 pulses per step, without wrapping.
EncoderSelector<transp.N> sel = {transp, {0, 1}, 4, Wrap::NoWrap};
// Major C chord in 4th octave, button between pin 2 and ground
{transp, 2, {MIDI_Notes::C[4], channel}, Bass::Double + Chords::Major},
{transp, 3, {MIDI_Notes::D[4], channel}, Bass::Double + Chords::Minor},
{transp, 4, {MIDI_Notes::E[4], channel}, Bass::Double + Chords::Minor},
{transp, 5, {MIDI_Notes::F[4], channel}, Bass::Double + Chords::MajorFirstInv},
{transp, 6, {MIDI_Notes::G[4], channel}, Bass::Double + Chords::MajorSecondInv},
{transp, 7, {MIDI_Notes::A[4], channel}, Bass::Double + Chords::MinorSecondInv},
{transp, 8, {MIDI_Notes::B[4], channel}, Bass::Double + Chords::Diminished},
};
/*
You can also use the non-bankable version without the transposer.
NoteChordButton buttons[] = {
// Major C chord in 4th octave, button between pin 2 and ground
{2, {MIDI_Notes::C[4], channel}, Bass::Double + Chords::Major},
{3, {MIDI_Notes::D[4], channel}, Bass::Double + Chords::Minor},
{4, {MIDI_Notes::E[4], channel}, Bass::Double + Chords::Minor},
{5, {MIDI_Notes::F[4], channel}, Bass::Double + Chords::MajorFirstInv},
{6, {MIDI_Notes::G[4], channel}, Bass::Double + Chords::MajorSecondInv},
{7, {MIDI_Notes::A[4], channel}, Bass::Double + Chords::MinorSecondInv},
{8, {MIDI_Notes::B[4], channel}, Bass::Double + Chords::Diminished},
};
*/
/*
* You can change the chords afterwards using
* buttons[0].setChord(Chords::MajorSeventh);
* for example.
*/
void setup() {
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update all elements
}
constexpr Channel Channel_1
Definition Channel.hpp:118
The main header file that includes all Control-Surface header files.
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
@ NoWrap
A class of MIDIOutputElements that read the input of a momentary push button or switch,...
A type-safe class for MIDI channels.
Definition Channel.hpp:13
void begin()
Initialize the Control_Surface.
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Selector that reads from a rotary encoder.
Class for transposing the address of NoteButton and other MIDI elements.
static constexpr setting_t N
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
const Chord< 2 > Double
Definition Chords.hpp:67
const Chord< 2 > MajorSecondInv
Definition Chords.hpp:47
const Chord< 2 > MajorFirstInv
Definition Chords.hpp:46
const Chord< 2 > MinorSecondInv
Definition Chords.hpp:51
const Chord< 2 > Minor
Definition Chords.hpp:49
const Chord< 2 > Major
Definition Chords.hpp:45
const Chord< 2 > Diminished
Definition Chords.hpp:53
constexpr Note F
F (Fa)
Definition Notes.hpp:61
constexpr Note G
G (Sol)
Definition Notes.hpp:63
constexpr Note E
E (Mi)
Definition Notes.hpp:60
constexpr Note B
B (Si)
Definition Notes.hpp:67
constexpr Note A
A (La)
Definition Notes.hpp:65
constexpr Note C
C (Do)
Definition Notes.hpp:56
constexpr Note D
D (Re)
Definition Notes.hpp:58