neoscore.western.chordrest
- class neoscore.western.chordrest.PitchAndGlyph[source]
Bases:
tuple
Used to define individual notes with one-off SMuFL glyphs.
- property pitch
The pitch for the notehead
- property notehead_glyph
The SMuFL glyph name for the notehead
- class neoscore.western.chordrest.Chordrest[source]
Bases:
PositionedObject
,StaffObject
A chord or a rest.
This is a unified interface for conventionally notated musical notes/chords/rests. It can be given any number of pitches to be used as notes in the chord, or
None
for a rest.It will automatically generate and lay out:
Notehead
s if pitches are givena
Stem
if pitches are given and required by the givenDuration
a
Flag
if pitches are given and required by the givenDuration
LedgerLine
s as needed (taking into consideration the given pitches and their location on theStaff
)Accidental
s as needed by any given pitchesa
Rest
if no pitches are givenRhythmDot
s if needed by the givenDuration
Any accidentals given in pitches will be unconditionally drawn regardless of context and key signature.
- __init__(pos_x: Unit, staff: Staff, notes: Optional[List[Union[Pitch, str, tuple, PitchAndGlyph]]], duration: Union[Duration, Tuple[int, int]], rest_y: Optional[Unit] = None, stem_direction: Optional[DirectionY] = None, beam_break_depth: Optional[int] = None, beam_hook_dir: Optional[DirectionX] = None, table: NoteheadTable = notehead_tables.STANDARD)[source]
- Parameters
pos_x – The horizontal position in the staff
staff – The staff the object is attached to
notes – A list of pitches and optional notehead-specific data. If
None
this indicates a rest. For simple notes and chords, this can typically be a list of pitch string shorthands (seePitch.from_str
). Pitches with extended accidentals can be given by passing fully constructedPitch
objects. Individual notehead glyphs (by default taken from the giventable
) can be overridden by passing a tuple of a pitch and a SMuFL glyph name string.duration – The written duration for the object.
rest_y – The vertical position used by rests. This defaults to the center of the staff.
stem_direction – An optional stem direction override. If omitted, the direction is automatically calculated to point away from the furthest-out notehead.
beam_break_depth – Break depth used if in a
BeamGroup
.beam_hook_dir – Beamlet hook direction used in a
BeamGroup
.table – The set of noteheads to use according to
duration
.
- property notes: List[Union[Pitch, str, tuple, PitchAndGlyph]]
- property rest_y: Optional[Unit]
The vertical position used by generated rests.
Defaults to the staff center.
- property accidentals: List[Accidental]
The accidentals contained in this Chordrest.
- property ledgers: List[LedgerLine]
The ledger lines contained in this Chordrest.
An empty list means none are needed.
- property beam_break_depth: Optional[int]
Break depth used if in a
BeamGroup
.If this Chordrest is within a beam group, this triggers a beam subdivision break at this point. The value indicates the number of beams to which the subdivision breaks. For example, in run of 16th notes a
beam_break_depth
of1
would indicate a subdivision break to 1 beam at this point.
- property beam_hook_dir: Optional[DirectionX]
Beamlet hook direction used in a
BeamGroup
.If this Chordrest is within a beam group and this position is one requiring a beamlet hook whose direction is ambiguous, this controls that direction.
- property table: NoteheadTable
- property duration: Duration
The written length of this event.
This affects many components of the chordrest.
- ledger_line_positions
A set of staff positions of needed ledger lines.
Positions are in centered staff positions.
An empty list means no ledger lines are needed.
- rhythm_dot_positions
The positions of all rhythm dots needed.
- furthest_notehead
The notehead furthest from the staff center
- highest_notehead
The highest notehead in the chord.
- lowest_notehead
The lowest notehead in the chord.
- leftmost_notehead
The notehead furthest to the left in the chord
- rightmost_notehead
The notehead furthest to the right in the chord
- extra_attachment_point
A point where common attachments like ornaments could go.
For chords, this is a point centered above or below the outermost notehead opposite of the stem direction.
For rests, this is a point centered above the rest.
The returned point is relative to the Chordrest.
- tremolo_attachment_point
A convenient reasonable point for tremolos to be placed.
The returned point is relative to the chordrest.
The precise position returned is not currently guaranteed, as there are known shortcomings that still need to be addressed, particularly with short stems and stems with flags attached.
For rests, this simply returns
ORIGIN
.
- notehead_column_bounding_rect
The bounding rect of the notehead column after layout.
- noteheads_outside_staff
All noteheads which are above or below the staff
- leftmost_notehead_outside_staff
The notehead furthest to the left outside the staff
- rightmost_notehead_outside_staff
The notehead furthest to the right outside the staff
- notehead_column_outside_staff_width
The total width of any noteheads outside the staff
- property stem_direction: DirectionY
The direction of the stem
Takes the notehead furthest from the center of the staff, and returns the opposite direction.
If the furthest notehead is in the center of the staff, the direction defaults to
DirectionY.DOWN
, unless the staff has only one line, in which case it defaults toDirectionY.UP
as a convenience for percussion staves.This automatically calculated property may be overridden using its setter. To revert to the automatically calculated value set this property to
None
.If there are no noteheads (meaning this Chordrest is a rest), this arbitrarily returns
DirectionY.UP
.
- stem_height
The height of the stem