Hello all. I'm a guitar player and some time ago, I built myself a MIDI controller with a Leonardo which has 8 toggle switches and 1 expression pedal which sends CC commands to the vst's I use to turn on/off the effects, etc and works thru USB.
Recently, I've gotten a Boss GT-10 guitar processor, which has MIDI IN&OUT ports, and I want to utilize this functionality to expand my control over the unit during live play. I plan to connect a MIDI Out to this switchboard and send the MIDI signals via the TX pin to this processor.
However, when I power the board up without a PC, it just turns on, and I see no signal output. I think I need to tinker the code I use, but I don't know how to proceed actually. It would be great to be able to use this switchboard both via USB and MIDI.
The code I currently use is as below, I just found it on the web and increased the switch quantity & set the pot. range to my need, that's all. I think it belongs to PieterP and as I checked, what I intend to do is somehow achievable by Dual-MIDI-Interface but some assistance over the below code would be great. It'd be also good if its possible to add some LED on-off indicators, but the switches I use have only 2 lugs, so I don't know if it'd be possible for LEDs to sync the real on-off positions of the switches.
#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface
USBMIDI_Interface midi;
// Instantiate an array of latched push buttons that send MIDI CC messages
// when pressed.
CCButtonLatched buttons[] {
{ 2, 0x10 },
// โ โโโโโ MIDI CC controller number
// โโโโโโโโโโ Button pin number
{ 3, 0x11 },
{ 4, 0x12 },
{ 5, 0x13 },
{ 6, 0x14 },
{ 7, 0x15 },
{ 8, 0x16 },
{ 9, 0x19 },
};
// Setup for an Analog pot for an EXP pedal on cc #11
CCPotentiometer potentiometer = {
A0, {MIDI_CC::Expression_Controller, CHANNEL_1}
};
// The filtered value read when potentiometer is at the 0% position
constexpr analog_t minimumValue = 10550;
// The filtered value read when potentiometer is at the 100% position
constexpr analog_t maximumValue = 14550;
// A mapping function to eliminate the dead zones of the potentiometer:
// Some potentiometers don't output a perfect zero signal when you move them to
// the zero position, they will still output a value of 1 or 2, and the same
// goes for the maximum position.
analog_t mappingFunction(analog_t raw) {
// make sure that the analog value is between the minimum and maximum
raw = constrain(raw, minimumValue, maximumValue);
// map the value from [minimumValue, maximumValue] to [0, 16383]
return map(raw, minimumValue, maximumValue, 0, 16383);
// Note: 16383 = 2ยนโด - 1 (the maximum value that can be represented by
// a 14-bit unsigned number
}
void setup() {
potentiometer.map(mappingFunction);
Control_Surface.begin(); // Initialize the Control Surface
Serial.begin(31250);
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
//Serial.println
(potentiometer.getRawValue());
}