[JW Lua] Rhythm above a staff

Chris marcel.denio at gmail.com
Mon Dec 9 15:49:41 CET 2013


Hello all

I made this script for writing a rhythm above a staff and maybe it could 
be used for some.
Must only enter notes and rests of this rhythm on the layer 4 to the 
correct height.


-----------------------------------------
function plugindef()
    -- This function and the 'finaleplugin' namespace
    -- are both reserved for the plug-in definition.
    finaleplugin.RequireSelection = true
    finaleplugin.Author = "Chris"
    finaleplugin.Date = "28/11/2013"
    finaleplugin.CategoryTags = "Note, Playback, Region, Rest"
    return "Rythme au-dessus d'une portee", "", "Cree un rythme a partir 
du calque 4"
end

local restDisplacement=6
local globalResize = 75

  -- memoriser la position verticale de la 1ere note (si elle existe)
for e in eachentry(finenv.Region()) do
     if (e.LayerNumber == 4 and e:IsNote()) then
         restDisplacement = e:CalcHighestDisplacement()
         break
     end
end

-- modifier les notes et les silences
for e in eachentrysaved(finenv.Region()) do
     if (e.LayerNumber ~= 4) then goto continue end

     if e:IsNote() then
         local resize = globalResize
         local  customChar= 243

         -- blanches ou rondes
         if e.Duration >= finale.HALF_NOTE  then
             customChar= 225
             resize = globalResize * 1.8
         end

         -- cacher les lignes supplementaires
         e.LedgerLines = false

         -- hampe en haut
         e.StemUp=true
         e.FreezeStem=true

         -- interdire le playback
         e.Playback=false

         -- Creer un objet de modification de tete de note
         local notehead = finale.FCNoteheadMod()
         -- Supprimer les eventuelles tetes de note
         local highestnote = e:CalcHighestNote(nil)
         notehead:EraseAt(highestnote)
         -- Creer une nouvelle tete de note
         notehead.CustomChar = customChar
         notehead.Resize = resize

         notehead:SaveAt(highestnote)

     elseif e:IsRest() then
         -- deplacer le silence
         e:MakeMovableRest()
         e:SetRestDisplacement(restDisplacement)
     end

     -- changer la taille de la note ou du silence
     local eam = finale.FCEntryAlterMod()
     eam:SetNoteEntry(e)
     eam:DeleteData()
     eam.Resize=globalResize
     eam:SaveNew()

     ::continue::
end
  ----------------------------------------------

That's what this script does:
- Change of noteheads in rhythmic notation(I used the character 225 for 
half and whole notes instead of 124 with which there are vertical 
alignment problems)
- Freeze Stems up
- Vertical alignment of silences
- Hide ledgerlines
- Disable playback
- Change the size of notes and silences (I set to 75% and it can be 
changed in line 12)


Of course it will adjust the stem connections andpossibly change some 
layer settings.

Any suggestions would be welcome

Chris






More information about the JWLua mailing list