Skip to content

Commit 78b9feb

Browse files
committed
Create pitch_entry_delete_nth_note.lua
- This script fulfills a request from Tim Davies for a way to quickly delete something like the 2nd or 3rd note in a chord. The script opens a dialog box to enter the note to be deleted (numbered from the top) - I also used the functions for keeping/deleting top/bottom notes from Nick Mazuk's scripts - Passes lint tests from the 'linting' PR
1 parent 3c7704a commit 78b9feb

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

src/pitch_entry_delete_nth_note.lua

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
function plugindef()
2+
finaleplugin.RequireSelection = true
3+
finaleplugin.Author = "Jacob Winkler, Nick Mazuk"
4+
finaleplugin.AuthorEmail = "[email protected]"
5+
finaleplugin.Copyright = "CC0 https://creativecommons.org/publicdomain/zero/1.0/"
6+
finaleplugin.Version = "1.0"
7+
finaleplugin.Date = "2024-01-26"
8+
finaleplugin.CategoryTags = "Pitch"
9+
finaleplugin.Notes = [[
10+
USING THE 'DELETE Nth NOTE' SCRIPT
11+
12+
This script allows the user to select a note within a chord to delete, as numbered form the top. Entering "1" will delete the top note, "2" will delete the 2nd note from the top, entering "3" the third, and so on.
13+
14+
This script also replicates Nick Mazuk's functions for deleting or keeping the top or bottom note in a chord.
15+
16+
To access these functions, enter the following commands:
17+
18+
"top" - Deletes the top note in the chord
19+
"bottom" or "btm" - Deletes the bottom note in the chord
20+
"keeptop" - Keeps the top note in the chord, deleting all others
21+
"keepbottom" or "keepbtm" - Keeps the bottom note in the chord, deleting all others.
22+
]]
23+
return "Chord: Delete nth note", "Chord: Delete nth note", "Deletes a user selected note"
24+
end
25+
26+
local note_entry = require("library.note_entry")
27+
local library = require("library.general_library")
28+
29+
function pitch_entry_delete_n_note(n)
30+
for entry in eachentrysaved(finenv.Region()) do
31+
if (entry.Count >= 2) then
32+
local target = entry.Count - n
33+
local i = 0
34+
for note in each(entry) do
35+
if i == target then
36+
note_entry.delete_note(note)
37+
end
38+
i = i + 1
39+
end
40+
end
41+
end
42+
end
43+
44+
function pitch_entry_delete_bottom_note()
45+
for entry in eachentrysaved(finenv.Region()) do
46+
if (entry.Count >= 2) then
47+
local bottom_note = entry:CalcLowestNote(nil)
48+
note_entry.delete_note(bottom_note)
49+
end
50+
end
51+
end
52+
53+
function pitch_entry_keep_bottom_note()
54+
for entry in eachentrysaved(finenv.Region()) do
55+
while (entry.Count >= 2) do
56+
local top_note = entry:CalcHighestNote(nil)
57+
note_entry.delete_note(top_note)
58+
end
59+
end
60+
end
61+
62+
function pitch_entry_keep_top_note()
63+
for entry in eachentrysaved(finenv.Region()) do
64+
while (entry.Count >= 2) do
65+
local bottom_note = entry:CalcLowestNote(nil)
66+
note_entry.delete_note(bottom_note)
67+
end
68+
end
69+
end
70+
71+
local n = library.simple_input("Delete nth note", "Note to delete (numbered from top)") or 0
72+
73+
if n == "top" then
74+
n = 1
75+
pitch_entry_delete_n_note(n)
76+
elseif n == "bottom" or n == "btm" then
77+
pitch_entry_delete_bottom_note()
78+
elseif n == "keeptop" then
79+
pitch_entry_keep_top_note()
80+
elseif n == "keepbottom" or n == "keepbtm" then
81+
pitch_entry_keep_bottom_note()
82+
else
83+
pitch_entry_delete_n_note(n)
84+
end

0 commit comments

Comments
 (0)