Skip to content

Commit 8546c8f

Browse files
committed
Create string_harmonics.lua
Create diamond noteheads on the top note of dyads identified as viable string harmonics. I use this script __a lot__ and just noticed that its exact functionality is not available in the Repo. It is only provided in the full commercial version of TGTools, not the inbuilt version.
1 parent 03d7416 commit 8546c8f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/string_harmonics.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function plugindef()
2+
finaleplugin.RequireSelection = true
3+
finaleplugin.Author = "Carl Vine"
4+
finaleplugin.AuthorURL = "https://carlvine.com/lua/"
5+
finaleplugin.Copyright = "https://creativecommons.org/licenses/by/4.0/"
6+
finaleplugin.Version = "0.62"
7+
finaleplugin.Date = "2024/06/02"
8+
finaleplugin.Notes = [[
9+
Create diamond noteheads on the top note of dyads identified as viable string harmonics.
10+
Note that this uses MIDI note values to identify acceptable intervals to
11+
avoid the complications of key signatures and transposing instruments.
12+
This is inelegant but simple and should work in most situations!
13+
]]
14+
return "String Harmonics", "String Harmonics",
15+
"Create diamond noteheads on the top note of dyads identified as viable string harmonics"
16+
end
17+
18+
local notehead = require("library.notehead")
19+
20+
function string_harmonics()
21+
-- allowable intervals for string harmonics, measured in interval STEPS
22+
local allowed = { 3, 4, 5, 7, 9, 12, 16, 19, 24, 28, 31 }
23+
local allowable = {}
24+
for _, v in ipairs(allowed) do allowable[v] = true end
25+
26+
for entry in eachentrysaved(finenv.Region()) do
27+
if entry:IsNote() and (entry.Count == 2) then -- only treat 2-note chords
28+
local highest = entry:CalcHighestNote(nil)
29+
local lowest = entry:CalcLowestNote(nil)
30+
local midi_diff = highest:CalcMIDIKey() - lowest:CalcMIDIKey()
31+
32+
if allowable[midi_diff] then -- only permissible intervals
33+
finale.FCNoteheadMod():EraseAt(lowest)
34+
notehead.change_shape(highest, "diamond")
35+
end
36+
end
37+
end
38+
end
39+
40+
string_harmonics()

0 commit comments

Comments
 (0)