Cautionary accidental script / plugin advice

Hi everyone. I’ve seen people in several other places requesting expanded functionality for automatic cautionary accidentals, like is available through plugins in Finale. Here’s one such example: https://forums.steinberg.net/t/courtesy-accidentals-automation/978353/2

I know there have also been debates about how necessary they are. I’m not interested in debating that, and I respect anyone who has a difference of opinion. In the scoring world, music is sightread once and then recorded on the next take, and sometimes that’s the only chance players have to get it right. Anything we can do to make their job easier is our job, and cautionary accidentals fall in that category. We typically add cautionary naturals within four bars of a previous sharp or flat. In complex chromatic music across a whole orchestra, providing these manually can take hours of work, and still be incomplete or inconsistent.

Does anyone have a basic concept around how this could be scripted or written into a plugin for Dorico? My understanding is that the built in script functionality uses lua, so I’m sure it’s possible, but it’s all new to me and I could use some input on where to start or how to think about programming it. I’d be willing to invest time into this, and share our results, if we could get it to work. Thanks!

Look under Notation Options for cautionary accidentals. Dorico provides lots of options..

The scripting functionality is very basic, and is not really capable of much beyond a sequence of instructions.
There is no provision for querying the document, e.g. “if note = A”, “if property = hidden”, so logic is extremely limited.

The expert on scripting is @Alexander_Ploetz, who has done some amazing things, however.

Thanks Derrek. The problem is that all of the built in options only work within one bar. That’s not sufficient for our line of work.

Perfect timing since I’m in the middle of a new work and was trying to use CMD-R to force cautionary accidentals by keeping sharps or flats consistent. It didn’t work perfectly. I have to constantly place cautionary accidentals that I notice probably should be there (eg, a D# four bars prior now changed to a D-natural in the same staff) but easily could miss some along the way.

TBH, Finale and its various accidentals plugins (I had three and they all did different things) was probably far worse so I suspect it’s not a trivial thing to program. But it would definitely be helpful, just as a composer let alone having to have people sightread. Thanks.

I’m wondering for what you describe if changing the Accidental duration rule in Notations options to 2nd Viennese school would meet your needs until there is improvement in cautionary accidentals? That way every note has an accidental and your players would always know if a note is sharp, flat or natural.

Hey James, thanks for the idea. While it would work, it would kind of be like hitting a nail with a sledgehammer. The players aren’t used to that and I think it would end up being more disorienting than helpful, unfortunately.

An aside: having composed a number of strict 12-tone works a few decades ago, I’m not sure why they call this rule “2nd Viennese School,” since none of those folks applied accidentals to every note, just when things changed (which, admittedly, were frequent). Here’s part of Schönberg’s late Trio for Strings, which is about as dodecaphonic as one gets, but the use of accidentals is no different from that of Beethoven:

I think that accidentals on every note is more like early Stockhausen, but he didn’t tend to have runs of repeated notes, so I can’t say if he’d place the same accidental on every repeated note (eg, D#-D#-D#-D#-F#-F#). This is from kontra-punkte:

Even Xenakis didn’t have accidentals on every note, even when he probably should have, as in his piano work Mists:

The only example I could readily find in my score collection, since I knew I’d seen this somewhere, was some music by Sorabji. Here’s the opening of his Opus Clavicembalisticum, and in the upper left he specifically states that accidentals only apply to their specific notes except for repeated and tied notes:

And the other one, which I found in Elaine Gould’s book, was from György Kurtág, and he certainly isn’t part of the New Viennese School. Scelsi didn’t do it, nor Lutosławski, nor Donatoni, nor Shapey, Feldman, Dallapiccola, etc.

So aside from two composers, none of whom were in the same galaxy as Schönberg, Berg, Webern, Dallapiccola (not Viennese but he was a fellow traveler), Boulez (same comment), etc, hardly anyone uses that convention and it was never part of any score I know of from the New Vienna School. There are a plethora of accidentals in some 12-tone music, simply because of the use of a series. Here is how Dorico handles a 12-tone section of my most recent work, with the Modernist option for accidentals (my default), which has a lot of accidentals on this page but not on every note:

And now with the 2nd Viennese school option:

Even with the 2nd Viennese school option, not every note has an accidental, which is fine. All I’m saying is that it seems to me that it’s a misnomer to call this convention the “2nd Viennese school” option when none of the 2nd Viennese school composers, nor those who were 2nd Viennese school-adjacent, did that, strictly speaking. They all followed, as best I can tell, the Modernist option as termed in Dorico.

I’ve been asking for additional cautionary accidental settings for years, and would very much like to see some implemented in a future version. For those unfamiliar with Finale’s plug-in, it looks like this:

Courtesy Naturals is nisnamed, as it actually applies courtesy accidentals when there is any return to the key signature accidental after a deviation. If I have an A natural in the key of Eb, then Courtesy Naturals will apply a courtesy flat to an Ab in the next bar for example.

I seem to recall the Key Cancellation setting was pretty buggy, so I usually did that manually, but obviously would be a nice feature to have in Dorico. Dorico is good about this already if the accidentals occur in the following bar …

… but not if there are any bars in between:

The Reset After setting is important too. Here I have 4 (like the OP’s request) but you could put anything you want. I had one client who specified that there should always be a cautionary no matter how much distance between the alteration, so I had it set at 999 or something for their work. A setting to apply cautionaries no matter the distance could be useful for clients like this.

Reset After doesn’t really take into account the issue of multibar rests though. If the devs expand Dorico’s automatic cautionary capabilities, I think there should obviously be a setting to account for a multibar rest like below, regardless of how many bars it actually contains:

I would like an option to account for next bar of entrance as well, no matter the distance or number of multibar rest regions:

It would be great to see Dorico’s capabilities with cautionaries expanded in a future version!

And of course, in choral music, it’s customary to put in a cautionary accidental if another part has a different note, because singers will just follow what they’ve heard regardless… :face_with_tongue:

I always found the default Finale accidentals options to be lacking, which is why I ended up also using a combination of JW Accidentals and TGTools (TGTools was very limited, but it undid some issues where JW would additionally place unnecessary naturals on more things than needed and TGT could undo all those in one fell swoop).

This is not uncommon in chamber music too.

I occasionally do this for instrumental music too, especially if there is a 1/2 step (13th vs 7th, #9 vs 3rd) that ends up enharmonically using the same base note with different accidentals in players that will be next to each other.

I’m sitting here working on a Harp part in Dorico and it occurred to me that the programming behind Dorico’s ability to color pitches as “out of range” when a harp pedal change is necessary would likely be highly related to the programming necessary to create these cautionary accidentals we’re asking for. It’s essentially remembering the accidental state of each pitch and checking that against the next time that same pitch appears, no matter how many bars of music have passed, and no matter which octave/staff the pitch occurs in.

Yes, I agree that the Finale plugins left a lot to be desired. They weren’t perfect, but they still saved hours compared to having to do it manually. Hopefully Dorico can eventually do it right!