// *************************************************************** // * Behringer XR18 Arduino MIDI Remote Control * // * By Vern Graner * // *************************************************************** // * This code connects to WiFI and sends OSC commands to an * // * Behringer XR18. You have to enter an IP address for the * // * mixer for this demo to work * // *************************************************************** // * Rev Info: V1.0a (VLG) 01-22-2018 Basic proof of concept * // * : V3.2a (VLG) 01-27-2018 CH1&2 mute, FOH/HOSTS PTT * // * : V3.2a (VLG) 01-27-2018 PROTOTYPE1 NO OLED * // * : V3.5a (VLG) 01-28-2018 Use array for OSC commands * // * : V3.5b (VLG) 02-06-2018 Cough Box V1 * // * : V3.5C (VLG) 03-07-2018 Tasked #4 button for FX * // *************************************************************** // Include the button library // http://www.michael.net.nz #include // Include the WiFi library // https://www.arduino.cc/en/Reference/WiFi #include // For WiFi #include // For WiFi // Include the OSC message handler // https://github.com/CNMAT/OSC #include // For OSC support // Include the MIDI stuff // https://github.com/FortySevenEffects/arduino_midi_library #include // MIDI support #include #include #include #include // Assign Button Functions // *************************************************** // define button arrays Format is "","", const char* button1Command[]={ "/ch/01/mix/on","OFF", // Button 1 Payload 0: Ch 1 UN-MUTE "/ch/01/mix/on","ON" // Button 1 Payload 1: Ch 1 MUTE }; const char* button2Command[]={ "/ch/02/mix/on","OFF", // Button 2 Payload 0: Ch 2 UN-MUTE "/ch/02/mix/on","ON" // Button 2 Payload 1: Ch 2 MUTE }; const char* button3Command[]={ "/ch/03/mix/on","OFF", // Button 3 Payload 0: Ch 3 UN-MUTE "/ch/03/mix/on","ON" // Button 3 Payload 1: Ch 3 MUTE }; const char* button4Command[]={ // "/ch/04/mix/on","OFF", // Button 4 Payload 0: Ch 4 UN-MUTE // "/ch/04/mix/on","ON" // Button 4 Payload 1: Ch 4 MUTE "/ch/02/mix/09/level","0", // Button 4 Payload 0: Ch 2 FX3 send ON "/ch/02/mix/09/level","-127", // Button 4 Payload 1: Ch 2 FX3 send OFF }; // WiFi setup char ssid[] = "YOUR-AP-NAME"; // your network SSID (name) char pass[] = "YOUR-AP-PASSWORD"; // your network password WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP // const IPAddress outIp(192,168,100,6); // IP of the XR18 in Comma Separated Octets, NOT dots! const IPAddress outIp(192,168,1,15); // IP of the XR18 in Comma Separated Octets, NOT dots! const unsigned int outPort = 10024; // remote port to receive OSC X-AIR is 10024, X32 is 10023 const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending) // Pin combos for Cough Drop Box // Button/LED pin combos Button 0 15/25 // Button/LED pin combos Button 1 27/34 // Button/LED pin combos Button 0 32/39 // Button/LED pin combos Button 3 33/26 // Setup LED pins int ledPin[]={15,27,32,33}; // define the pins for the LEDs COUGH DROP // int ledPin[]={23,22,14,32}; // define the pins for the LEDs on BREADBOARD int ledCount=4; // set the number of LEDs in the loop int ledState[] = {0,0,0,0}; // current state of the button int led[] = {0,0,0,0}; // current state of the button #define OFF 0 // Friendly names for LED states #define ON 1 // Friendly names for LED states #define BLINK 2 // Friendly names for LED states // Setup button pins int myButtons[] = {25,34,39,26}; // define the pins for the buttons on COUGH DROP // int myButtons[] = {16,19,18,5,4}; // define the pins for the buttons on breadboard int buttonCount = 5; // set the number of buttons in the loop // Assign pins for button handler routine COUGH DROP Button button1(25); // Mic 1 Button button2(34); // Mic 2 Button button3(39); // Mic 3 Button button4(26); // Mic 4 Button button5(36); // LOCK switch // Assign pins for button handler routine BREADBOARD // Button button1(16); // Mic 1 // Button button2(19); // Mic 2 // Button button3(18); // Mic 3 // Button button4(5); // Mic 4 // Button button5(4); // LOCK switch // LED handler for ON, OFF and BLINK #define OFF 0 #define ON 1 #define BLINK 2 unsigned long previousMillis = 0; // for non-blocking LED blink routine const long interval = 150; // how fast the LED blinks int ledBlink=0; // variable for blink routine // Button Toggle Routine bool setToToggle=true; // set default toggle state int toggleFlag1=0; // flag for toggle state int toggleFlag2=0; // flag for toggle state int toggleFlag3=0; // flag for toggle state int toggleFlag4=0; // flag for toggle state // Button & LED Pair pin numbers: // Button0 = 15, LED0 = 25 // Button1 = 27, LED0 = 34 // Button2 = 32, LED0 = 39 // Button3 = 33, LED0 = 26 // Setup button type int buttonToggle[] = {0,0,0,0}; // "0" is for follow state 1 is for toggle state // Define program Variables int buttonState[] = {0,0,0,0}; // current state of the button int lastButtonState[] = {0,0,0,0}; // previous state of the button // MIDI OSC Hex converter int commandLength=0; byte bigMidiCommand[64]; // maximum command length in bytes byte midiHeader[]= { 0xF0,0x00,0x20,0x32,0x32 }; // XR18 OSC preamble byte midiSpacer[]= { 0x20 }; // XR18 OSC post-amble byte midiFooter[]= { 0xF7 }; // XR18 OSC post-amble // Counter variables int count; // Command Counter int i=0; // Button counter int j=0; // bigMIDIcommand counter int WiFiWait=0; // Wait Counter // Setup MIDI hardware HardwareSerial Serial1(2); // setup MIDI on TX pin MIDI_CREATE_INSTANCE(HardwareSerial,Serial1, midiOut); // create a MIDI object called midiOut void setup() { // Start Button Handler button1.begin(); // Mic 1 button2.begin(); // Mic 2 button3.begin(); // Mic 3 button4.begin(); // Mic 4 button5.begin(); // Lock Switch // Setup Serial Out Serial.begin(115200); // DEBUG window Serial1.begin(31250); // setup MIDI output midiOut.begin(); //Setup pin mode for buttons for (int i=0;i= interval) // Check to see if we need to change LED state { // previousMillis = currentMillis; // save the last time you blinked the LED if (ledBlink == 0) // if the LED is off turn it on and vice-versa: { // ledBlink = 1; // } else { // ledBlink = 0; // } // } for (int i=0; i