Tweaking output elements? #953
Unanswered
flippinDiodes
asked this question in
Q&A
Replies: 1 comment
-
Yes, this is possible, and supposed to be relatively easy. For custom output elements, you can have a look at https://tttapa.github.io/Control-Surface-doc/Doxygen/d4/d3b/Custom-MIDI-Output-Element_8ino-example.html. For custom input elements, you could use something like this (untested): #include <Control_Surface.h>
class CustomMIDIInputElement : public MatchingMIDIInputElement<MIDIMessageType::NOTE_ON, TwoByteMIDIMatcher> {
public:
using Matcher = TwoByteMIDIMatcher;
using Parent = MatchingMIDIInputElement<MIDIMessageType::NOTE_ON, Matcher>;
CustomMIDIInputElement(pin_t ledPinRed, pin_t ledPinGreen, MIDIAddress address)
: Parent(address), ledPinRed(ledPinRed), ledPinGreen(ledPinGreen) {}
// Called when a MIDI message is received that matches the specified address
void handleUpdate(Matcher::Result match) override {
// match.value contains the velocity (zero means note off)
AH::ExtIO::digitalWrite(ledPinRed, match.value == 127 ? HIGH : LOW);
AH::ExtIO::digitalWrite(ledPinGreen, match.value == 0 ? HIGH : LOW);
}
// Called once when Control_Surface.begin() is called
void begin() override {
AH::ExtIO::pinMode(ledPinRed, OUTPUT);
AH::ExtIO::pinMode(ledPinGreen, OUTPUT);
reset();
}
// Called when MIDI "all notes off" is received
void reset() override {
AH::ExtIO::digitalWrite(ledPinRed, LOW);
AH::ExtIO::digitalWrite(ledPinGreen, HIGH);
}
private:
pin_t ledPinRed, ledPinGreen;
};
CustomMIDIInputElement muteLeds{
12, // red
13, // green
{ 0x10, Channel_1 },
};
USBMIDI_Interface midi;
void setup() {
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to make customised input and output elements?
For example, I would like to have a red LED for when a mixer channel is muted and a green one when it is unmuted. I can get the red one to work using the basic NoteLED object, and my DAW sends a note at velocity 127 when the channel is muted so it lights up. But for my green LED it needs to turn on when it gets the same message at 0 velocity, but I can't work out how to do this.
I have been able to do this a bit with inputs by making my own button pressing code that has midi.sendCC as its output, but I can't find a way to interact with midi inputs except through the objects that are already in the library.
Beta Was this translation helpful? Give feedback.
All reactions