Show Shared Functions

Starting with version 0.5 you can use Show files to more conveniently perform actions when specific sections of particular tracks are played. Shows have their own sets of expressions, which we cover next.

Between tracks, phrase triggers, and all the cues you might put inside them, shows can accumulate a great many expressions. You can use the Expressions Report to help manage them.

The Tracks menu at the top of a Show window lets you define expressions that can manage values you want to make available to all your other expressions within the Show. Most of them are described in the next section, but we will look at how to set up shared functions for use in all your show expressions here.

Just like in the Triggers window, if you start writing complex expressions in your Show, you will find yourself repeating common pieces of code over and over again in multiple expressions. The best way to deal with that is to pull out the repetitive part and write it as a function, which can then be called from any expression that wants to use it. In Clojure, you use defn to define a function, and choosing Tracks  Edit Shared Functions brings up an editor window that is the place where you should organize all the shared functions you want your Show expressions to use.

The Shared Functions will be loaded before any of your Show expressions are compiled.

If you are going to be using the functions in Triggers expressions, define them using Triggers  Edit Shared Functions in the Triggers window instead. Starting with BLT version 8, functions and expressions for a Show are compiled into a namespace that is private to that Show. If you need the same functions in both Show and Triggers Window expressions (or in two different Shows), put copies in both places.

If you want to use any Show expressions from a Raw Trigger that lives in the Show but runs in the context of the Triggers window, it can access them using the show-shared alias.

For a detailed (and amusing) look at defining and using shared functions in a show, check out the Break Buddy integration example.

Also see the discussion of how you can import libraries for use in your expressions.