Applying slash notation in Dorico via a Lua script

Tips

Editor’s note: This post is written by Alexander Plötz. Philip Rothman edited the post and provided additional content.

When Dorico was released last year, there was a considerably large group of potential users who said: “This looks really great, and I would so love to use it, but… really, there is one thing that I positively must have before I can commit to this new software. And that is chord symbols.”

Chord symbols have arrived. Everybody’s happy, right? Says a sub-group of those on-the-fence users: “Well, this looks really great, and I would so love to use it, but… I just realized, there is one more thing that I positively must have before I can commit to this new software. And that is slash notation.” Which is tough luck, because properly implemented slash notation will not arrive until the next substantial update at the earliest, according to Dorico’s product marketing manager Daniel Spreadbury.

In the meantime, however, there is a method to get the appearance of slash notation.

That, as an aside, is not a trivial observation. Having worked with Dorico over the last months I can say that I know of no other score writer application that puts up this much resistance against faking. Alternatively, I could say that the other programs’ much less strict semantic models of music notation leave a lot more room for using their features in a way that is not intentional.

Back to our topic: getting the appearance of slash notation.

To do that, input single notes on the middle line in the rhythm of your beats (probably quarter notes), select those notes and use Edit > Notehead to set the noteheads to Slash Noteheads.

Then, in Engrave Mode, activate the Stem length adjustment property in the Notes and Rests sections of the lower panel and set the number box to an appropriate negative value (for quarter notes in Bravura this would be -2 7/16). Just to be on the safe side, the Accidental property in the same section can be set to Hide. If you are relying on playback, it is also a good idea to activate the Muted property in the Common section and to check the box.

While all this is simple enough, in practice it can become a bit tedious. This is why we are pleased to hereby provide a simple Lua script you can download, which, in spite of its limitations, will hopefully make it easier for you to prepare beautiful Dorico charts right now.

How scripts are handled in Dorico

Scripting in Dorico is currently still in a nascent state. While the number of things that are possible is not exactly small, those things themselves are a bit superficial. If you can do something manually in Dorico through a discrete sequence of UI commands, then there is a good, but not perfect chance that you will be able to do it via script. Anything more is off-limits for now.

To your ears, this might sound like a macro recorder, and you would be right. If you want to try your hands on a Dorico script, you can learn by doing the following:

Go to Script > Start Recording Macro, do a few things, then apply Script > End Recording Macro. Your actions are now recorded in the file usermacro.lua in the folder ~/Library/Application Support/Steinberg/Dorico/Script plug-ins on Mac, or ~\AppData\Roaming\Steinberg\Dorico\Script plug-ins on PC (the folder is created the first time you record a macro). This file will be overwritten every time you start recording again.

Open this file in an editor of your choice to study how your actions have been turned into commands, and go from there. There is no documentation (since scripting is not officially supported yet), but if I could get something useful out of analyzing recorded actions, so can you.

The following indented section gives some further detail to those among our readers with ambitions to experiment with Dorico’s Lua scripting capabilities. Everyone else, meet me at the bottom.

The scripting console in Dorico is not merely an output. The field in the lower half of the console can actually be used to write code ad hoc. You could type in a complete script line by line and watch it being executed at the same pace. While this approach is certainly not recommended, the input field offers a way for some mildly clever workarounds to address current limitations; namely that you cannot assign keyboard shortcuts to scripts (with the marginally useful exception of Script > Run Last Script) and that there is no way to influence a script by providing user input in the usual way.

Whenever a script is run by way of the Script menu, it is loaded “into” the environment that the console represents, meaning that any variables and functions that have been declared in the script are still active and can indeed be called and manipulated through the input field.

This is what our script takes advantage of: at the end of the code the main function (called, rather bluntly, makeFakeSlashNotation) is bound to the variable o. The function can now be called by entering o() into the console — a method especially useful if you have several distinct functions that you bind to different one-letter variables. While the latter approach is not exemplified in our script, the fact that you have read this section to this point makes me confident that you have an idea. Calling functions in this way is not as comfortable as actual keyboard shortcuts, but compared with manually loading different scripts from file again and again it is clearly preferable.

Since we can call functions, we can do so while passing variables. Thus we can exploit the input field to make scripts a bit more flexible, taking the step from a rigid macro to a most modest form of data processing. Using our slash notation script by entering o(), the amount by which the stem length gets adjusted will be the default value, suitable for quarter notes. However, calling o(h) will use the value of the variable h instead – h is a mnemonic for “half note”, its value is simply the number for adjusting the stem of such a note appropriately. This also means that entering o(0) (a stem length adjustment of zero) will apply all necessary edits for slash notation except shortening of stems, in case that a distinct rhythm is to be notated instead of mere beats (sometimes called “rhythmic notation”).

Running the script for the first time during your current Dorico session is done via Script > Run Script…, unsurprisingly. Through the upcoming dialogue you specify the file to run; for consistency, I recommend storing the file in Dorico’s own scripting folder (see above), but the file location can be anywhere, really. Upon clicking OK, the script will be loaded and executed. In the case of our particular script — as with probably most of the scripts that will be written for Dorico — the default edits will be applied immediately to any current selection.

As long as you do not load a new file, you can re-run the script via Script > Run Last Script, to which you can assign your own keyboard shortcut. There is, however, another way that is a bit more flexible (if you have read the indented section above, you can skip to the next paragraph, below the animation): you can control the script via Dorico‘s scripting console. It should appear automatically when running a script, but if not, you can make it show via Script > Show Console. Enter o() into the lower field to re-apply the default edits to your current selection. To learn about some modest extra functionality, like how to create rhythmic notation, enter help().

Outlook

It should be said here that the way scripting works in Dorico will very likely be subject to some considerable change in the future. Therefore, it may be not the best use of your time to start working on elaborate function libraries. Nevertheless, some small-scale things are possible right now that can be real time savers.

Whatever the developments for Dorico‘s scripting capabilities will bring in the future, I think it is a safe bet that the script we offer today will not be relevant anymore at that point, as by then the slash notation feature will be implemented in the software itself with the same level of care that we have come to expect by now from the Dorico developers. Until then, feel free to use this little tool to your heart’s delight — but be aware that it is a workaround, with all the usual caveats.

If you have feedback on this script, or indeed if you’ve created one of your own that you think would be helpful, please mention it in the comments!

Comments

  1. Andrew Noah Cap

    A great article. One can easily create a desktop link to the folder ~/Library/Application Support/Steinberg/Dorico/Script plug-ins (on Mac,) or ~\AppData\Roaming\Steinberg\Dorico\Script plug-ins (on PC).

    There you can easily rename the script and then copy it to the installation folder of Dorico/lua/[make your own folder].

    Whenever you start Dorico this will be the default folder when one selects “run script”

  2. Stan Martin

    Alexander, I applaud you sir!!! But I just don’t have the time or motivation to do all this work to have it nullified when Dorico updates this with their own slashes. I will stay with Sibelius until it happens. When I’m facing deadlines, I have to crank it out.

  3. Leigh

    The lack of slash notation in Dorico 1.2.10.139 was preventing me from using for serious work. Having found this script, I can now start using Dorico for production work.

    Thank you so much for posting this wonderful script!!!

Leave a Comment

Your email address will not be published.