Project Update
I have had success with an objective of using the steel strings of my electric guitar to feed in MIDI to the DAW over USB. Furthermore, with class-compliant MIDI, it means it should work on Apple
I do not actually own any Apples to test it on, but I hear that if it works on Apple -- it is a benefit to any resulting end product's communicability.
Video Demonstration
Please feel free to watch this brief video overview. There are still tweaks to be made to the software, and a housing to be added. I have all the parts and most of the code ready for the next post. I will also do some micro posts along the way in the next few days as general updates (for what otherwise would be regarded as full content posts).
LeoStick (ATmega32U4) Code
The code running on the LeoStick below, I used Arduino IDE 1.6.7 :
// PlectralEFFECTS // Include the Bounce2 library found here : // https://github.com/thomasfredericks/Bounce2 #include <Bounce2.h> #define BUTTON_PIN_1 0 #define BUTTON_PIN_2 1 #define LED_PIN 13 // Instantiate a Bounce object Bounce debouncer1 = Bounce(); Bounce debouncer2 = Bounce(); void noteOn(byte channel, byte pitch, byte velocity) { MIDIEvent noteOn = {0x09, 0x90 | channel, pitch, velocity}; MIDIUSB.write(noteOn); } void noteOff(byte channel, byte pitch, byte velocity) { MIDIEvent noteOff = {0x08, 0x80 | channel, pitch, velocity}; MIDIUSB.write(noteOff); } void controlChange(byte channel, byte control, byte value) { MIDIEvent event = {0x0B, 0xB0 | channel, control, value}; MIDIUSB.write(event); } bool value1state=false; bool value2state=false; void loop() { debouncer1.update(); debouncer2.update(); int value1 = debouncer1.read(); int value2 = debouncer2.read(); // Turn on the LED if either button is pressed : if ( value1 == LOW ) { digitalWrite(LED_PIN, HIGH ); if (!value1state) { noteOn(0, 48, 64); // Channel 0, middle C, normal velocity MIDIUSB.flush(); value1state=true; } } else { digitalWrite(LED_PIN, LOW ); if (value1state) { noteOff(0, 48, 64); // Channel 0, middle C, normal velocity MIDIUSB.flush(); value1state=false; } } if ( value2 == LOW ) { digitalWrite(LED_PIN, HIGH ); if (!value2state) { noteOn(0, 50, 64); // Channel 0, middle D, normal velocity MIDIUSB.flush(); value2state=true; } } else { digitalWrite(LED_PIN, LOW ); if (value2state) { noteOff(0, 50, 64); // Channel 0, middle D, normal velocity MIDIUSB.flush(); value2state=false; } } // controlChange(0, 10, 65); // Set the value of controller 10 on channel 0 to 65 } void setup() { // Setup the first button with an internal pull-up : pinMode(BUTTON_PIN_1,INPUT_PULLUP); debouncer1.attach(BUTTON_PIN_1); debouncer1.interval(5); // interval in ms // Setup the second button with an internal pull-up : pinMode(BUTTON_PIN_2,INPUT_PULLUP); debouncer2.attach(BUTTON_PIN_2); debouncer2.interval(5); // interval in ms //Setup the LED : pinMode(LED_PIN,OUTPUT); }