sargentpilcher
Well-known member
So I'm trying to make my code more efficient by cutting down some of the lines required. I've gotten a lot of help from people on this forum that I appreciate so much. Just for an idea of what I'm doing, I'm posting a before and after.
This code works perfectly (Just incredibly slow)
So based on recomendations from fellow user "oddson" I'm using a math formula to assign the LED number instead of listing them all manually. So I've modified it to this
However in this code, it is saying that "note" was not declared in this scope. Which to me is weird because "note" isn't declared any differently in the first/working example. I was having the same problem with "channel" until I changed the code to "usbMIDI.getChannel()" (Which may or may not even work), but there isn't an alternative for "note" that I've found. Isn't "note" declared during the "void OnoteOn" part? Aren't these part of the usbMIDI library? Thank you in advance for any help.
This code works perfectly (Just incredibly slow)
Code:
void OnNoteOn(byte channel, byte note, byte velocity)
{if (channel = 1 && note == 0)
{red0 = velocity*2;}
if (channel = 1 && note == 1)
{green0 = velocity*2;}
if (channel = 1 && note == 2)
{blue0 = velocity*2;}
strip1.setPixelColor(0, red0, green0, blue0);
So based on recomendations from fellow user "oddson" I'm using a math formula to assign the LED number instead of listing them all manually. So I've modified it to this
Code:
void OnNoteOn(byte channel, byte note, byte velocity);
uint8_t light = usbMIDI.getChannel()+note-1
red[light] = velocity*2
green[light] = velocity*2
blue[light] = velocity*2
strip1.setPixelColor(light, red[light], green[light], blue[light]);}
However in this code, it is saying that "note" was not declared in this scope. Which to me is weird because "note" isn't declared any differently in the first/working example. I was having the same problem with "channel" until I changed the code to "usbMIDI.getChannel()" (Which may or may not even work), but there isn't an alternative for "note" that I've found. Isn't "note" declared during the "void OnoteOn" part? Aren't these part of the usbMIDI library? Thank you in advance for any help.
Last edited: