[JW Lua] Improved FindEntryStartPosition function
Jan Angermüller
jan at angermueller.com
Fri May 5 17:27:52 CEST 2017
Jari,
FCNoteEntryCell:FindEntryStartPosition sometimes returns unfavorable
results.
It prioritizes main notes over grace notes, but it doesn't prioritize:
1.) visible notes over invisible notes (so currently an invisible rest
on layer 1 is prefered over a visible note on layer 2)
2.) notes that are on the exact measure position over whole measure
rests that appear in the center of the measure
(so at position 0 a rest on layer 1 that appears in the center of the
measure is prioritized over a note that appears on position 0 on layer 2)
3.) visible notes over notes that are hidden through a staff style
The latter may be a bit difficult to implement, but the first two
options should be rather straight forward.
This would be a great improvement of the function.
Below is a workaround solution for 1) + 2).
Best,
Jan
https://elbsound.studio
function NewFindEntryStartPosition(entry,measurepos,notecell)
-- look for better matching entries in other layers
if (entry~=nil) then
if entry.Visible
and entry:IsRest()
and (entry.Duration==4096) then
local meas=finale.FCMeasure()
meas:Load(entry.Measure)
if meas:GetDuration()<=4096 then
for e in each(notecell) do
if (e.MeasurePos==measurepos)
and (not e:IsRest() or (e.Duration~=4096)) then
entry=e
break
end
end
end
elseif (entry.Visible==false) then
for e in each(notecell) do
if (e.MeasurePos==measurepos)
and e.Visible then
entry=e
break
end
end
end
end
return entry
end
local
noteentrycell=finale.FCNoteEntryCell(finenv.Region().EndMeasure,finenv.Region().StartStaff)
noteentrycell:Load()
local
entry=NewFindEntryStartPosition(noteentrycell:FindEntryStartPosition(0,-1),0,noteentrycell)
print(entry.LayerNumber)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20170505/328d7354/attachment.htm>
More information about the JWLua
mailing list