/** 
 * This is an example that demonstrates the use of MIDI Note Buttons that can be
 * used for triggering samples, mute/solo/rec buttons, play/pause/stop buttons, 
 * etc. It can control almost any push button control in your DAW software.
 *
 * @boards  AVR, AVR USB, Nano Every, Due, Nano 33 IoT, Nano 33 BLE, Pi Pico, Teensy 3.x, ESP32, ESP8266
 * 
 * Connections
 * -----------
 * 
 * - 5: momentary push button (to ground)
 * 
 * The internal pull-up resistor for the button will be enabled automatically.
 * 
 * Behavior
 * --------
 * 
 * - When the button on pin 5 is pressed, a MIDI Note On message is sent for
 *   note C4.
 * - When the button on pin 5 is released, a MIDI Note Off message is sent for 
 *   note C4.
 * 
 * Mapping
 * -------
 * 
 * Select the Arduino as a custom MIDI controller in your DAW, and use the 
 * MIDI learn option to assign the button to a function.
 * 
 * Written by PieterP, 2019-08-07  
 * https://github.com/tttapa/Control-Surface
 */

#include <Control_Surface.h> // Include the Control Surface library

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;

// Instantiate a NoteButton object
NoteButton button_1 {
  3,                       // Push button on pin 5
  {MIDI_Notes::C(4), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_2 {
  4,                       // Push button on pin 5
  {MIDI_Notes::D(4), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_3 {
  5,                       // Push button on pin 5
  {MIDI_Notes::E(4), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_4 {
  6  ,                       // Push button on pin 5
  {MIDI_Notes::G(2), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_5 {
  7  ,                       // Push button on pin 5
  {MIDI_Notes::G(4), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_6 {
  8  ,                       // Push button on pin 5
  {MIDI_Notes::A(4), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_7 {
  9  ,                       // Push button on pin 5
  {MIDI_Notes::B(4), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_8 {
  10  ,                       // Push button on pin 5
  {MIDI_Notes::C(5), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_9 {
  11  ,                       // Push button on pin 5
  {MIDI_Notes::D(5), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_10 {
  12  ,                       // Push button on pin 5
  {MIDI_Notes::E(5), CHANNEL_1}, // Note C4 on MIDI channel 1
};
NoteButton button_11 {
  13  ,                       // Push button on pin 5
  {MIDI_Notes::C(3), CHANNEL_1}, // Note C4 on MIDI channel 1
};

void setup() {
  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  Control_Surface.loop(); // Update the Control Surface
}
