Skip to content

Commit 3026cff

Browse files
chore: autopublish 2024-07-20T14:00:12Z
1 parent 1d290d3 commit 3026cff

File tree

2 files changed

+72
-89
lines changed

2 files changed

+72
-89
lines changed

dist/pitch_changer.lua

Lines changed: 71 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5300,8 +5300,8 @@ function plugindef()
53005300
finaleplugin.Author = "Carl Vine"
53015301
finaleplugin.AuthorURL = "https://carlvine.com/lua/"
53025302
finaleplugin.Copyright = "CC0 https://creativecommons.org/publicdomain/zero/1.0/"
5303-
finaleplugin.Version = "0.35"
5304-
finaleplugin.Date = "2024/05/04"
5303+
finaleplugin.Version = "0.39"
5304+
finaleplugin.Date = "2024/07/05"
53055305
finaleplugin.AdditionalMenuOptions = [[
53065306
Pitch Changer Repeat
53075307
]]
@@ -5322,26 +5322,22 @@ function plugindef()
53225322
2017 plug-in to work on Macs with non-Intel processors.
53235323
53245324
Identify __from__ and __to__ pitches by note name (__a-g__ or __A-G__)
5325-
followed by accidental (#-##-###, b-bb-bbb) as required.
5325+
followed by accidental (__bbb/bb/b__ ... __#/##/###__) as required.
53265326
Matching pitches will be changed in every octave.
53275327
For transposing instruments on transposing scores select
53285328
__Written Pitch__ to affect the pitch you see on screen.
53295329
To repeat the last change without a confirmation dialog use
5330-
the _Pitch Changer Repeat_ menu or hold down [Shift] when opening the script.
5330+
the _Pitch Changer Repeat_ menu or hold down [_Shift_] when opening the script.
53315331
5332-
Select __Modeless__ if you prefer the dialog window to
5333-
"float" above your score so you can change the score selection
5334-
while it remains active. In this mode, click __Apply__ [Return/Enter]
5335-
to make changes and __Cancel__ [Escape] to close the window.
5332+
Select __Modeless Dialog__ if you want the dialog window to persist
5333+
on-screen for repeated use until you click _Cancel_ [_Escape_].
53365334
Cancelling __Modeless__ will apply the _next_ time you use the script.
53375335
53385336
> __Key Commands:__
53395337
5340-
> - __a-g__ (__A-G__): Note Names
5341-
> - __0-4__: Layer number (delete key not needed)
5342-
> - __z__: Direction Closest
5343-
> - __x__: Direction Up
5344-
> - __v__: Direction Down
5338+
> - __A__-__G__: Note Names (automatically capitalised)
5339+
> - __0__-__4__: Layer number (delete key not needed)
5340+
> - __z__: Toggle "Direction" Mode
53455341
> - __w__: Swap the __From:__ and __To:__ values
53465342
> - __s__: Shortcut for __#__
53475343
> - __m__: Toggle the __Modeless__ setting
@@ -5355,14 +5351,12 @@ function plugindef()
53555351
\fs18
53565352
{\info{\comment "os":"mac","fs18":"fs24","fs26":"fs32","fs23":"fs29","fs20":"fs26"}}
53575353
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 This script revives Jari Williamsson\u8217's {\i JW Change Pitches} 2017 plug-in to work on Macs with non-Intel processors.\par}
5358-
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 Identify {\b from} and {\b to} pitches by note name ({\b a-g} or {\b A-G}) followed by accidental (#-##-###, b-bb-bbb) as required. Matching pitches will be changed in every octave. For transposing instruments on transposing scores select {\b Written Pitch} to affect the pitch you see on screen. To repeat the last change without a confirmation dialog use the {\i Pitch Changer Repeat} menu or hold down [Shift] when opening the script.\par}
5359-
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 Select {\b Modeless} if you prefer the dialog window to \u8220"float\u8221" above your score so you can change the score selection while it remains active. In this mode, click {\b Apply} [Return/Enter] to make changes and {\b Cancel} [Escape] to close the window. Cancelling {\b Modeless} will apply the {\i next} time you use the script.\par}
5354+
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 Identify {\b from} and {\b to} pitches by note name ({\b a-g} or {\b A-G}) followed by accidental ({\b bbb/bb/b} \u8230? {\b #/##/###}) as required. Matching pitches will be changed in every octave. For transposing instruments on transposing scores select {\b Written Pitch} to affect the pitch you see on screen. To repeat the last change without a confirmation dialog use the {\i Pitch Changer Repeat} menu or hold down [{\i Shift}] when opening the script.\par}
5355+
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 Select {\b Modeless Dialog} if you want the dialog window to persist on-screen for repeated use until you click {\i Cancel} [{\i Escape}]. Cancelling {\b Modeless} will apply the {\i next} time you use the script.\par}
53605356
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li720 \fi0 {\b Key Commands:}\par}
5361-
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b a-g} ({\b A-G}): Note Names\par}
5362-
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b 0-4}: Layer number (delete key not needed)\par}
5363-
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b z}: Direction Closest\par}
5364-
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b x}: Direction Up\par}
5365-
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b v}: Direction Down\line \par}
5357+
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b A}-{\b G}: Note Names (automatically capitalised)\par}
5358+
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b 0}-{\b 4}: Layer number (delete key not needed)\par}
5359+
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b z}: Toggle \u8220"Direction\u8221" Mode\par}
53665360
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b w}: Swap the {\b From:} and {\b To:} values\par}
53675361
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b s}: Shortcut for {\b #}\par}
53685362
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b m}: Toggle the {\b Modeless} setting\par}
@@ -5375,30 +5369,29 @@ function plugindef()
53755369
end
53765370
repeat_change = repeat_change or false
53775371
local hotkey = {
5378-
Closest = "Z",
5379-
Up = "X",
5380-
Down = "V",
5381-
Swap = "W",
5382-
Modeless = "M",
5383-
Written = "R",
5384-
Show_Info = "Q",
5372+
direction = "Z",
5373+
swap = "W",
5374+
sharp = "S",
5375+
modeless = "M",
5376+
written = "R",
5377+
show_info = "Q",
53855378
}
53865379
local directions = { "Closest", "Up", "Down" }
53875380
for i, v in ipairs(directions) do
5388-
directions[i] = string.format("%s (%s)", v, hotkey[v]:lower())
5381+
directions[i] = string.format("%s (%s)", v, hotkey.direction:lower())
53895382
end
53905383
local config = {
5391-
find_string = "F#",
5392-
find_pitch = "F",
5393-
find_offset = 1,
5394-
new_string = "Eb",
5395-
new_pitch = "E",
5396-
new_offset = -1,
5397-
direction = 1,
5398-
layer_num = 0,
5384+
find_string = "F#",
5385+
find_pitch = "F",
5386+
find_offset = 1,
5387+
new_string = "Eb",
5388+
new_pitch = "E",
5389+
new_offset = -1,
5390+
direction = 1,
5391+
layer_num = 0,
53995392
written_pitch = false,
5400-
timer_id = 1,
5401-
modeless = false,
5393+
timer_id = 1,
5394+
modeless = false,
54025395
window_pos_x = false,
54035396
window_pos_y = false,
54045397
}
@@ -5411,10 +5404,6 @@ local script_name = library.calc_script_name()
54115404
local refocus_document = false
54125405
local selection
54135406
local saved_bounds = {}
5414-
local bounds = {
5415-
"StartStaff", "StartMeasure", "StartMeasurePos",
5416-
"EndStaff", "EndMeasure", "EndMeasurePos",
5417-
}
54185407
local function dialog_set_position(dialog)
54195408
if config.window_pos_x and config.window_pos_y then
54205409
dialog:StorePosition()
@@ -5438,7 +5427,10 @@ local function get_staff_name(staff_num)
54385427
return str
54395428
end
54405429
local function track_selection()
5441-
5430+
local bounds = {
5431+
"StartStaff", "StartMeasure", "StartMeasurePos",
5432+
"EndStaff", "EndMeasure", "EndMeasurePos",
5433+
}
54425434
local rgn = finenv.Region()
54435435
for _, property in ipairs(bounds) do
54445436
saved_bounds[property] = rgn[property]
@@ -5471,30 +5463,31 @@ end
54715463
local function octave_direction()
54725464
local find = string.byte(config.find_pitch) - 67
54735465
local new = string.byte(config.new_pitch) - 67
5474-
local find_off, new_off = config.find_offset, config.new_offset
5466+
local diff = new - find
54755467
local oct = 0
5468+
if find >= 0 and new < 0 then oct = -1
5469+
elseif find < 0 and new >= 0 then oct = 1
5470+
end
54765471
if config.direction == 1 then
5477-
if ((find - new) > 3 and (new_off < 0)) then
5478-
oct = 1
5479-
elseif ((new - find) > 3 and (find_off < 0)) then
5480-
oct = -1
5481-
end
5482-
elseif config.direction == 2 then
5483-
if (find < 0 and new > 0) or
5484-
(new < find and (find < 0 or new >= 0)) or
5485-
(new == find and new_off < find_off) then
5486-
oct = 1
5487-
end
5488-
else
5489-
if (new < 0 and find > 0) or
5490-
(new > find and (find >= 0 or new < 0)) or
5491-
(new == find and new_off > find_off) then
5492-
oct = -1
5472+
if diff > 3 then oct = oct - 1
5473+
elseif diff < -3 then oct = oct + 1
54935474
end
5475+
elseif config.direction == 2 and diff < 0 then
5476+
oct = oct + 1
5477+
elseif config.direction == 3 and diff > 0 then
5478+
oct = oct - 1
54945479
end
54955480
return oct
54965481
end
5497-
local function change_the_pitches()
5482+
local function change_the_pitches(dialog)
5483+
if finenv.Region():IsEmpty() then
5484+
local ui = dialog and dialog:CreateChildUI() or finenv.UI()
5485+
ui:AlertError(
5486+
"Please select some music\nbefore running this script",
5487+
finaleplugin.ScriptGroupName
5488+
)
5489+
return
5490+
end
54985491
finenv.StartNewUndoBlock(
54995492
string.format("Pitch Change %s-%s %s",
55005493
config.find_string, config.new_string, selection)
@@ -5535,7 +5528,7 @@ local function run_the_dialog()
55355528

55365529
local function yd(diff) y = y + (diff or 25) end
55375530
local function Show_Info()
5538-
utils.show_notes_dialog(dialog, "About " .. name, 420, 430)
5531+
utils.show_notes_dialog(dialog, "About " .. name, 400, 370)
55395532
refocus_document = true
55405533
end
55415534
local function cstat(horiz, vert, wide, str)
@@ -5555,15 +5548,15 @@ local function run_the_dialog()
55555548
if (kind == "layer" and s:find("[^0-4]"))
55565549
or (kind ~= "layer" and s:find("[^A-G#]")) then
55575550

5558-
if s:find(hotkey.Closest) then pitch.popup:SetSelectedItem(0)
5559-
elseif s:find(hotkey.Up) then pitch.popup:SetSelectedItem(1)
5560-
elseif s:find(hotkey.Down) then pitch.popup:SetSelectedItem(2)
5561-
elseif s:find("S") and kind ~= "layer" then
5562-
save_text[kind] = s:gsub("S", "#")
5563-
elseif s:find(hotkey.Swap) then value_swap()
5564-
elseif s:find(hotkey.Show_Info) then Show_Info()
5565-
elseif s:find(hotkey.Modeless) then toggle_check("modeless")
5566-
elseif s:find(hotkey.Written) then toggle_check("written_pitch")
5551+
if s:find(hotkey.direction) then
5552+
local n = pitch.popup:GetSelectedItem()
5553+
pitch.popup:SetSelectedItem((n + 1) % 3)
5554+
elseif s:find(hotkey.sharp) and kind ~= "layer" then
5555+
save_text[kind] = s:gsub(hotkey.sharp, "#")
5556+
elseif s:find(hotkey.swap) then value_swap()
5557+
elseif s:find(hotkey.show_info) then Show_Info()
5558+
elseif s:find(hotkey.modeless) then toggle_check("modeless")
5559+
elseif s:find(hotkey.written) then toggle_check("written_pitch")
55675560
end
55685561
else
55695562
s = (kind == "layer") and s:sub(-1) or (s:sub(1, 1) .. s:sub(2):lower())
@@ -5624,33 +5617,30 @@ local function run_the_dialog()
56245617
yd(14)
56255618
ctl.info = dialog:CreateStatic(16, y):SetText(selection):SetWidth(x_pos[4] + 65)
56265619

5627-
dialog:CreateOkButton():SetText(config.modeless and "Apply" or "Change")
5628-
dialog:CreateCancelButton()
5620+
dialog:CreateOkButton() :SetText(config.modeless and "Apply" or "Change")
5621+
dialog:CreateCancelButton():SetText(config.modeless and "Close" or "Cancel")
56295622
dialog:RegisterInitWindow(function(self)
5630-
self:SetOkButtonCanClose(not config.modeless)
56315623
if config.modeless then self:SetTimer(config.timer_id, 125) end
56325624
local bold = ctl.from:CreateFontInfo():SetBold(true)
5633-
ctl.from:SetFont(bold)
5634-
ctl.to:SetFont(bold)
5635-
ctl.direction:SetFont(bold)
5625+
for _, v in ipairs{"from", "to", "direction", "q"} do ctl[v]:SetFont(bold) end
56365626
pitch.find:SetKeyboardFocus()
56375627
end)
56385628
local change_mode, user_error = false, false
56395629
dialog_set_position(dialog)
56405630
if config.modeless then dialog:RegisterHandleTimer(on_timer) end
56415631
dialog:RegisterHandleOkButtonPressed(function()
56425632
errors = {}
5643-
local good_name1, good_name2 = encode_pitches("find"), encode_pitches("new")
5644-
if good_name1 and good_name2 then
5633+
local good1, good2 = encode_pitches("find"), encode_pitches("new")
5634+
if good1 and good2 then
56455635
config.layer_num = pitch.layer:GetInteger()
56465636
config.direction = pitch.popup:GetSelectedItem() + 1
56475637
config.written_pitch = (ctl.written_pitch:GetCheck() == 1)
5648-
change_the_pitches()
5638+
change_the_pitches(dialog)
56495639
else
56505640
local msg = (#errors > 1) and
56515641
"These pitch names are invalid:\n" or "This pitch name is invalid:\n"
56525642
msg = "Pitch names cannot be empty and must start "
5653-
.. "with a single note name (a-g or A-G) followed by "
5643+
.. "with a single note name (A-G) followed by "
56545644
.. "accidentals (#-###, b-bbb) as required.\n\n"
56555645
.. msg .. table.concat(errors, "; ")
56565646
dialog:CreateChildUI():AlertError(msg, name .. " Error")
@@ -5674,13 +5664,6 @@ local function run_the_dialog()
56745664
end
56755665
local function change_pitch()
56765666
configuration.get_user_settings(script_name, config, true)
5677-
if not config.modeless and finenv.Region():IsEmpty() then
5678-
finenv.UI():AlertError(
5679-
"Please select some music\nbefore running this script.",
5680-
finaleplugin.ScriptGroupName
5681-
)
5682-
return
5683-
end
56845667
local qim = finenv.QueryInvokedModifierKeys
56855668
local mod_key = qim and (qim(finale.CMDMODKEY_ALT) or qim(finale.CMDMODKEY_SHIFT))
56865669
track_selection()

hash/pitch_changer.hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
593534da7dda7dcd11f1b9a3810956c94f27c6462c4bfbfbbb3565d3bd708d7e565278c2af3f958104de128daf4d608f4a51744f5a66d1b039f8bc6a43e171ce pitch_changer.lua
1+
51c0a19f17334b3d56811672a4914cca4b35b0b3c74a66f9a8f5a866670acbba553af812a82a271ab8ef3de5c22cdb68d6357a7c991c4674c320414fa0361952 pitch_changer.lua

0 commit comments

Comments
 (0)