neoscore.western.staff
- class neoscore.western.staff.Staff[source]
Bases:
AbstractStaff
A staff with some high-level knowledge of its contents.
- __init__(pos: PointDef, parent: Optional[PositionedObject], length: Unit, group: Optional[StaffGroup] = None, line_spacing: Unit = Mm(1.75), line_count: int = 5, music_font_family: str = 'Bravura', pen: Optional[PenDef] = None)[source]
- Parameters
pos – The position of the top-left corner of the staff
parent – The parent for the staff. Make this a
Flowable
to allow the staff to run across line and page breaks.length – The horizontal width of the staff
group – The staff group this belongs to. Set this if being used in a system of multiple staves.
line_spacing – The distance between two lines in the staff.
line_count – The number of lines in the staff.
music_font_family – The name of the font to use for MusicText objects in the staff. This defaults to the system-wide default music font family.
pen – The pen used to draw the staff lines. Defaults to a line with thickness from the music font’s engraving default.
- distance_to_next_of_type(staff_object: PositionedObject) Unit [source]
Find the x distance until the next occurrence of an object’s type.
If the object is the last of its type, this gives the remaining length of the staff after the object.
This is useful for determining rendering behavior of staff objects which are active until another of their type occurs, such as
KeySignature
andClef
.
- clefs
All the clefs in this staff, ordered by their relative x pos.
- active_clef_at(pos_x: Unit) Optional[Clef] [source]
Return the active clef at a given x position, if any.
- key_signatures
All the key signatures in this staff, ordered by their relative x pos.
- time_signatures
All the time signatures in this staff, ordered by their relative x pos.
- active_key_signature_at(pos_x: Unit) Optional[KeySignature] [source]
Return the active key signature at a given x position, if any.
- middle_c_at(pos_x: Unit) Unit [source]
Find the y-axis staff position of middle-c at a given point.
Looks for clefs and other transposing modifiers to determine the position of middle-c.
- Raises
NoClefError – If no clef is active at the given position.
- y_on_ledger(pos_y: Unit) bool [source]
Determine if a y-axis position is approximately at a ledger line position
This is true for any whole-number staff position outside the staff
- ledgers_needed_for_y(position: Unit) List[Unit] [source]
Find the y positions of all ledgers needed for a given y position
- register_layout_controllers()[source]
Register any flowable margin controllers needed by the staff.
Staff subclasses must implement this.
- fringe_layout_for_isolated_staff(location: Optional[NewLine]) StaffFringeLayout [source]
Determine the staff fringe layout of this staff in isolation.
This is the layout needed if this staff was alone in a staff system.
StaffGroup
uses this as a starting point in its fringe layout logic.Staff subclasses must implement this.