If it is still of interest, just sharing the evolution of the code here
I took the principles of @schamass and rewrote part of it to achieve the following:
- replace the need of widget knobs / button by an external midi event trigger
- be able to control different LEDs depending on received Midi CC number
- be able to change the color based on CC value
As stated before, this is still work in progress / proof of concept, so values are just indicative of the potential. the idea is to have a sufficiently flexible code to add additional LEDs without need of duplicating / re-writing code.
for the next step I will also split the response of LED color from LED Status, as i want to associate Status to the MIDI controller presets (to display the purpose of the LED accordingly to the selected preset: AMP / Looper / overdrive, etc…) and the LED color to its activation.
//VARIABLES -----------------------------------------------------------------------------
var
LED01, STATUS01, LED02, STATUS02 : widget
color_red, color_green, color_orange, color_neutral, CCValue : integer
MidiTest: MidiInBlock
LedArray : widget Array =[LED01, LED02]
StatusArray : widget Array =[STATUS01, STATUS02]
LedCount: integer
MidiCount: integer
//SUPPORT FUNCTIONS ---------------------------------------------------------------------
// 03a - function to change widget color
Function
SetColor (target : widget, color : integer)
SetWidgetFillColor(target, color)
End
// 03b - function to change widget text
Function
SetText (target : widget, text : string)
SetWidgetLabel (target, text)
End
// 02a - function condition to select color (reads function 03a)
Function GetConditionColor (target: widget, con_val : double)
Select
con_val > 60.00 do SetColor (target, color_red)
con_val > 40.00 do SetColor (target, color_orange)
con_val > 10.00 do SetColor (target, color_green)
con_val > 00.00 do SetColor (target, color_neutral)
End
End
// 02b - function condition to select text (reads function 03b)
Function GetConditionText (target: widget, con_val : double)
Select
con_val > 60.00 do SetText (target, "Condition 3")
con_val > 40.00 do SetText (target, "Condition 2")
con_val > 10.00 do SetText (target, "Condition 1")
con_val > 00.00 do SetText (target, "Condition 0")
End
End
//RUNNING CODE ---------------------------------------------------------------------
// 00 - Sets Initial status
Initialization
color_red = RGBToColor(0.8, 0.0, 0.0, 1.0)
color_green = RGBToColor(0.0, 0.8, 0.0, 1.0)
color_orange = RGBToColor(0.8, 0.8, 0.0, 1.0)
color_neutral = RGBToColor(0.8, 0.8, 0.8, 1.0)
CCValue = 0
GetConditionColor (LED01, CCValue)
GetConditionText (STATUS01, CCValue)
End
// 01 - Called when a CC message is received at some MidiIn block (reads functions 02a & 02b)
On ControlChangeEvent(m : ControlChangeMessage) from MidiTest
LedCount = 0 //Resets LED counts
for MidiCount = 11; MidiCount < 21; MidiCount=MidiCount+1 do //filtes midi messages from CC11 to CC21
if GetCCNumber(m) == MidiCount then //Responds to messages from CC11 to CC21
CCValue = GetCCValue(m) //Stores CC value
GetConditionColor (LedArray[LedCount], CCValue) //applies function to associated LED
GetConditionText (StatusArray[LedCount], CCValue) //applies function to associated LED
end
LedCount = LedCount+1 //increments LED number count associates each LED to one CC
end
end
First time digging on Gig Performer script, but really finding the amazing possibilities it offers
Also below the gig file
Test LEDS.gig (72.2 KB)