Hi Everyone!
I'm trying to fabricate a custom MIDI controller for an Ipad App to control stage lights
with the help of the Control Surface library but I don't know much about programming.
The controller is made of a keyboard with 29 mechanical keys, 29 SK6812 leds to light up the keys and 3 rotary encoders, plugged into a Pi Pico.
What I'd like to obtain is quiet simple :
- every led is lit to the same color/brightness when idle ;
- each press of a key sends a note to be mapped to a corresponding button in the app and flashes the led to a defined color/brightness as long as the key is pressed ;
- rotary encoders are independents and will be mapped to a generic function (Master, scroll..). Later I'd love to had rotary encoders with push buttons so that a press of the rotary will switch between two different speed multiplier (like a coarse/fine function).
Here is a picture of the schematic :
I have started a bit of coding with all the info I could find but with my noob experience I am quickly lost.
Here's what I tried :
#include <FastLED.h>
// Must be before Control Surface to enable FastLED features of Control Surface
#include <Control_Surface.h>
USBMIDI_Interface midi; // Starts a USB MIDI Instance
/////////////////////////////// Keyboard Matrix
// The note numbers corresponding to the buttons in the matrix
const AddressMatrix<5, 6> addresses {{
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20},
{21, 22, 23, 24, 25},
{26, 27, 28, 29, 30},
}};
NoteButtonMatrix<5, 6> buttonmatrix {
{27, 26, 25, 24, 22}, // row pins
{1, 2, 4, 5, 6, 7}, // column pins
addresses, // address matrix
Channel_1, // channel and cable number
};
/////////////////////////////// Rotary Encoders
// Instantiate a CCRotaryEncoder object
CCRotaryEncoder enc {
{9, 10}, // pins
MIDI_CC::General_Purpose_Controller_2, // MIDI address (CC number + optional channel)
1, // optional multiplier if the control isn't fast enough
};
CCRotaryEncoder enc {
{11, 12}, // pins
MIDI_CC::General_Purpose_Controller_3, // MIDI address (CC number + optional channel)
1, // optional multiplier if the control isn't fast enough
};
CCRotaryEncoder enc {
{31, 32}, // pins
MIDI_CC::General_Purpose_Controller_1, // MIDI address (CC number + optional channel)
1, // optional multiplier if the control isn't fast enough
};
/////////////////////////////// LED
// Define the array of leds.
Array<CRGB, 29> leds {};
// The data pin with the strip connected.
constexpr uint8_t ledpin = 21;
// Create a MIDI input element that listens to all notes in the range C4 - G4
// (the range starts at C4 and has a length equal to `leds.length` == 8).
NoteRangeFastLED<leds.length> midiled {leds, MIDI_Notes::C[4]};
///////////////////////////////
void setup() {
RelativeCCSender::setMode(relativeCCmode::TWOS_COMPLEMENT); // Rotary Encoder Relative mode
FastLED.addLeds<NEOPIXEL, ledpin>(leds.data, leds.length); // LED
FastLED.setCorrection(TypicalPixelString); //LED
midiled.setBrightness(128); // LED
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
if (midiled.getDirty()) { // If the colors changed
FastLED.show(); // Update the LEDs with the new colors
midiled.clearDirty(); // Clear the dirty flag
}
}
I did copy most of it from examples, but when I try to compile it I get an error.
In the matrix part :
const AddressMatrix<5, 6> addresses {{
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20},
{21, 22, 23, 24, 25},
{26, 27, 28, 29, 30},
}};
The adresses corresponds to a note right? Like Key 1 is C#, Key 2 is D, etc..?
In the led part I'm totally lost, numbers of leds and pin seems alright, but the I don't understand how the range fuctions works (and how to set the range).
Also how to set the color and brightness for idle and when the key is pressed?
If someone can help me get that thing working or help me with certain fuctions I would really appreciate it.
Thanks in advance for you time,
Arnaud
