Hello, I've spent a few months on and off on this project and finally decided to post in the forums for some guidance. I'm building a MIDI controller using a Teensy 3.6 and some encoders, pots, LEDs, etc. Using tttapa's (Pieter's) Control Surface library I've been able to get a very simple setup working with ease (thanks to the documentation and examples provided). I've had success mapping and controlling parameters within Ableton Live.
Here's where my tiny, tiny peabrain fails me: I'd like to be able to return CC values from Ableton and have the actual value of the parameter correspond to an LED (i.e. if the virtual knob (macro) is at CC value 0 then LED is 'off' or zero brightness, if CC value is 63 then LED is at 50% brightness, if CC value is 127 then LED is at full brightness). I would like to have one of these set up for every encoder so that I can get a quick idea of the position of each macro within Ableton.
I have a maxforlive patch that sends CC values which can be mapped to macros, so I have a way to send the information back out to the Teensy (the macro itself will dictate the CC values, not the encoder). I'm unsure how to turn this information into illuminating the LED.
Here's my code:
If this is actually something that's dead easy please point me to some examples so I can pick them apart and try learn this for myself. Thank you
Here's where my tiny, tiny peabrain fails me: I'd like to be able to return CC values from Ableton and have the actual value of the parameter correspond to an LED (i.e. if the virtual knob (macro) is at CC value 0 then LED is 'off' or zero brightness, if CC value is 63 then LED is at 50% brightness, if CC value is 127 then LED is at full brightness). I would like to have one of these set up for every encoder so that I can get a quick idea of the position of each macro within Ableton.
I have a maxforlive patch that sends CC values which can be mapped to macros, so I have a way to send the information back out to the Teensy (the macro itself will dictate the CC values, not the encoder). I'm unsure how to turn this information into illuminating the LED.
Here's my code:
Code:
#include <Encoder.h>
#include <Control_Surface.h>
USBMIDI_Interface midi; //designate that this is a USBMIDI interface and the name
int LED1 = 35;
int brightness = 0;
CCRotaryEncoder enc = { {32, 31}, MIDI_CC::Channel_Volume, 2, 4,};
// create rotary encoder object called enc1 on pins 31, 32
//sends midi to Channel_Volume CC (byte 0x10) on midi channel 1
//the step multiplier is 2, encoder sends out 4 pulses per step
void LEDCC(byte channel, byte note, byte velocity) {
int vel1 = velocity;
vel1 = map(vel1, 0, 127, 0, 255);
brightness = vel1;
analogWrite(LED1, brightness);
}
void setup() {
// put your setup code here, to run once:
Control_Surface.begin();
pinMode(LED1, OUTPUT);
usbMIDI.setHandleControlChange(LEDCC);
}
void loop() {
// put your main code here, to run repeatedly:
Control_Surface.loop();
}
If this is actually something that's dead easy please point me to some examples so I can pick them apart and try learn this for myself. Thank you