Get MA2 Speed Master BPM value

In some cases, it might be useful to get the BPM value of a Speed Master from an MA2 desk. One common use-case is to use the MA2 Speed Master as the global master for the remaining systems.

While there is no dedicated way to retrieve a BPM value from a Speed Master, you can retrieve the running "cue" name of an executor, which, for a Speed Master, is essentially the current BPM value.

-- Get 'GrandMA2' element
GrandMA2 = GetElement('GrandMA2')
-- Returns the name of the current cue
-- (in fact for speedmasters it shows the BPM value)
-- For example: "60.0 BPM"
v = GrandMA2.GetExecutorCurrentCue(1)
-- Remove the " BPM" part of the name
v = string.gsub(v, " BPM", "")
-- Convert to Number
v = tonumber(v)
-- Variable v contains the speedmaster BPM value as a number

Because the GetExecutorCurrentCue function returns a string containing the units (for example, "60.0 BPM"), we need to remove that text part and then convert the string to a number.