How to get all SongPart names for each Song in the setlist

Is there a “SongPart” version of the GetVariationNameForRackspaceAtIndex and also GetVariationCountForRackspaceAtIndex?

I’m writing a script that gets called on Gig load or on Setlist load. It loops through all songs and gets all Song names along with all Song Part names. It sends this as MIDI SysEx messages to my custom midi controller pedalboard to setup my button screens.

Right now it seems the only way to collect all this data is actually set the active song and then get current song part names. Is there a way to do this without forcing Gig Performer to set each song as the current song in the loop? My Songs are rather CPU intense so it takes a lot of CPU power to loop through all songs quickly to gather this information!

function SendAllDataToPedalboard()
    Var // Local variables for SendAllDataToPedalboard
        originalGPSongIndex : integer;
        originalGPSongPartIndex : integer;
        gpSongCount : integer;
        pedalboardSongIndex : integer;
        gpSongPartCountForCurrentIteratedSong : integer;
        i_song : integer; 
        i_part : integer; 
        songName : string;
        partName : string;
        switchSuccess : boolean; // Dummy variable to "consume" the return value
    // End Var
// Begin    
    Print("GP: Starting SendAllDataToPedalboard...")

    originalGPSongIndex = GetCurrentSongIndex()
    originalGPSongPartIndex = GetCurrentSongPartIndex()
    gpSongCount = GetSongCount()

    For i_song = 0; i_song < gpSongCount; i_song = i_song + 1 Do
        if i_song < 25 then 
            pedalboardSongIndex = i_song

            Print("GP: Switching to song index " + IntToString(i_song) + " to get its data...")
            // Assign the result of SwitchToSongByIndex to the dummy variable
            switchSuccess = SwitchToSongByIndex(i_song, 0) 
            // You could optionally check switchSuccess here if needed, e.g.:
            // If not switchSuccess then Print("Warning: Failed to switch to song " + IntToString(i_song)) End

            Sleep(1000) 

            songName = GetSongName(i_song) 
            If songName <> "" Then
                SendTextAsSysex(ToPedalBoard, CMD_SET_SONG_NAME_HEX, pedalboardSongIndex, 0, songName)
            Else 
                SendTextAsSysex(ToPedalBoard, CMD_SET_SONG_NAME_HEX, pedalboardSongIndex, 0, "Song " + IntToString(pedalboardSongIndex + 1) )
            End

            gpSongPartCountForCurrentIteratedSong = GetSongPartCount()
            For i_part = 0; i_part < 6; i_part = i_part + 1 Do
                if i_part < gpSongPartCountForCurrentIteratedSong then
                    partName = GetSongPartName(i_part)
                    If partName <> "" Then
                        SendTextAsSysex(ToPedalBoard, CMD_SET_BUTTON_NAME_HEX, pedalboardSongIndex, i_part, partName)
                    Else
                        SendTextAsSysex(ToPedalBoard, CMD_SET_BUTTON_NAME_HEX, pedalboardSongIndex, i_part, " ") 
                    End
                else 
                    SendTextAsSysex(ToPedalBoard, CMD_SET_BUTTON_NAME_HEX, pedalboardSongIndex, i_part, " ") 
                End
            End 
        else
            //break 
        End 
    End 

    Print("GP: Restoring original song index " + IntToString(originalGPSongIndex) + ", part " + IntToString(originalGPSongPartIndex))
    if originalGPSongIndex >= 0 then 
        // Assign the result of SwitchToSongByIndex to the dummy variable here too
        switchSuccess = SwitchToSongByIndex(originalGPSongIndex, originalGPSongPartIndex)
        Sleep(50) 
    End

    Print("GP: Finished SendAllDataToPedalboard.")
End


// --- System Event Callbacks (remain the same) ---
On SystemEvent Matching GigLoaded 
   Print("GP: GigLoaded event triggered.")
   SendAllDataToPedalboard()
End

On SystemEvent Matching SetlistChanged
   Print("GP: SetlistChanged event triggered. New setlist index: ")
   SendAllDataToPedalboard()
End
1 Like

Looks like this is missing from the system function list — you’re the first person to notice. We’ll add this for the next major release

5 Likes

Does your controller actually display and allow selection of a song part in a non active song? If not, then you could just get the part names on demand each time you select a song.

I originally coded it that way, to send the sysex on song change. However a negative side affect is it seemed to bog down my esp32 controller and I couldn’t quickly page through songs. Maybe I could have coded it better, but there was a about a 2 second lag switching songs this way.

I’m happy with the way it currently works though. This saves me so much time entering all the setlist data directly into my pedalboard! And I will be even happier when I can generate the data without having to switch through all songs in the setlist. Currently it adds about 30 seconds to an already fairly slow loading gig. About 4:30 total load time.

1 Like