Dorico uses the Lua programming language for its Scripts feature. You will be hearing more about Lua as it relates to music notation programs on this blog in the coming months.
Dorico’s Edit filters are a great way to illustrate how Lua scripting can make your life in Dorico even more efficient.
Dorico’s ability to filter for specific types of objects is extensive. These are available when in Write Mode by choosing Edit > Filter >. (A subset of filtering operations is also available when in Engrave Mode).
But why should I need to run a script just to make filter selections? Finale and Sibelius both have the ability to filter for a variety of different objects for copy and paste, or for deletion operations. So?
What is different about Dorico is its ability to perform its Edit filter operations cumulatively, rather than each successive filter operation replacing the last. A Macro script can perform these cumulative filtering choices very fast, as well as allowing for very detailed filtering operations.
Of course, you could resort to using a third party macro program like AutoHotKey on Windows or Keyboard Maestro on Mac, but Dorico’s Scripts feature, though still in a nascent state as of v2.2, can provide just what we need for creating more esoteric edit filter selections which are not already a preset.
Here is an example. Say you want to select just the bottom notes, along with the single notes in these two measures:
When you select the preset Edit > Filter > Notes in Chords > Bottom Note or Single Notes, Dorico automatically does just that.
But what if you wanted to do this in reverse? That is, say you’ve already copied the contents to another instrument and you want to *deselect* the bottom notes and single notes so you could delete all the other notes, for instance?
Let’s give it a try. First, by choosing Edit > Filter > Deselect Only. Then, choosing Edit > Filter > Notes in Chords > Bottom Note or Single Notes.
But, that’s not quite it, is it? The dynamics are still selected. If you were to delete the selected notes, you would lose the dynamics, too.
Here is a sequence of filtering steps that provides what we need:
(a) Edit > Filter > Select Only
(b) Edit > Filter > Notes and Chords
Will give us:
Note that the dynamics have been deselected for us with this operation. And, with just a couple of additional filtering steps:
(c) Edit > Filter > Deselect Only
(d) Edit > Filter > Bottom Notes or Single Notes
…we have, then, in four steps, this selection:
From which we can delete all but the bottom notes (and their associated dynamics).
It is very easy to record these four steps for quick recall as a Macro script in Dorico.
First, make your selection of music. Next, in Dorico’s Script menu, choose “Start Recording Macro”, then select the above four filter operations, one right after another:
(a) Edit > Filter > Select Only
(b) Edit > Filter > Notes and Chords
(c) Edit > Filter > Deselect Only
(d) Edit > Filter > Bottom Notes or Single Notes
Now, in the Scripts menu, choose “Stop Recording Macro”.
Dorico only saves one user macro at a time currently, so we’ll need to save the results with a different file name so we can recall this useful script at a later time. Navigate to:
Mac: ~/Library/Application Support/Steinberg/Dorico/Script plug-ins
Windows: ~\AppData\Roaming\Steinberg\Dorico\Script plug-ins
Make a copy of the text file labeled “usermacro.lua” and rename this file “Deselect Bottom Note or Single Notes.lua” or similar. Now, any time you need this type of filter result, simply choose “Run Script…” from the Script menu in Dorico and locate that file.
If you’d like to cut to the chase, just download these short Lua scripts for Dorico and try them out. Thanks to Luís Salgueiro for his help recording and saving these five macros.
“Deselect Top Note or Single Notes.lua”
“Deselect Second Note or Single Notes.lua”
“Deselect Third Note or Single Notes.lua”
“Deselect Fourth Note or Single Notes.lua”
“Deselect Bottom Note or Single Notes.lua”
For those who are looking to dig a little deeper into this, here is the resulting Lua script code that is generated when you record the above “Deselect Bottom Note or Single Notes” illustration. It is just 5 total lines of code:
local app=DoApp.DoApp()
app:doCommand([[Edit.FilterBehaviour?FilterBehaviour=kSelect]])
app:doCommand([[Filter.NotesAndChords]])
app:doCommand([[Edit.FilterBehaviour?FilterBehaviour=kDeselect]])
app:doCommand([[Filter.NotesInChordsFromBottom?Index=0]])
The Lua Scripts Macro Recorder feature is only the beginning of Dorico’s extensible future. What useful macro sequences will you create?
The only really inconvenient part of this process is
“Dorico only saves one user macro at a time currently, so we’ll need to save the results with a different file name so we can recall this useful script at a later time. Navigate to:
Mac: ~/Library/Application Support/Steinberg/Dorico/Script plug-ins
Windows: ~\AppData\Roaming\Steinberg\Dorico\Script plug-ins
Make a copy of the text file labeled “usermacro.lua” and rename this file “Deselect Bottom Note or Single Notes.lua” or similar.”
I understand that the Dorico guys don’t want to put in a full programming language interface until they are ready to do it, but I would think that if they just provided an easy way to name a recorded macro, where it could default to “usermacro.lua” but be user modifiable, it would make this feature more immediately accessible to a lot of people.
I wonder if you could write a little lua macro to rename “usermacro.lua” in the interim? I’m not sure if renaming is in the available vocabulary, but it would be handy if it were.
Otherwise, cool stuff!
I agree with your point about having a way to rename these files more easily, Bob. Hopefully something we will see in the future. Thank you!