How to toggle on pad lights of an Akai APCmini with Gig Performer

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

Thank you Erik.

3 Likes

@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.

First of all @doug_lucas, I would say that you should read the doc about GPScript, that’s the way @schamass learned it too. (I guess :stuck_out_tongue_winking_eye:)

Now a few things without being able to test.

  • your widget buttons have to have handle names defined as pad60, pad61, pad62, pad63… from your screenshot it seems that you did it
  • your pad widgets have to be declared in the GPScript as pad60, pad61, pad62, pad63 : Widget at the same place others are declared
  • in a general way everywhere you have pad56, pad57, pad58, pad59 in the code you will have to add pad60, pad61, pad62, pad63 too

Have fun :wink:

1 Like

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.

Just a very simple possible cause for the “malfunction”… did you press the “Compile” button after you made the changes to the script? Just a thought…

2 Likes

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?

1 Like

@schamass – Erik!!! That was it! That “compile” button! hahaha Thank you! Back to work.

Yessssssssssssssssssssssss! Lights! Lights everywhere!

1 Like

Hmm…do we have to start thinking about auto compiling?

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

I’m sure you’re right. I’ll learn to be more careful and alert!

Auto Compile could lead to loose code.
Imagine you accidently change code and now with successful autocompile you loose the previous code.

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 :teacher:

1 Like

Only if you also think about automatic code generation, elsewhere I would say : don’t do that!!! :stuck_out_tongue_winking_eye:

6 Likes

All I know is - you guys have sure made this job a lot easier. Check out these lights on the APC mini:

GigPerformer4-rig

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 )!!!

Doug

6 Likes