@@ -3,33 +3,42 @@ function plugindef()
33 finaleplugin .Author = " Carl Vine"
44 finaleplugin .AuthorURL = " https://carlvine.com/lua/"
55 finaleplugin .Copyright = " https://creativecommons.org/licenses/by/4.0/"
6- finaleplugin .Version = " 0.62 "
7- finaleplugin .Date = " 2024/06/02 "
6+ finaleplugin .Version = " 0.63 "
7+ finaleplugin .Date = " 2024/07/21 "
88 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!
9+ This script converts the __upper__ note of allowable _string harmonic_
10+ dyads (two-note chords) into __diamond__ noteheads.
11+ The first twelve harmonics of the lower _root_ pitch are recognised.
12+
13+ Three other scripts currently in the
14+ [FinaleLua.com ](https://FinaleLua.com) repository
15+ ("_String harmonics_ __X__ _sounding pitch_") take single-pitch
16+ _sounding_ notes and create an equivalent played _string harmonic_ by adding a
17+ __diamond-headed__ _harmonic_ note, and transposing the resulting dyad
18+ downwards by the interval of the harmonic.
1319 ]]
14- return " String Harmonics" , " String Harmonics" ,
15- " Create diamond noteheads on the top note of dyads identified as viable string harmonics"
20+ return " String Harmonics" ,
21+ " String Harmonics" ,
22+ " Identify suitable string harmonic dyads and change the top note to a diamond notehead"
1623end
1724
1825local notehead = require (" library.notehead" )
1926
2027function 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-
28+ -- recognised intervals for string harmonics measured in semitone STEPS,
29+ -- mapped to the corresponding diatonic interval
30+ local allowed = {
31+ [3 ] = 2 , [4 ] = 2 , [5 ] = 3 , [7 ] = 4 ,
32+ [9 ] = 5 , [12 ] = 7 , [16 ] = 9 , [19 ] = 11 ,
33+ [24 ] = 14 , [28 ] = 16 , [31 ] = 18
34+ }
2635 for entry in eachentrysaved (finenv .Region ()) do
27- if entry :IsNote () and (entry .Count == 2 ) then -- only treat 2-note chords
36+ if entry :IsNote () and (entry .Count == 2 ) then -- only treat dyads
2837 local highest = entry :CalcHighestNote (nil )
2938 local lowest = entry :CalcLowestNote (nil )
3039 local midi_diff = highest :CalcMIDIKey () - lowest :CalcMIDIKey ()
31-
32- if allowable [midi_diff ] then -- only permissible intervals
40+ local displacement_diff = highest . Displacement - lowest . Displacement
41+ if allowed [midi_diff ] and allowed [ midi_diff ] == displacement_diff then
3342 finale .FCNoteheadMod ():EraseAt (lowest )
3443 notehead .change_shape (highest , " diamond" )
3544 end
0 commit comments