Activating/toggling the tuner in S-Gear

I much prefer the tuner included in S-Gear, so I made a script to open the plugin window and activate the tuner when I press a button on my foot controller. On a second press it will deactivate the tuner and close the S-Gear window.

// Script to toggle the S-Gear tuner and automatically open/close the plugin window.
Var
   fcb1010 : MidiInBlock   
   sgear : PluginBlock
   sgear_tuner : Integer
   sgear_tuner_state : Double

Initialization
sgear_tuner := 15 // Parameter number for the S-Gear tuner.
End

// Update the CC number to match your controller (I am using CC 16).
On ControlChangeEvent(m : ControlChangeMessage) Matching 16 from fcb1010
sgear_tuner_state := GetParameter (sgear, sgear_tuner ) 
If sgear_tuner_state == 0 Then
    OpenPlugin(sgear) 
    SetParameter (sgear, sgear_tuner, 1)
Else
    SetParameter (sgear, sgear_tuner, 0)
    ClosePlugin(sgear) 
End
End
1 Like

Very nice script that does the job, but no way for you to add a button widget acting on the sgear tuner plugin parameter and to learn the CC 16 event from your FCB1010 ?

Yes, thanks for the suggestion!

This version is based on a widget, which as you state, has the benefit of being able to use the midi learn feature (and you get a button to trigger it manually).

// Script to toggle the S-Gear tuner and automatically open/close the plugin window. This version uses a widget so that it can be toggled manually and use the midi learn feature.
Var 
   sgear : PluginBlock
   sgear_tuner_widget : Widget
   sgear_tuner_param : Integer

Initialization
    sgear_tuner_param := 15 // Parameter number for the S-Gear tuner.
End

// Called when the widget value has changed.
On WidgetValueChanged(newValue : double) from sgear_tuner_widget
    If newValue == 1 Then
        OpenPlugin(sgear) 
        SetParameter (sgear, sgear_tuner_param, 1)
    Else
        SetParameter (sgear, sgear_tuner_param, 0)
        ClosePlugin(sgear) 
    End
End

My suggestion was to try to avoid scripting for this, but I forgot you open and close the plugin window in your script, so you need a script.