Switch rackspaces with Midi CC or Midi note

Hello Gig Performer community,

I’m still new and not so familiar with the program yet.
Actually I just want to switch different rackspaces with a midi controller. Unfortunately I don’t have a single controller that can send midi program change. NanoKontrol, Nanokontrol2, NanoPad, NanoKey and Akai APCmini all send only Control Change or Note on/off. :frowning_face:
I read in the forum that it is possible to get GigPerformer to convert Note or CC messages to Program Change messages with a script. However, I can’t figure it out from the posts. Also the manual of the script language is not very productive and I can’t find any examples.
What I need is a well documented script that I can customize to convert an incoming CC or Note message from a given controller into a defined Program Change message.
If someone has experience with this and can help me I would be very grateful.

Jürgen

I have an example Gig Script here, which has examples of converting both cc and note messages to pc.

It was for a specific controller, but hopefully you can see the major elements.

4 Likes

I assume you want buttons to switch to a specific rackspace? Because you can easily use cc to go up/down rackspaces.

Hello rank13,

thank you for your support! It works!!!

Here is a short description what I did and how to use a APCMini as Rackspace switching device:

Make a new Rig with actually up to 16 Rackspaces.
Go to Window → Rig Manager and name your APC Mini alias APCmini (exactly as in the script) → Apply.
Go to Window → Show Gig Script Editor an Paste this into the Editor Window

// Note messages are converted to PC messages to change rackspaces (by rank13)

Var
    APCmini : MidiInDeviceAlias
    PADNOTES : Integer Array = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    
// Converting the APCmini pads to PC messages
On NoteEvent(m : NoteMessage) Matching [0..16] from APCmini
    Var i : Integer
        noteNumber : Integer = GetNoteNumber(m) 
    if IsNoteOn(m) and GetChannel(m) == 1 then
        // Find index of the pad note number and generate PC message
        for i = 0; i < Size(PADNOTES); i = i + 1 do
            if noteNumber == PADNOTES[i] then
                InjectMidiEventViaRigManager(APCmini, MakeProgramChangeMessage(i))
            end
        end
    end
End

Press Compile and close the Window.
Buttons 0 - 15 (two lowest rows) change the Rackspaces
Done!

2 Likes

Is there also a possibility to switch on the corresponding led via script on the APCmini when the Rackspace is active? Currently I do it via the configuration of the internal MIDI Out plugin.

Is that more elegant with script? How is this done?

What do you send now to set the LED - Note On?
If a pad is set to send Note messages, that would generally mean it’s momentary, so I’m surprised if sending a Note On back to it would cause the LED to stay lit.

Your script could be a bit simpler, as your note numbers are all continuous. The reason I used the array was because the other example had non-continuous note numbers for the 16 pads, so it made it easier to manually list them.

You can add extra callbacks to the Gig Script for other things. There is one that is triggered when the rackspace changes. The function to send to a midi out device is slightly different → you use the actual string format of the port name.

// Called when you switch to another rackspace
On Rackspace(oldRackspaceIndex : integer, newRackspaceIndex : integer)
   SendNowToMidiOutDevice("IAC Driver Bus 1", MakeNoteMessage(newRackspaceIndex, 127))
End

You might also need to set the prior Rackspace to zero velocity to turn the old one off. Or do a “For” loop and go through all 16 pads to set the other ones off.

I think just be cautious about creating loops, if the controller sends back a message again when you update the LED. You can add a few extra checks to avoid this.

1 Like

Currently I have solved it this way: APC Mini sends Midi notes → Script converts Midi notes to PC → PC switches Rackspaces → In each Rackspace there is a Midi Out. This sends a Midi Note on to the APC Mini, which corresponds to the pressed button. The remaining button LEDs are switched off with a Note on Velocity 00 command.

This works very well, but it is very complex to program. I can copy and paste the midi out to any rackspace, but there are a few problems:

To turn off an LED, the midi out must be set to note on vel 00. Note off does not work. When I open the configuration of the Midi Out to adjust the settings, the set values are displayed correctly in the lower right window. But when I open the editor to adjust the values ALL velocity values are set to 64! This means that I have to set 256 velocity values manually for switching 16 rackspaces. :astonished: This should be more elegant to solve.

These commands are received by the APC Mini
Button No = Note No

Note on [Button No] Vel 00 switches LED off
Note on [Button No] Vel 01 switches LED green
Note on [Button No] Vel 02 switches LED green flashing
Note on [Button No] Vel 03 switches LED red
Note on [Button No] Vel 04 switches LED red flashing
Note on [Button No] Vel 05 switches LED yellow
Note on [Button No] Vel 06 switches LED yellow flashing

I think I will leave the array like this, because maybe later I will rearrange the function groups on the APC Mini in columns (that would be 56, 48, 40, 32 …). Also the switching off of the LEDs I will have to do individually, since a loop then also no longer works.

As I said, I have no idea about programming… :-1:

Are the previous and the current Rackstate “Numbers” automatically stored here?

On Rackspace(oldRackspaceIndex : integer, newRackspaceIndex : integer)

I then just add the following line to the above example:

SendNowToMidiOutDevice("IAC Driver Bus 1", MakeNoteMessage(oldRackspaceIndex, 0)).

Is that correct?
Where can I find the “string format of the port name”? :thinking:

That format for the oldRackspaceIndex looks right to me.
For the midi port name, just have a look in the Options > Midi Ports and take the name from there.