Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathnotes_tie.lua
More file actions
Latest commit
75 lines (70 loc) · 3.18 KB
/
Copy pathnotes_tie.lua
File metadata and controls
75 lines (70 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
functionplugindef()
finaleplugin.RequireSelection=true
finaleplugin.Author="Carl Vine and Robert Patterson"
finaleplugin.Copyright="CC0 https://creativecommons.org/publicdomain/zero/1.0/"
finaleplugin.Version="v0.76"
finaleplugin.Date="2022/08/01"
finaleplugin.AdditionalMenuOptions=[[
Untie Notes
]]
finaleplugin.AdditionalUndoText=[[
Untie Notes
]]
finaleplugin.AdditionalPrefixes=[[
untie_notes = true
]]
finaleplugin.AdditionalDescriptions=[[
Untie all notes in the selected region
]]
finaleplugin.MinJWLuaVersion=0.62
finaleplugin.ScriptGroupName="Tie/untie notes"
finaleplugin.ScriptGroupDescription="Tie or untie suitable notes in the current selection"
finaleplugin.Notes=[[
Ties notes in adjacent entries if matching pitches are available.
A companion menu item is also created to `Untie` all notes in the selection.
]]
return"Tie Notes", "Tie Notes", "Tie suitable notes in the selected region"
end
-- default to "tie" notes for normal operation
untie_notes=untie_notesorfalse
localtie=require('library.tie')
localfunctiontie_notes_in_selection()
localregion=finenv.Region()
forslot=region.StartSlot, region.EndSlotdo
localstaff_number=region:CalcStaffNumber(slot)
forlayer_number=0, 3do-- run through layers [0-based]
localentry_layer=finale.FCNoteEntryLayer(layer_number, staff_number, region.StartMeasure, region.EndMeasure)
entry_layer:Load()
forentryineach(entry_layer) do
ifentry:IsNote() andregion:IsEntryPosWithin(entry) then
fornoteineach(entry) do
ifuntie_notesthen
ifnote.TieBackwardsthen
local_, start_note=tie.calc_tie_span(note, true)
ifnotstart_noteorregion:IsEntryPosWithin(start_note.Entry) ornotstart_note.Tiethen
note.TieBackwards=false
finale.FCTieMod(finale.TIEMODTYPE_TIEEND):EraseAt(note)
end
end
ifnote.Tiethen
local_, _, end_note=tie.calc_tie_span(note, false)
ifnotend_noteorregion:IsEntryPosWithin(end_note.Entry) ornotend_note.TieBackwardsthen
note.Tie=false
finale.FCTieMod(finale.TIEMODTYPE_TIESTART):EraseAt(note)
end
end
else
localtied_to_note=tie.calc_tied_to(note)
iftied_to_noteandregion:IsEntryPosWithin(tied_to_note.Entry) then
note.Tie=true
tied_to_note.TieBackwards=true
end
end
end
end
end
entry_layer:Save()
end
end
end
tie_notes_in_selection()