First Profile with Console Tools

Automating Trill Tasks in Dorico with Console Tools

Hey everyone,

I recently started learning to use the console tools in Dorico to simplify some complex tasks, and I wanted to share my first “slightly” elaborated profile. This script was developed to address repetitive tasks I often encounter when working with trills, especially in contemporary music. Here are some examples of issues I aimed to solve:

  • Setting the trill note as a natural or artificial harmonic.
  • Create a trill between two identical pitches.
  • Handling microtonal accidentals of the small notes of the trill (natively, we cannot enharmonically respell the small notes of the trill in a microtonal context).

Typically, people seem to resolve these issues by recreating the small note of the trill in another voice. This involves steps like creating the note in another voice, deleting rests, hiding the stem, parenthesizing, scaling the note, etc. To simplify this process, I wrote a script.

The result is a functional script, though I believe there’s room for improvement. For instance, I encountered challenges with selection tools when trying to execute everything in a single command. For example:

  • After creating the trill, the note gets deselected.
  • To reselect the previous note, I used EventEdit.NavigatePreviousItemSamePosition. While this works in my test case, I’m unsure of its reliability. If it selects a tuplet instead of the note, the script won’t work.

Below, I’ve attached a video demonstrating the script and the script itself. Please note that the script is designed to work with the Console Tools framework created by Alexander_Ploetz, and it cannot be run directly from the “Run Script” function.


Script Code

local dorSetHarmonicType=CTL.generateDoricoPropertyChangeFunction("kNoteHarmonicType")
local dorSetPartial=CTL.generateDoricoPropertyChangeFunction("kNoteHarmonic","int")

local createOrnament = CTL.generateStaticDoricoCommandFunction("NoteInput.CreateOrnament")
local createTrill = CTL.generateStaticDoricoCommandFunction("NoteInput.CreateOrnament?Definition=tr&UseLocalOverride=0")
local wigglyLine = CTL.generateDoricoPropertyChangeFunction("kTrillHasWigglyLine")
local trillAppearence = CTL.generateDoricoPropertyChangeFunction("kTrillIntervalAppearance")
local accidentalVisibility = CTL.generateDoricoPropertyChangeFunction("kTrillAccidentalVisibility")
local selectNote = CTL.generateStaticDoricoCommandFunction("EventEdit.NavigatePreviousItemSamePosition")
local copyNote = CTL.generateStaticDoricoCommandFunction("Edit.Copy")
local enter = CTL.generateStaticDoricoCommandFunction("NoteInput.Enter?Set=1")
local nextVoice = CTL.generateStaticDoricoCommandFunction("NoteInput.NextVoice")
local pasteIntoVoice = CTL.generateStaticDoricoCommandFunction("Edit.PasteIntoVoice")
local exitEdit = CTL.generateStaticDoricoCommandFunction("NoteInput.Exit")

local changeDuration = CTL.generateStaticDoricoCommandFunction("NoteInput.NoteValue?LogDuration=kDemiSemiQuaver&Set=true")
local moveRight = CTL.generateStaticDoricoCommandFunction("EventEdit.MoveRightByValue?RhythmicGridResolutionValue=kDemisemiquaver")
local extendRight = CTL.generateStaticDoricoCommandFunction("EventEdit.NavigateRightExtendBar")
local extendLeft = CTL.generateStaticDoricoCommandFunction("EventEdit.NavigateLeftExtendBar")

local filterVoice = CTL.generateStaticDoricoCommandFunction("Filter.VoiceDownstem1")
local removeRest = CTL.generateStaticDoricoCommandFunction("Edit.RemoveRests")
local hideStem = CTL.generateStaticDoricoCommandFunction("Edit.ToggleHideStem")
local roundBrackets = CTL.generateStaticDoricoCommandFunction("Edit.ToggleRoundBracketsForNotehead")
local changeScale = CTL.generateDoricoPropertyChangeFunction("kEventScale")

createOrnament()
createTrill()
wigglyLine("true")
trillAppearence("kAccidental")
accidentalVisibility("kHide")
selectNote()
copyNote()
if(arg1 == "1") then
	diamondNotehead()
end
if(arg1 == "4") then
	dorSetHarmonicType("kArtificial")
	dorSetPartial(4)
end
enter()
nextVoice()
pasteIntoVoice()
exitEdit()
changeDuration()
moveRight()
if(arg1 == "2") then
	diamondNotehead()
end
if(arg1 == "5") then
	dorSetHarmonicType("kArtificial")
	dorSetPartial(4)
end
extendRight()
extendLeft()
filterVoice()
removeRest()
hideStem()
roundBrackets()
changeScale("kCue")

Video Demonstration


If anyone has suggestions for improving this script or handling the selection issues more reliably, I’d greatly appreciate your input!

4 Likes

For obvious reasons, I am more than thrilled to see you showcasing your foray into ConsoleTools.

That being said, I’m a bit puzzled that this should really be the generally acknowledged way of applying micro-tonal trill intervals.

[EDIT: Ah, I see now that you are tackling some very special cases; I’ll let the code below stand, since it may still be found educational.]

Incidentally, I had on my desk an orchestra piece with loads of such trills just last month, for which I cobbled together a draft for quickly setting Dorico’s native trill intervall, and that worked like a charm. Since I don’t have much time right now, I’ll just paste the code from my draft file below, more as an inspiration and certainly not as a ready-to-use implementation. I’ll try to present something more usable at a later time.

 setTrillInterval=function(iIntv,iAcc,o_iDeltaDenominator,o_forceIntervalToShow)

	if l.isBoolean(o_iDeltaDenominator) then
		o_iDeltaDenominator,o_forceIntervalToShow=nil,o_iDeltaDenominator
	end
	local strDelta=tostring(iAcc)..[[/]]..tostring(o_iDeltaDenominator or 12)

	if o_forceIntervalToShow then
		dor([[UI.InvokePropertyChangeValue?Type=kTrillAccidentalVisibility&Value=string: "kShow"]])
	end
	
	dor([[UI.InvokePropertyChangeValue?Type=kTrillInterval&Value=list: {string: "]]..strDelta..[["}\, {int: ]]..tostring(iIntv)..[[}]])

--   1, 1, 24, true		-- Quarter Tone Upwards
--   1, 1,     true		-- Minor Second Upwards
--   1, 2,     true		-- Major Second Upwards
--   0, 0				-- (no note)
--  -1,-1,     true		-- Minor Second Downwards
--  -1,-2,     true		-- Major Second Downwards
--  -2,-3,     true		-- Minor Third Downwards


 end

3 Likes

Thank you very much for taking your time to answer! I am really happy about Console Tools and excited to keep learning more about it. Thanks for the code snippet; it’s very useful to see how to implement this effectively.

However, as you noticed, I wanted to tackle some special cases. For example, in microtonal contexts, I sometimes encounter several enharmonic microtones, such as 1/4 sharp being the same as 3/4 flat, or arrow accidentals being enharmonic equivalents of non-arrow accidentals. In these cases, since enharmonic spelling is not possible, I decided to develop a script to handle these situations.

This is one of the key reasons for the script I’m working on. Still, the script you shared is very interesting as it demonstrates a better structure and organization of the code. It’s definitely something I’ll learn from as I continue refining my approach.

Arnau

1 Like

I approached the problem of enharmonic spelling for microtonal trill auxiliary notes by setting up a derivative Tonality System that had the respective microtonal accidentals removed that Dorico defaults to, so that the spelling of such a microtonal delta would revert to the next accidental in line. This Tonality System can then be applied locally to a passage where needed, and the trill note will have the intended accidental. This is still pretty much a hack, but it certainly is much less hassle than faking the note in another voice.

Speaking strictly as an editor, I would probably argue for handling the other two cases (different noteheads / identical pitch) as tremolo notations, as they are pretty removed from the conventional concept of a trill. However, I realise that this won’t always be possible, for a variety of reasons.

1 Like

Yes, for microtonal trills, I think your approach is better since it’s less complicated than creating a second voice, which obviously won’t work if there’s already something in that voice, among other problems.

Yes, I kind of agree that it is obvious that those do not totally fit the concept of a trill. Sometimes I find myself using a tremolo for those cases, but there are situations where the clearer notation is the trill one. For example, if there is a bow tremolo at the same time, it can get confusing. Also, in complex rhythms, I find the trill notation to be rhythmically simpler to read than the tremolo notation.