If Else FX Flip Switch

Hello,

I’m trying to use GPScript that will use one widget to “Flip” between eight song parts as follows:

Swell <----> SwellFX
Great <----> GreatFX
Choir <----> ChoirFX
Swell <----> PedalFX

I believe that I have a strategy to implement this, but I’m struggling to get my GPScript to compile. The plan is to use an If/Else statement to assign different actions to the widget depending on the state of the songpart index. If the song index is 1-4, then the widget will add 4 to the index. If the song index is 5-8, then the widget will subtract 4 from the index.

Can anyone please assist? The script is in the gig script of the .gig below.

Thanks in advance!

If Else Song Part.gig (26.3 KB)

Paste your script and paste the actual error message you’re getting.

1 Like

The script is:

//Get Song Part

var FXSwitch : Widget
var SongPartNumber : Integer

On Songpart(oldSongpartIndex : Integer, newSongpartIndex : Integer)
SongPartNumber = GetCurrentSongPart()

End 

//Find Manual's FX Part
On WidgetValueChanged(newValue : double) from FXSwitch 

If SongPartNumber <= 4 Then
    SetSongPart(index: SongPartNumber + 4)
    Elsif SongPartNumber >= 5 Then
    SetSongPart(index: SongPartNumber - 4)
	        
End

My error message is:

Gig (GigScript) - - Syntax Error in “Main”: Line 14, Col 1: Unexpected or unrecognized token: ‘If’
Mismatched input ‘If’ expecting End

ok - several issues with this

  1. Your SetSongPart function calls have “index:” and that’s not valid — you’re making a function call, not delcaring a variable

  2. If this is in a GigScript, you can’t declare widgets.

1 Like

And an “End” is missing for the if clause.
And the callback you cannot use

2 Likes

Thanks for your guidance! I tidied up the script and spent time with the manual getting to know objects available in a Rackspace/Gig Script setting.

However, I’m still struggling to setup a callback that can be triggered via midi/widget in the Gig Script. I see many available in a Rackspace Script, but I can’t migrate because it is unable to use song functions such as:

On Songpart(oldSongpartIndex : Integer, newSongpartIndex : Integer)
SongPartNumber = GetCurrentSongPart()

Any direction on solving this dilemma? Here is the current script:

//Patch Control <---> FX Control

var SongPartNumber : Integer
SomeMidiInBlock : MidiInDevice

On Songpart(oldSongpartIndex : Integer, newSongpartIndex : Integer)
SongPartNumber = GetCurrentSongPart()

End 

On ControlChangeEvent (c : ControlChangeMessage) From SomeMidiInBlock

    If SongPartNumber <= 4 Then
        SetSongPart(SongPartNumber + 4)
        Elsif SongPartNumber >= 5 Then
        SetSongPart(SongPartNumber - 4)
    End
End

The reason you cannot access widgets directly from a gigscript is because there is no way to guarantee that a specific widget that you reference from a gig script will actually be available.

However, if you want to trigger a callback in a gigscript from a rackspace (say), then you can use OSC messages.

2 Likes

Brilliant! I changed my callback trigger to OSC instead of MIDI and corrected the “break point” (0-3, 4-7 vs 1-4, 5-8) and now the patch is working perfectly. Here’s the script and .gig:

//Patch Control <---> FX Control

var SongPartNumber : Integer

On Songpart(oldSongpartIndex : Integer, newSongpartIndex : Integer)
SongPartNumber = GetCurrentSongPart()

End 

On OSCMessageReceived(message : OSCMessage) Matching "/GigScript/FXSwitch"
    If SongPartNumber <= 3 Then
        SetSongPart(SongPartNumber + 4)
        Elsif SongPartNumber >= 4 Then
        SetSongPart(SongPartNumber - 4)
    End
End

If Else Song Part.gig (17.9 KB)

I’m really starting to understand the power and practicality of OSC. Thanks again for your help and patience!

Sam

You don’t need that test. If the songpart is NOT <= 3 then it must be >= 4 so just do

Else SetSongPart(SongPartNumber - 4)

instead of that extra test.