New post
Avatar
0

I have one of the general JW Lua scripts (also should work in RGP Lua) that takes notes in a selected measure and converts them to artificial string harmonics with the harmonic notated at the perfect fourth. That is, it takes the sounding notes as written and converts them to the artificial harmonics (two octaves down with a perfect fourth added as a diamond head). It’s one of Nick Mazuk’s scripts here. Very handy.

But today I started a new work and am using a SMuFL music font (Petaluma) and the fourth is notated with one of those humongous circles that usually result when a font character/glyph isn’t located. My fix (clunky though it is) was to use JW Change, replace it with a standard note head then apply TGTools to make it into harmonics. At least the transposition was done correctly by the Lua script.

But that says to me that many Lua scripts may not work properly with SMuFL. I know some of the JW Change functions do not, but didn’t realize that some of the Lua scripts may not work properly either if they need to create a specific character that is based on the pre-SMuFL conventions.

I’m going to dig into the script and see if I can figure out how to make it work, but just wanted to mention this issue. I’ll also apprise Nick. 

7 comments

Date Votes
Avatar
0

SMuFL uses different characters. You need to find a spot to add this to the script, which should work in RGP as well as JW.

local diamond_head = 79 -- non-SMuFL character
local font_info = finale.FCFontInfo()
font_info:LoadFontPrefs(finale.FONTPREF_MUSIC)
-- Finale version 27+ and RGPLua suitable?
if finenv.RawFinaleVersion >= 10027 and font_info.IsSMuFLFont then
    diamond_head = 0xe0e1   -- SMuFL version of char
end

Comment actions Permalink
Avatar
0

Of course! Why didn’t I see that?

 

I am absolutely in awe of you folks who can not only conceive of that, but make it work. Were I wearing a hat, it would be off to you.

Comment actions Permalink
Avatar
0

Although he uses it differently, I borrowed those elements from Nick Mazuk's script "pitch_transform_harmonics_fourth.lua" - part of his FinaleLua script set. (https://www.finalelua.com)

Comment actions Permalink
Avatar
0

That was the guidance I was looking for in terms of what to insert into Nick's script. However, I've not been able to get it to work (I tried inserting the additional code into the script and it is not providing a harmonic character, just the large O as before).

Here is the code for the .lua script (this is the one I've been using, which uses a perfect fourth). Any suggestions where to place the additional code? Thanks. 

 

function plugindef()
    finaleplugin.RequireSelection = true
    finaleplugin.Author = "Nick Mazuk"
    finaleplugin.Copyright = "©2020 Nick Mazuk"
    finaleplugin.AuthorURL = "https://nickmazuk.com"
    finaleplugin.Version = "0.1"
    finaleplugin.Date = "3/29/2020"
    return "String Harmonics 4th - Sounding Pitch", "String Harmonics 4th - Sounding Pitch", "Takes a sounding pitch, then creates the artificial harmonic that would produce that pitch"
end

function changeoctave(pitchstring, n)
    pitchstring.LuaString = pitchstring.LuaString:sub(1, -2) .. (tonumber(string.sub(pitchstring.LuaString, -1)) + n)
    return pitchstring
end

function updiatonicfourth(pitchstring)
    local letters = "ABCDEFGABCDEFG"
    local notenamepos = letters:find(pitchstring.LuaString:sub(1,1))
    local newnote = letters:sub(notenamepos + 3, notenamepos + 3)
    pitchstring.LuaString = newnote .. pitchstring.LuaString:sub(2)

    -- transposes everything an octave higher if necessary
    if(notenamepos >= 7) or notenamepos <= 2 then
        pitchstring = changeoctave(pitchstring, 1)
    end
    return pitchstring
end

function deletecirclearticulation(entry)
    local artics = entry:CreateArticulations()
        for a in eachbackwards(artics) do
            local defs = a:CreateArticulationDef()
            print(defs:GetAboveSymbolChar())
            if defs:GetAboveSymbolChar() == 111 then
                a:DeleteData()
            end
        end
end


function main() 
    for entry in eachentrysaved(finenv.Region()) do
        -- only process 1-note entries
        if (entry.Count == 1) then 
            deletecirclearticulation(entry)
            
            local note = entry:CalcLowestNote(nil)
            local pitchstring = finale.FCString()
            local measure = entry:GetMeasure()
            measureobject = finale.FCMeasure()
            measureobject:Load(measure)
            local keysig = measureobject:GetKeySignature()
            note:GetString(pitchstring, keysig, false, false)
            pitchstring = changeoctave(pitchstring, -2)
            note:SetString(pitchstring, keysig, false)
            
            local newnote = entry:AddNewNote()
            newnote.Tie = note.Tie
        
            -- makes the new note a diatonic 4th higher with the same accidentals
            newnote:SetString(updiatonicfourth(pitchstring), keysig, false)
        
            -- fixes any errors from the diatonic transposition
            if(newnote:CalcMIDIKey() - note:CalcMIDIKey() ~= 5) then
                local error = newnote:CalcMIDIKey() - note:CalcMIDIKey() - 5
                newnote.RaiseLower = newnote.RaiseLower - error
            end
        
            -- create a diamond character that is 110% of the default size
            local notehead = finale.FCNoteheadMod()
            notehead:EraseAt(newnote)
            notehead.CustomChar = 79
            notehead.Resize = 110
            if(entry:GetDuration() == 4096) then
                if(note:CalcStaffPosition() >= -5) then
                    notehead.HorizontalPos = 5
                else
                    notehead.HorizontalPos = -5
                end
            end
            notehead:SaveAt(newnote)
        end
    end
end

main()

Comment actions Permalink
Avatar
0
Comment actions Permalink
Avatar
0

Well, sure. I reached out to him yesterday so hoping to hear something soon. Will update the group when I do. Not mission-critical but definitely can be a time saver if you’re writing a lot of string harmonics (as I am currently). 

Comment actions Permalink
Avatar
0

Just heard from him. He's tied up for the next few weeks but should have a fix out at some point.

Comment actions Permalink

Please sign in to leave a comment.