This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
MIDI-Controller-Finished-Example.ino

MIDI-Controller-Finished-Example

This is the code I used for my specific MIDI controller.

Boards:
Leonardo

Connections

I used an Arduino Leonardo with:

Behavior

Mapping

Create a custom mapping using the MIDI learn option in your DAW.

Written by PieterP, 07-09-2017 https://github.com/tttapa/Control-Surface

#include <Encoder.h>
// Encoder has to be included before Control_Surface
// If the jog wheels or other encoders are too slow in your software, increase
// this value.
// (It will be multiplied with the actual speed of the encoder, as the name
// implies.) Default is 1.
const int speedMultiplier = 1;
Bank<2> bank(4); // A bank with four channels, and 2 bank settings
};
CCPotentiometer knobsTop[] = {
};
};
};
{1, 0}, // pins
speedMultiplier, // multiplier
4, // pulses per click
};
SwitchSelector selector = {bank, 11};
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() { // Refresh all inputs
digitalWrite(LED_BUILTIN, digitalRead(11));
}
USBMIDI_Interface
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
Definition: USBMIDI_Interface.hpp:43
Bank
A class that groups Bankable BankableMIDIOutputs and BankableMIDIInputs, and allows the user to chang...
Definition: Bank.hpp:77
MCU::MUTE_3
constexpr uint8_t MUTE_3
Definition: MCU.hpp:38
ExtIO::pinMode
void pinMode(pin_t pin, uint8_t mode)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:34
CHANNEL_3
constexpr Channel CHANNEL_3
Definition: Channel.hpp:113
MCU::MUTE_2
constexpr uint8_t MUTE_2
Definition: MCU.hpp:37
Bankable::NoteButtonLatching
A class of MIDIOutputElements that read the input of a latching push button or toggle switch,...
Definition: Bankable/NoteButtonLatching.hpp:22
MIDI_CC::General_Purpose_Controller_4
constexpr uint8_t General_Purpose_Controller_4
Definition: Control_Change.hpp:35
MIDI_CC::General_Purpose_Controller_2
constexpr uint8_t General_Purpose_Controller_2
Definition: Control_Change.hpp:33
Control_Surface.h
The main header file that includes all Control-Surface header files.
Bankable::CCPotentiometer
A class of MIDIOutputElements that read the analog input from a potentiometer or fader,...
Definition: Bankable/CCPotentiometer.hpp:22
ExtIO::digitalWrite
void digitalWrite(pin_t pin, uint8_t val)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:45
MCU::MUTE_1
constexpr uint8_t MUTE_1
Definition: MCU.hpp:36
MIDI_CC::General_Purpose_Controller_3
constexpr uint8_t General_Purpose_Controller_3
Definition: Control_Change.hpp:34
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:171
CHANGE_CHANNEL
Change the offset of the channel number of the element.
Definition: BankConfig.hpp:21
CHANNEL_4
constexpr Channel CHANNEL_4
Definition: Channel.hpp:114
SwitchSelector
Selector that selects one of two settings, based on the state of a toggle or momentary switch.
Definition: SwitchSelector.hpp:51
CCRotaryEncoder
A class of MIDIOutputElements that read the input of a quadrature (rotary) encoder and send out relat...
Definition: CCRotaryEncoder.hpp:21
CCPotentiometer
A class of MIDIOutputElements that read the analog input from a potentiometer or fader,...
Definition: CCPotentiometer.hpp:19
MIDI_CC::General_Purpose_Controller_1
constexpr uint8_t General_Purpose_Controller_1
Definition: Control_Change.hpp:32
ExtIO::digitalRead
int digitalRead(pin_t pin)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:56
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:22
CHANNEL_2
constexpr Channel CHANNEL_2
Definition: Channel.hpp:112
CHANGE_ADDRESS
Change the offset of the address (i.e.
Definition: BankConfig.hpp:17
OUTPUT
const uint8_t OUTPUT
Definition: ExtendedInputOutput.hpp:38
MIDI_CC::Pan
constexpr uint8_t Pan
Definition: Control_Change.hpp:26
MIDI_CC::Channel_Volume
constexpr uint8_t Channel_Volume
Definition: Control_Change.hpp:23
CHANNEL_1
constexpr Channel CHANNEL_1
Definition: Channel.hpp:111
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:45
MCU::MUTE_4
constexpr uint8_t MUTE_4
Definition: MCU.hpp:39
MIDI_CC::General_Purpose_Controller_5
constexpr uint8_t General_Purpose_Controller_5
Definition: Control_Change.hpp:78