Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lua Scripting 101: Macro actions
#1
Expanding on the "Hello World" script, let's go one small step further.

A common request is to trigger a sequence of events (actions) from a single button or key shortcut; this is sometimes called a "macro". Mixbus's Scripting feature allows us to access any command that can be triggered from a keyboard shorcut, and instead call it from a Lua script.

So, here's a script that calls 2 actions in sequence:

[Image: lua-macro-1.png]

As you can probably guess from the code, this example script selects all the 'regions' in your session, and it calls the "cut region gain" shortcut, therefore reducing all regions by 1dB.

Here's the code, if you'd like to copy + paste it:

Code:
function factory () return function ()

    Editor:access_action("Editor","select-all-objects")
    Editor:access_action("Region","cut-region-gain")

end end

However, there is one problem with this example: We might want to save this for later use. To enable saving the script, we must add a small header which defines the script's name, the author, a description and a license.

[Image: lua-macro-2.png]

Code:
ardour {
    ["type"]    = "EditorAction",
    name        = "Cut Regions 1dB",
    license     = "MIT",
    author      = "Ben Loftis",
    description = "Select all regions, and cut by 1dB"
}

function factory () return function ()

    Editor:access_action("Editor","select-all-objects")
    Editor:access_action("Region","cut-region-gain")

end end

Once you've added the script's "header", you can click the "Save" button, and the script will be saved into your personal list of Lua scripts; you can then open, modify, and re-use the script at your convenience.

Once the script is saved, you'll find it under the "Action" list in your scripts window.

The script is saved on your hard disk in your Mixbus preferences folder. So if you ever delete your preferences, you will lose all your scripts. Don't forget to keep backups of your data!
Reply


Messages In This Thread
Lua Scripting 101: Macro actions - by Ben@Harrison - 03-30-2017, 09:12 AM
RE: Lua Scripting 101: Macro actions - by truemix - 12-08-2018, 11:28 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)