instrumenttools.notes_and_chords_in_expr_are_on_expected_clefs

abjad.tools.instrumenttools.notes_and_chords_in_expr_are_on_expected_clefs.notes_and_chords_in_expr_are_on_expected_clefs(expr, percussion_clef_is_allowed=True)[source]

New in version 2.0.

True when notes and chords in expr are on expected clefs:

abjad> staff = Staff("c'8 d'8 e'8 f'8")
abjad> contexttools.ClefMark('treble')(staff)
ClefMark('treble')(Staff{4})
abjad> instrumenttools.Violin()(staff)
Violin()(Staff{4})
abjad> instrumenttools.notes_and_chords_in_expr_are_on_expected_clefs(staff)
True

False otherwise:

abjad> staff = Staff("c'8 d'8 e'8 f'8")
abjad> contexttools.ClefMark('alto')(staff)
ClefMark('alto')(Staff{4})
abjad> instrumenttools.Violin()(staff)
Violin()(Staff{4})
abjad> instrumenttools.notes_and_chords_in_expr_are_on_expected_clefs(staff)
False

Allow percussion clef when percussion_clef_is_allowed is true:

abjad> staff = Staff("c'8 d'8 e'8 f'8")
abjad> contexttools.ClefMark('percussion')(staff)
ClefMark('percussion')(Staff{4})
abjad> instrumenttools.Violin()(staff)
Violin()(Staff{4})
abjad> f(staff)
\new Staff {
    \clef "percussion"
    \set Staff.instrumentName = \markup { Violin }
    \set Staff.shortInstrumentName = \markup { Vn. }
    c'8
    d'8
    e'8
    f'8
}
abjad> instrumenttools.notes_and_chords_in_expr_are_on_expected_clefs(staff, percussion_clef_is_allowed = True)
True

Disallow percussion clef when percussion_clef_is_allowed is false:

abjad> instrumenttools.notes_and_chords_in_expr_are_on_expected_clefs(staff, percussion_clef_is_allowed = False)
False

Return boolean.

This Page