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 of 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 repetetive 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 where you should organize all of the shared functions you want your Show expressions to use.

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

If you are going to be using the functions only in Triggers expressions, define them using Triggers  Edit Shared Functions in the Triggers window instead. Even though they get compiled into the same beat-link-triggers.expressions namespace, putting them in the Triggers window means they will be saved independently of the Show, and will work even if the Show was never opened, or if you share the Triggers with someone else. If you need them in both your Show and Triggers expressions, put them in both places. Redefining a function is harmless, although make sure you have exactly the same definition in both places or you will confuse yourself!

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.