Two way control of MIDI Twister

Gig Performer doesn’t (yet) have bi-directional control of external MIDI devices, that is, you can’t have a widget learn a MIDI control and then also send the widget value back to the external control. This feature will be built-in at some point, it’s very useful for controllers such as some motorized faders and devices like the MIDI Fighter Twister that can display current position information.

However, it’s not too hard to implement this facility with GP Script. Click here to download an example gigfile that implements partial support for the MIDI Twister. By partial I mean that I only supported 4 knobs and push buttons, the reason being that this is just an example and users will most likely want to do it differently than what I did. Below is the script (it’s in the gigfile, you don’t need to copy this, it’s for information only). The idea is that you create a standalone MidiOutBlock associated with the Twister MIDI Port.

Basically, you first get your widgets to learn the twister controllers in the usual manner. That allows the widgets to respond to the controllers. Then you add widget callbacks that respond when a widget is turned. Those callbacks are used to send the current widget position back out to the controller and that’s what gives you two way communication.

Note also the use of an On Activate callback to initialize the Twister to the current positions of the widgets.

// You need to create a MIDI Out block and give it
// the scripting name  MFT
//
// Then you can declare this variable to be able to communicate with the twoster
var
   MFT : MidiOutBlock // Connects to Midi Fighter Twister

 
// Send MIDI value out to twister based on position of a widget
function UpdateTwisterWithValue(ccNumber : integer, widgetValue : double)
var
   cc : ControlChangeMessage
   value : integer

   // Convert widget value between 0.0 and 1.0 to a MIDI value between 0 and 127
   value = ParamToMidi(widgetValue) 

   // Create the appropiate CC message and send it out through the MidiOutBlock
   cc = MakeControlChangeMessage(ccNumber, value);
   MFT.SendNowExternal(cc);
end

// These are the first four widgets associated with knobs on the MIDI Twister
// When you create widgets in a rackspace, you need to give them script handles with these names
var
   K1, K2, K3, K4 : Widget

// These callbacks are triggered when you turn a widget and then
// they call the Update function above to actually set the external Twister knob virtual posi
On WidgetValueChanged(newValue : double) from K1
   UpdateTwisterWithValue(71, newValue)  // 71 is CC value for K1
end

On WidgetValueChanged(newValue : double) from K2
   UpdateTwisterWithValue(1, newValue)  // 71 is CC value for K1
end

On WidgetValueChanged(newValue : double) from K3
   UpdateTwisterWithValue(2, newValue)  // 71 is CC value for K1
end

On WidgetValueChanged(newValue : double) from K4
   UpdateTwisterWithValue(3, newValue)  // 71 is CC value for K1
end

function UpdateTwisterOnActivate(w : Widget, ccNumber : integer)
   var value : double;

     // Get the current position of a widget
     value = w.GetWidgetValue();
     // And update the external device
     UpdateTwisterWithValue(ccNumber, value);
end

On Activate

   UpdateTwisterOnActivate(K1, 71);
   UpdateTwisterOnActivate(K2, 1);
   UpdateTwisterOnActivate(K3, 2);
   UpdateTwisterOnActivate(K4, 3);

end

initialization
   OpenLogWindow()
   ClearLogWindow()
   Print("Ready")
end
1 Like