I suppose a good place to start is with the question “What exactly is Lua?”
Lua is a lightweight computer programming language (the complete Lua distribution could fit on a floppy disk) designed primarily for use within other applications (think plugins) to increase functionality and productivity of the host software program.
Video games are a good example. In recent years, Lua has risen to become a lingua franca for scripting in video games as diverse as World of Warcraft and Angry Birds. For programmers with an interest in this area, this means that your Lua programming skills are transferable from company to company.
Lua’s construct of simple, flexible meta-features can be extended as needed, rather than supplying a feature-set specific to one software program. This makes Lua an ideal and powerful tool for music notation software.
History & Trivia: Lua was created in 1993 by members of the Computer Graphics Technology Group (Tecgraf) at the Pontifical Catholic University of Rio de Janeiro (PUC-Rio), in Brazil. In 2011, Lua was honored with Game Developer Magazine’s Front Line Award in the programming tool category.
‘Lua’ is the Portuguese word for ‘moon’. In Roman mythology, ‘Lua’ was the Goddess to whom soldiers sacrificed captured weapons.
Finale already has a robust Lua scripting environment created by programmer Jari Williamsson called “JW Lua”. Officially still in beta, JW Lua is a plug-in for Finale that runs Lua scripts. These scripts behave as fully-featured plug-ins. No additional software is necessary to write them. (Lua scripts are plaintext files.)
If you have been using Finalescript to script various ancillary tasks in Finale, the first thing you will notice is that Lua is FAST.
A great example of Lua’s speed is the “Split Articulations” script from CJ Garcia and Mark Adler of MakeMusic. This script converts combined articulations such as accent-tenuto, marcato-staccato, and others into separate accent + tenuto, marcato + staccato articulations, to take advantage of the much improved articulation placement of Finale 26.
Scoring Notes recently did a tutorial to help Finale users get up and running with this script. The blog post includes a helpful tutorial for downloading and installing the JW Lua plugin for Finale. My colleague Philip Rothman, who authored the post, observes: “The script is incredibly fast — I used it on a large orchestral score of more than 1000 bars in length, and it took only a second or two.”
Dorico has the beginnings of a framework for Lua scripting support built in. The easiest way to create a Lua script in Dorico 2.0 is by recording a macro; record a series of steps within the program using “Start / Stop Recording Macro” then play the script back using “Run Last Script”. It is also possible to edit these commands, and even save a copy of a specific recorded macro for later recall. The resulting output is a Lua script, saved to a text file.
Go to “Script > Start Recording Macro”. After you have completed recording actions, choose “Script > End Recording Macro”. Your actions were recorded, and can be played back.
Dorico creates a user file called “usermacro.lua” the first time you record some actions. This file will be overwritten every time you start recording a new sequence of events. An enclosing “script plug-ins” folder is also created the first time you record any macro.
However, contents aside, this is just a text file, and you can save a copy of your recorded “usermacro.lua” macro with a different name more suited for the task sequence, then recall it any time later by choosing “Run Script…” from the menu, and selecting your renamed and saved script when the dialog opens.
In case you come up with a really useful macro you want to save as, rename and reuse, the “usermacro.lua” file can be found here (after you record something, of course):
Mac: ~/Library/Application Support/Steinberg/Dorico/Script plug-ins
Windows: ~\AppData\Roaming\Steinberg\Dorico\Script plug-ins
While other music notation software programs such as LilyPond make use of Lua scripting, the goal of this little corner of Of Note will be to share (over time) some of the small useful, yet functional scripts being written in Lua that you can add to your toolbox for both Dorico and Finale. (As of this writing, Sibelius does not support Lua, but rather, uses its own proprietary scripting language for plugins called Manuscript).
If you are Finale or Dorico user, for what I will post here, you probably won’t need to know anything technical beyond some basic things you likely already know about for your music notation program anyway.
If you are a programmer, and are interested in, or are already writing scripts for Finale or Dorico using the Lua scripting language, I’d love to share your efforts related to these music notation software programs on this blog.
Lua.org – the official site for Lua language development.
JW Lua – a high-performance script language for Finale.