Section Staves

Staves utility function

See
Staff
StavesGroup

Summary

Return typeFunction and summary
tableGetChordsFromStaff(Score score, Staff staff, bool held)
Get the chords of a staff from the chord line and return detailed informations.
CollectionGetDynamicsThatApplyToStaff(Score score, Staff staff)
Get all Dynamic that apply to the specified staff.
StavesGroupGetStavesGroup(Score score, Staff staff)
Get the StavesGroup of a Staff, or nil if staff is not grouped.

Functions

GetStavesGroup(Score score, Staff staff)

Get the StavesGroup of a Staff, or nil if staff is not grouped.

ParameterTypeDefaultDescription
scoreScore  
staffStaff  
Return
StavesGroup: nil if staff is not grouped
Error
if score is nil or staff is nil

GetDynamicsThatApplyToStaff(Score score, Staff staff)

Get all Dynamic that apply to the specified staff.

Dynamics are:

  • velocity changes (crescendo, descrendo, pppp to fff)
  • Tempo change
  • Pedal on/off
  • Ottava

ParameterTypeDefaultDescription
scoreScore  
staffStaff  
Return
Collection: of Dynamics that apply to staff are on attached to it, or one of merged staves with it, or one of the staves of the contain group, or to the whole score.
Error
if score or staff are nil
See
DYNAMIC_* constants in MSDefine
Dynamic.Type

GetChordsFromStaff(Score score, Staff staff, bool held)

Get the chords of a staff from the chord line and return detailed informations.

This is useful to build bass and chords accompaniments, perform analysis, or whatever you want. The returned structure is a table, indexed from 1 to number of chords. Each element is a

table
which contains properties:
  • Chord: a Chord object, able to understand more complex notations than HA. From this object, you can obtain the list of notes, chord octave, bass octave (2 octaves lower), inversion...
  • BarNumber: the bar number where the chord is writed
  • TimeBegin: time (in tick, from the beginning of the score), where the chord starts to play
  • TimeEnd: time (in ticks, from the beginning of the score), where the chord ends, juste before next chord or an empty cell/bar.
  • ArppegioDelay: by default, staff.ChordArpeggioDelay. May change if [Annn] command has been encountered in chord line.

ParameterTypeDefaultDescription
scoreScore  
staffStaff  
heldboolnilHold chord until next is encountered? If nil, use the chord line setup of the staff. HA needs underscore (_) to hold a chord, but this is unsightly for printing, and works randomly.
Return
table:
See
Chord for more details about Chord object.
Example
local chords = GetChordsFromStaff(FrontScore(), FrontScore().FirstStaff)
for i=1,getn(chords) do
print("Chord #" .. i .. ": "..chords[i].Chord:toASCIIName())
print("Bar #" .. chords[i].BarNumber)
print(tdebug(chords[i].Chord:notes()))
end