[JW Lua] GetStaffPosition for a note entry ?

Jari Williamsson jari.williamsson at mailbox.swipnet.se
Mon Jul 7 15:49:05 CEST 2014


Jan,

For now, you'd need to go through the percussion layout to get the 
position for percussion entries. I'll update CalcActualDisplacement() to 
work with percussion staves later, but it'll not be in the next update.


Best regards,

Jari Williamsson


On 2014-07-07 12:34, Jan Angermüller wrote:
> Jari,
>
> thanks for the hint !
> But: FCNote:CalcActualDisplacement() seems to return wrong results for
> percussion staves.
> When using NoteEntry:CalcHighestPercussionNote ():CalcActualDisplacement()
> it seems to ignore percussion layout. Notes on the same staff pos, but
> with different
> MIDI values return different positions.
>
> And the standard note results do not have the same range as percussion
> note results
> (which have staff position 6 on the middle line, CalcActualDisplacement
> returns -4 on middle line).
>
> Attached below are my own functions that deliver the same staff position
> for both standard and percussion staves. They seem to work fine,
> although I probably should switch to FCNote:CalcActualDisplacement()
> and add range adjust, as it probably has had more testing yet.
>
> function GetPercPitch(staff,note)
>       local layerinstrdef=staff:CreateLayerInstrumentDef(1)
>       local percmapnotes=layerinstrdef:CreatePercussionMapNotes()
>       local percID=staff:CalcPercussionLayoutID(0)
>       local perclayoutnotes=finale.FCPercussionLayoutNotes()
>       perclayoutnotes:LoadAllForItem(percID)
>       return
> perclayoutnotes:FindMidiNote(note,percmapnotes):GetStaffPosition()
> end
>
> function GetStaffPos(entry,staff)
>      --calc note position in staff, rests return 0
>      local staffpos=0
>
>      -- Get clef, key signature, major/minor and measure
>      local clef=finale.FCClefDef()
>      clef:Load(entry:GetClefIndex())
>      local measure=finale.FCMeasure()
>      measure:Load(entry.Measure)
>      local key=measure:GetKeySignature()
>      local minor=0
>      if key:IsMinor() then
>         minor=-2
>      end
>
>      local percussionhighestnote=entry:CalcHighestPercussionNote ()
>      if percussionhighestnote~= nil then
> staffpos=GetPercPitch(staff,percussionhighestnote:CalcMIDIKey())
>      elseif entry:IsRest() or (entry.Duration==0) then -- return 0 on rests
>           staffpos=0
>      else
>          staffpos=entry:CalcHighestNote(NULL):GetDisplacement() --
> replace with FCNote:CalcActualDisplacement()
>                         +clef:GetVerticalAdjust()
>                         +staff:GetTransposeInterval()
>                         +key:CalcRootRelationIndex()
>                         +minor
>                         +10           -- make range compatible with
> percussion staves
>      end
>      return staffpos
> end
>
>
> Jan
>
>> Jari Williamsson <jari.williamsson at mailbox.swipnet.se> schrieb:
>>
>>     On 2014-07-02 17:03, Jan Angermüller wrote:
>>     > Does anyone know if there is GetStaffPosition for a "normal"
>>     note entry ?
>>
>>     Sounds like FCNote:CalcActualDisplacement() is what you're looking
>>     for.
>>
>>
>>     Best regards,
>>
>>     Jari Williamsson
>>
>>
>>     _______________________________________________
>>     JWLua mailing list
>>     JWLua at jwmusic.nu
>>     http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
>
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>






More information about the JWLua mailing list