Skip to content

frank1119/gp-globalvars

Repository files navigation

C++ Gig Performer Extension GlobalVars

Gig Performer is a live performance VST-host with lots of features. See Gig Performer for details.
This extension uses the Gig Performer SDK and is based on the gp-extension-cpp example.

Purpose

Provides global variables accessible between the several script types, like gig-script, rackspace-scrips, scriptlets and song-scripts. GPscript lacks this.
You might call this extension 'headless', because it has no menus or panels. It only adds some scripting functions. USE AT YOUR OWN RISK!

Some history

Some time ago I started exploring Gig Performer and stumbled upon its scripting feature. This feature is very useful, but lacks one thing: low weight communication between the several scripts. Of course there are way to accomplish collaboration between these scripts but sometimes they feel a bit heavy for the usage I have in mind. The easiest way IMHO could be variables accessible from all scripts. When I read about this extension API and its possibility to extend also the available script functions, I saw an opportunity to implement this myself.

I must admit till now every 'Gig' I created can do without it, so I'm not entirely sure of the usefulness of this extension. Furthermore, it is possible that this extension conflicts with the philosophy of Gig Performer.

How to build...

These instructions are a copy of build instructions for the gp-extension-cpp example. The build on macOS I cannot try, because I don't own a Mac.

... on macOS

  • Make sure you have CMake installed. You might have to add the path to the cmake executable by adding this line to your bash profile:

    export PATH=/Applications/CMake.app/Contents/bin:$PATH

    Alternatively, you can install CMake via Homebrew:

    brew install cmake
  • Build (and install) the project via CMake. For your convenience we have provided a build.sh which contains all necessary commands:

    ./build.sh

... on Windows

  • Make sure you have CMake, Git and a C(++) compiler installed. You can get that for example by installing Visual Studio with the Desktop development with C++ workload and the Git for Windows component.

  • Build (and install) the project via CMake. For your convenience we have provided a build.cmd which contains all necessary commands:

    build.cmd

    Make sure to run the script from the Visual Studio developer command prompt!

How to use

Declare a variable

  • Integer declaration

    var
        b : boolean
        
        b = GlobalVars_CreateInt("NumberOfSongparts")
        Print(b)
    
  • String declaration

    var
        b : boolean
        
        b = GlobalVars_CreateString("Author")
        Print(b)
    
  • Declaration with an error

    var
        b : boolean
        
        b = GlobalVars_CreateString("global_1")
        
        b = GlobalVars_CreateInt("global_1") // Will return false: global_1 already exists
        Print(b)
    
  • Integer array declaration

    var
        b : boolean
        
        b = GlobalVars_CreateIntArray("PowersOfTwo", 10)
        Print(b)
    

Assigning a value

  • Assigning an integer

    var
        b : boolean
        
        b = GlobalVars_SetInt("NumberOfSongparts", 100)
        Print(b)
    
  • Assigning an integer in an array

    var
        b : boolean
        
        b = GlobalVars_SetIntInArray("PowersOfTwo", 0, 1)
        Print(b)
        b = GlobalVars_SetIntInArray("PowersOfTwo", 1, 2)
        Print(b)
        b = GlobalVars_SetIntInArray("PowersOfTwo", 2, 4)
        Print(b)
        b = GlobalVars_SetIntInArray("PowersOfTwo", 3, 8)
        Print(b)
    
  • Assigning a string

    var
        b : boolean
        author : string
        
        author = "Frank"
        
        b = GlobalVars_SetString("Author", author, Length(author))
        Print(b)
    
  • Assigning a string in an array

    var
        b : boolean
        contributor : string
        
        contributor = "Frank"
        b = GlobalVars_SetStringInArray("Contributors", 0, contributor, Length(contributor))
        Print(b)
        
        contributor = "Tom"
        b = GlobalVars_SetStringInArray("Contributors", 1, contributor, Length(contributor))
        Print(b)
    

Getting values

  • Getting an integer

    Print (GlobalVars_GetInt("NumberOfSongparts"))
    
  • Getting a string

    Print (GlobalVars_GetString("Author"))
    
  • Getting an integer from an array

    Print (GlobalVars_GetIntFromArray("PowersOfTwo", 2))
    Print (GlobalVars_GetIntFromArray("PowersOfTwo", 3))
    
  • Getting a string from an array

    Print (GlobalVars_GetStringFromArray("Contributors", 0))
    Print (GlobalVars_GetStringFromArray("Contributors", 1))
    

Removing variables

  • Removing specific variables

    Print (GlobalVars_DestroyVariable("Contributors"))
    Print (GlobalVars_DestroyVariable("NumberOfSongparts"))
    
  • Erase all

    GlobalVars_RemoveAll()
    

Enabling auto Removing variables when loading a new Gig

By default, variables created in one Gig will not be erased when a new Gig is loaded.

  • Enable:

    Print (GlobalVars_RemoveAllOnLoad(True))
    
  • Disable:

    Print (GlobalVars_RemoveAllOnLoad(False))
    

    The returnvalue is the previous state.

Informational

  • Variable type

    var
        tp : integer
    
        tp = GlobalVars_GetVariableType("PowersOfTwo")
        Print (tp)
        
        // 0 -> Does not exist
        // 1 -> String value
        // 2 -> Integer value
        // 3 -> Double value
        // 4 -> Boolean value
    
        // 17 -> String array
        // 18 -> Integer array
        // 19 -> Double array
        // 20 -> Boolean array
    
  • Array size

    Print (GlobalVars_GetArraySize("PowersOfTwo"))
    // -1 -> Not an array or variable does not exist
    // >= 0 -> Size (although an array with a size of 0 cannot be created)
    

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published