In case anyone is interested (now or years from now - someone that was in my situation and needed to hook up a midi controller to Gig Performer to activate VSTs or whatever), here’s the sample script that Erik developed. He recommended that I get to this by clicking on the “Window | Show Current Rackspace Script Editor.” There’s a keystroke shortcut to that - ctrl-shift-1.
— code follows —
var
pad56, pad57, pad58, pad59 : widget
lbl_message : widget
apc_out : MidiOutBlock
on_100 : int = 6 // ch 6 = 100% full on
on_10 : int = 0 // ch 0 = 10% on
col_off : int = 0 // RGB #000000 (means "off)?
col_1 : int = 5 // RGB #FF0000 (means full red)
col_2 : int = 21 // RGB #00FF00 (means full green)
col_3 : int = 45 // RGB #0000FF (means full blue)
// Called when any of several widgets changed
// The widget and index parameters are optional
On WidgetValueChanged(w : Widget, index: integer, newValue : double) from pad56, pad57, pad58, pad59
var
pad_nr, midi_ch, velo_val : int
pad_msg : NoteMessage
if newValue > 0.6 Then
pad_nr = StringToInt(CopySubstring(GetWidgetScriptName(w), Length(GetWidgetScriptName(w))-2 , 2))
midi_ch = on_100 //full on - see var definitions
velo_val = col_3 // full blue
pad_msg = MakeNoteMessageEx(pad_nr, velo_val, midi_ch)
SendNowExternal(apc_out, pad_msg)
SetWidgetLabel (lbl_message, pad_msg)
Else
pad_nr = StringToInt(CopySubstring(GetWidgetScriptName(w), Length(GetWidgetScriptName(w))-2 , 2))
midi_ch = on_10 //10% on - see var definitions
velo_val = col_off // no color = off?
pad_msg = MakeNoteMessageEx(pad_nr, velo_val, midi_ch)
SendNowExternal(apc_out, pad_msg)
SetWidgetLabel (lbl_message, pad_msg)
end
End
— code above —
Erik ( @schamass ) I think I can build on this code. I’ll look forward to diving into it tonight
@schamass , Erik, I hate to ask - but could I bother you just one more time? I’ve tried to add additional buttons to your code, and I must be missing something. The buttons I add won’t operate. Finally, I just tried to utilize even your same syntax of adding new names. And it STILL won’t work. If I paste the code here, would you take a look and venture a guess as to what I’m doing wrong please?
var
pad56, pad57, pad58, pad59 : widget
lbl_message : widget
apc_out : MidiOutBlock
on_100 : int = 6 // ch 6 = 100% full on
on_10 : int = 0 // ch 0 = 10% on
col_off : int = 0 // RGB #000000 (means "off)?
col_1 : int = 5 // RGB #FF0000 (means full red)
col_2 : int = 21 // RGB #00FF00 (means full green)
col_3 : int = 45 // RGB #0000FF (means full blue)
// Called when any of several widgets changed
// The widget and index parameters are optional
On WidgetValueChanged(w : Widget, index: integer, newValue : double) from pad56, pad57, pad58, pad59
var
pad_nr, midi_ch, velo_val : int
pad_msg : NoteMessage
if newValue > 0.6 Then
pad_nr = StringToInt(CopySubstring(GetWidgetScriptName(w), Length(GetWidgetScriptName(w))-2 , 2))
midi_ch = on_100 //full on - see var definitions
velo_val = col_3 // full blue
pad_msg = MakeNoteMessageEx(pad_nr, velo_val, midi_ch)
SendNowExternal(apc_out, pad_msg)
SetWidgetLabel (lbl_message, pad_msg)
Else
pad_nr = StringToInt(CopySubstring(GetWidgetScriptName(w), Length(GetWidgetScriptName(w))-2 , 2))
midi_ch = on_10 //10% on - see var definitions
velo_val = col_off // no color = off?
pad_msg = MakeNoteMessageEx(pad_nr, velo_val, midi_ch)
SendNowExternal(apc_out, pad_msg)
SetWidgetLabel (lbl_message, pad_msg)
end
End
(edited the posting for better readabiity of the code - schamass as Mod)
The widgets that I’ve added don’t seem to be operating anything - and the lights don’t actuate.
Thank you @David-san . I guess that’s the thing. I have started studying the doc. I had thought I used the same syntax on handle names. I’m almost sure I declared the variables in the same pattern and I thought for sure I followed Erik’s pattern on adding the new variables - yet still… I am missing something, obviously, because they don’t work. That’s exactly why I wrote. After working on this for two hours, it was obvious I’m missing something.
If it is clear for you that the GPScript code you posted won’t be enough to make the additional buttons work , you could perhaps post the code you modified?
That would be a wonderful add-on. But another approach is just to train new users (like Erik just did in my case). I honestly just hadn’t noticed it.
Another option - if you just wanted to … “on window close, ask the user, 'Do you want to compile this script?” – but it’s already a tremendous help (as can be seen in Erik’s contribution here). We can live with manual compiling if you have bigger fish to fry. Just thankful for Gig Performer.
To be honest, this is the first time since GP was released that this has come up as an issue. I was just a little taken aback. Maybe a warning that one can turn off but I’m not sure it’s worth it
Maybe the first time someone starts scripting, offer a short guidance, a sort of like some games do when you play it the first time. That way there’s some ‘education’.
But after all: GP has a lot of features and it all boils down to the fact that sometimes people have to read (a part of) the manual
All I know is - you guys have sure made this job a lot easier. Check out these lights on the APC mini:
I can now use real buttons to choose instruments and background drone tones through the song, all from this Akai APC mini. And the lights make it easy for me to tell which channel is at work! Thank you
(@schamass )!!!