Skip to content

Commit 3557fbf

Browse files
committed
Update ties_remove_dangling.lua
Added ability to replace dangling ties with slur (as menu option)
1 parent 637e3f5 commit 3557fbf

File tree

1 file changed

+52
-27
lines changed

1 file changed

+52
-27
lines changed

src/ties_remove_dangling.lua

+52-27
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,61 @@
11
function plugindef()
2-
-- This function and the 'finaleplugin' namespace
3-
-- are both reserved for the plug-in definition.
4-
finaleplugin.Author = "Jacob Winkler"
5-
finaleplugin.Copyright = "2022"
6-
finaleplugin.Version = "1.0.1"
7-
finaleplugin.Date = "2022-08-26"
8-
finaleplugin.RequireSelection = true
9-
finaleplugin.AuthorEmail = "[email protected]"
10-
return "Ties: Remove Dangling", "Ties: Remove Dangling", "Removes dangling ties (ties that go nowhere)."
2+
-- This function and the 'finaleplugin' namespace
3+
-- are both reserved for the plug-in definition.
4+
finaleplugin.Author = "Jacob Winkler"
5+
finaleplugin.Copyright = "2022"
6+
finaleplugin.Version = "1.1"
7+
finaleplugin.Date = "2022-09-04"
8+
finaleplugin.AuthorEmail = "[email protected]"
9+
finaleplugin.AdditionalMenuOptions = [[
10+
Ties: Replace Dangling w/Slurs
11+
]]
12+
finaleplugin.AdditionalUndoText = [[
13+
Ties: Replace Dangling w/Slurs
14+
]]
15+
finaleplugin.AdditionalDescriptions = [[
16+
Removes dangling ties and replaces them with slurs
17+
]]
18+
finaleplugin.AdditionalPrefixes = [[
19+
replace_with_slur = true
20+
]]
21+
finaleplugin.Notes = [[
22+
TIES: REMOVE DANGLING
23+
24+
This script will search for 'dangling ties' - ties that go to rests rather than other notes - and either remove them or replace them with slurs.
25+
]]
26+
return "Ties: Remove Dangling", "Ties: Remove Dangling", "Removes dangling ties (ties that go nowhere)."
1127
end
1228

13-
local tie = require("library.tie")
29+
replace_with_slur = replace_with_slur or false
30+
31+
local tie = require("tie")
32+
local smartshape = require("smartshape")
1433

1534
local music_region = finale.FCMusicRegion()
16-
music_region:SetCurrentSelection()
35+
music_region:SetFullDocument()
1736

1837
for working_staff = music_region:GetStartStaff(), music_region:GetEndStaff() do
19-
for layer_num = 0, 3, 1 do
20-
local note_entry_layer = finale.FCNoteEntryLayer(layer_num, working_staff, music_region.StartMeasure, music_region.EndMeasure)
21-
note_entry_layer:Load()
22-
for index = 0, note_entry_layer.Count-1, 1 do
23-
local entry = note_entry_layer:GetRegionItemAt(index, music_region)
24-
if entry and entry:IsTied() then
25-
for note in each(entry) do
26-
local tie_must_exist = true
27-
local tied_note = tie.calc_tied_to(note, tie_must_exist)
28-
if not tied_note then
29-
note.Tie = false
30-
end
31-
end
32-
end
38+
for layer_num = 0, 3, 1 do
39+
local note_entry_layer = finale.FCNoteEntryLayer(layer_num, working_staff, music_region.StartMeasure, music_region.EndMeasure)
40+
note_entry_layer:Load()
41+
for index = 0, note_entry_layer.Count-1, 1 do
42+
local entry = note_entry_layer:GetRegionItemAt(index, music_region)
43+
if entry and entry:IsTied() then
44+
for note in each(entry) do
45+
local tie_must_exist = true
46+
local tied_note = tie.calc_tied_to(note, tie_must_exist)
47+
if not tied_note then
48+
note.Tie = false
49+
if replace_with_slur then
50+
local next_entry = note_entry_layer:GetRegionItemAt(index + 1, music_region)
51+
if next_entry then
52+
smartshape.add_entry_based_smartshape(entry, next_entry)
53+
end
54+
end
55+
end
56+
end
57+
end
58+
end
59+
note_entry_layer:Save()
3360
end
34-
note_entry_layer:Save()
35-
end
3661
end

0 commit comments

Comments
 (0)