@@ -4,8 +4,8 @@ function plugindef()
44 finaleplugin .Author = " Carl Vine"
55 finaleplugin .AuthorURL = " https://carlvine.com/lua"
66 finaleplugin .Copyright = " https://creativecommons.org/licenses/by/4.0/"
7- finaleplugin .Version = " 0.11 "
8- finaleplugin .Date = " 2024/07/17 "
7+ finaleplugin .Version = " 0.12 "
8+ finaleplugin .Date = " 2024/07/20 "
99 finaleplugin .MinJWLuaVersion = 0.70
1010 finaleplugin .Notes = [[
1111 Make dynamic marks in the selection louder or softer by stages.
@@ -42,7 +42,6 @@ local utils = require("library.utils")
4242local library = require (" library.general_library" )
4343local script_name = library .calc_script_name ()
4444local name = plugindef ():gsub (" %.%.%." , " " )
45- local selection
4645local dyn_char = library .is_font_smufl_font () and
4746 { -- char numbers for SMuFL dynamics (1-14)
4847 0xe527 , 0xe528 , 0xe529 , 0xe52a , 0xe52b , 0xe520 , 0xe52c , -- pppppp -> mp
7978
8079local function update_selection ()
8180 local rgn = finenv .Region ()
82- selection = " no staff, no selection" -- default
83- if not rgn :IsEmpty () then
84- selection = get_staff_name (rgn .StartStaff )
81+ if rgn :IsEmpty () then
82+ return " "
83+ else
84+ local s = get_staff_name (rgn .StartStaff )
8585 if rgn .EndStaff ~= rgn .StartStaff then
86- selection = selection .. " -" .. get_staff_name (rgn .EndStaff )
86+ s = s .. " -" .. get_staff_name (rgn .EndStaff )
8787 end
88- selection = selection .. " m." .. rgn .StartMeasure
88+ s = s .. " m." .. rgn .StartMeasure
8989 if rgn .StartMeasure ~= rgn .EndMeasure then
90- selection = selection .. " -" .. rgn .EndMeasure
90+ s = s .. " -" .. rgn .EndMeasure
9191 end
92+ return s
9293 end
9394end
9495
@@ -126,7 +127,8 @@ local function is_hidden_exp(exp_def)
126127end
127128
128129local function change_dynamics (dialog )
129- if finenv .Region ():IsEmpty () then
130+ local selection = update_selection ()
131+ if selection == " " then -- empty region
130132 local ui = dialog and dialog :CreateChildUI () or finenv .UI ()
131133 ui :AlertError (" Please select some music\n before running this script" , name )
132134 return
@@ -161,7 +163,6 @@ local function change_dynamics(dialog)
161163 match_dynamics (true )
162164 match_dynamics (false )
163165 -- start
164- update_selection () -- update current score selection
165166 finenv .StartNewUndoBlock (string.format (" Dynamics %s%d %s" ,
166167 (config .direction == 0 and " +" or " -" ), config .levels , selection )
167168 )
0 commit comments