[JW Lua] flip accidentals in selected regions

Joseph Weidinger jsphweid at gmail.com
Wed May 6 16:46:27 CEST 2015


I threw that in there and it still doesn't work though. (below)
Besides not working, it seems to have odd behaviors when run on transposing
instrument lines (change enharmonics that obviously aren't in the line and
meanwhile missing ones that definitely are) although my forth parameter is
"true" in all instances.

tblOne = {'A#', 'B#', 'C#', 'D#', 'E#', 'F#', 'G#', 'Cb', 'Fb', 'Bb', 'Db',
'Eb', 'Gb', 'Ab'}
tblTwo = {'Bb', 'C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'B', 'E', 'A#', 'C#',
'D#', 'F#', 'G#'}

local pitchString = finale.FCString()
local originalPitchString = finale.FCString()

for entry in eachentrysaved(finenv.Region()) do
    if entry:IsNote() then
        i = 0 --to get the correct item of a chord, if there is one
        for note in each(entry) do
            note:GetString(pitchString, nil, false, true)
            note:GetString(originalPitchString, nil, false, true)
            for k, v in ipairs(tblOne) do
                if pitchString:ContainsLuaString(v, nil) then
                    pitchString:Replace(tblOne[k], tblTwo[k])
                    entry:GetItemAt(i):SetString(pitchstring, nil, false,
true)
                    entry.CheckAccidentals = true
                    print('old was', originalPitchString.LuaString, 'and
new is', pitchString.LuaString)
                    break
                end
            end
            i = i + 1
        end
    end
end




On Wed, May 6, 2015 at 8:42 AM, Jan Angermüller <jan at angermueller.com>
wrote:

>  You might need note:SetString ?
>
>
> Am 06.05.2015 um 15:34 schrieb Joseph Weidinger:
>
>  This almost works... It seems to correctly change the note but it
> doesn't stick or save. I'm not sure why it doesn't stick as I do iterate
> over it with "eachentrysaved" and even have an entry.CheckAccidentals =
> true, if that does anything in this case...  What am I missing?
>
>  Thanks!
>
>  tblOne = {'A#', 'B#', 'C#', 'D#', 'E#', 'F#', 'G#', 'Cb', 'Fb', 'Bb',
> 'Db', 'Eb', 'Gb', 'Ab'}
> tblTwo = {'Bb', 'C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'B', 'E', 'A#', 'C#',
> 'D#', 'F#', 'G#'}
>
>  local pitchString = finale.FCString()
> local originalPitchString = finale.FCString()
>
>  for entry in eachentrysaved(finenv.Region()) do
>     if entry:IsNote() then
>         for note in each(entry) do
>             note:GetString(pitchString, nil, false, true)
>             note:GetString(originalPitchString, nil, false, true)
>             for k, v in ipairs(tblOne) do
>                 if pitchString:ContainsLuaString(v, nil) then
>                     pitchString:Replace(tblOne[k], tblTwo[k])
>                     print("The pitch", originalPitchString.LuaString, "was
> changed to", pitchString.LuaString)
>                     break
>                 end
>             end
>         end
>     end
>     entry.CheckAccidentals = true
> end
>
>
>
> _______________________________________________
> JWLua mailing listJWLua at jwmusic.nuhttp://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>
>
> --
> Jan Angermüller
> Jevenstedter Str. 80
> 22547 Hamburg
> Tel. 040 - 28 94 84 82www.angermueller.com
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20150506/5e292775/attachment-0002.html>


More information about the JWLua mailing list