Control Surface  1.1.1
MIDI Control Surface library for Arduino
Transposer.ino

Transposer

This is an example that demonstrates the use a Transposer to transpose the note events sent out by NoteButtons.

Boards:
AVR, AVR USB, Due, Nano 33, Teensy 3.x, ESP32

Connections

The internal pull-up resistor for the buttons will be enabled automatically.

Behavior

Mapping

Route the Arduino MIDI port into a synth to play the notes.

Written by PieterP, 2019-10-26
https://github.com/tttapa/Control-Surface

#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface.
using namespace MIDI_Notes;
// Instantiate a Transposer that can transpose from one octave down to one
// octave up
Transposer<-12, +12> transposer;
// Instantiate a Selector to change the transposition
IncrementDecrementSelector<transposer.getNumberOfBanks()> selector = {
transposer,
{10, 11},
};
// Instantiate an array of NoteButton objects
Bankable::NoteButton buttons[] = {
{transposer, 2, note(C, 4)}, {transposer, 3, note(D, 4)},
{transposer, 4, note(E, 4)}, {transposer, 5, note(F, 4)},
{transposer, 6, note(G, 4)}, {transposer, 7, note(A, 4)},
{transposer, 8, note(B, 4)}, {transposer, 9, note(C, 5)},
};
void setup() {
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}
USBMIDI_Interface
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
Definition: USBMIDI_Interface.hpp:35
MIDI_Notes::D
constexpr int8_t D
Definition: Notes.hpp:20
Bankable::NoteButton
A class of MIDIOutputElements that read the input of a momentary push button or switch,...
Definition: Bankable/NoteButton.hpp:22
MIDI_Notes::G
constexpr int8_t G
Definition: Notes.hpp:25
MIDI_Notes::A
constexpr int8_t A
Definition: Notes.hpp:27
Transposer
Definition: Transposer.hpp:10
IncrementDecrementSelector
Selector with two buttons (one to increment, one to decrement).
Definition: IncrementDecrementSelector.hpp:66
Control_Surface.h
The main header file that includes all Control-Surface header files.
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:48
Bank::getNumberOfBanks
constexpr static uint8_t getNumberOfBanks()
Get the number of Banks.
Definition: Bank.hpp:107
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:176
MIDI_Notes::note
constexpr int8_t note(int8_t note, int8_t numOctave)
Get the MIDI note in the given octave.
Definition: Notes.hpp:35
MIDI_Notes::B
constexpr int8_t B
Definition: Notes.hpp:29
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23
MIDI_Notes::E
constexpr int8_t E
Definition: Notes.hpp:22
Wrap::Clamp
When the maximum (minimum) setting is reached, clamp to the maximum (minimum) setting.
MIDI_Notes
MIDI note names.
Definition: Notes.hpp:16
MIDI_Notes::C
constexpr int8_t C
Definition: Notes.hpp:18
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25