Clef¶
-
class
abjad.indicators.Clef.
Clef
(name='treble', *, hide=None)¶ Clef.
Some available clefs:
>>> staff = abjad.Staff("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8") >>> clef = abjad.Clef('treble') >>> abjad.attach(clef, staff[0]) >>> clef = abjad.Clef('alto') >>> abjad.attach(clef, staff[1]) >>> clef = abjad.Clef('bass') >>> abjad.attach(clef, staff[2]) >>> clef = abjad.Clef('treble^8') >>> abjad.attach(clef, staff[3]) >>> clef = abjad.Clef('bass_8') >>> abjad.attach(clef, staff[4]) >>> clef = abjad.Clef('tenor') >>> abjad.attach(clef, staff[5]) >>> clef = abjad.Clef('bass^15') >>> abjad.attach(clef, staff[6]) >>> clef = abjad.Clef('percussion') >>> abjad.attach(clef, staff[7]) >>> abjad.show(staff)
Clefs can be tagged:
>>> staff = abjad.Staff("c'4 d' e' f'") >>> abjad.attach(abjad.Clef('treble'), staff[0], tag='RED') >>> abjad.show(staff)
>>> abjad.f(staff) \new Staff { \clef "treble" %! RED c'4 d'4 e'4 f'4 }
LilyPond can not handle simultaneous clefs:
>>> voice_1 = abjad.Voice("e'8 g' f' a' g' b'") >>> abjad.attach(abjad.Clef('treble'), voice_1[0], context='Voice') >>> abjad.attach(abjad.LilyPondLiteral(r'\voiceOne'), voice_1) >>> voice_1.consists_commands.append('Clef_engraver') >>> voice_2 = abjad.Voice("c'4. c,8 b,, a,,") >>> abjad.attach(abjad.Clef('treble'), voice_2[0], context='Voice') >>> abjad.attach(abjad.Clef('bass'), voice_2[1], context='Voice') >>> abjad.attach(abjad.LilyPondLiteral(r'\voiceTwo'), voice_2) >>> voice_2.consists_commands.append('Clef_engraver') >>> staff = abjad.Staff([voice_1, voice_2], is_simultaneous=True) >>> staff.remove_commands.append('Clef_engraver') >>> abjad.show(staff)
But Abjad components work fine:
>>> for leaf in abjad.select(voice_1).leaves(): ... leaf, abjad.inspect(leaf).effective(abjad.Clef) ... (Note("e'8"), Clef('treble')) (Note("g'8"), Clef('treble')) (Note("f'8"), Clef('treble')) (Note("a'8"), Clef('treble')) (Note("g'8"), Clef('treble')) (Note("b'8"), Clef('treble'))
>>> for leaf in abjad.select(voice_2).leaves(): ... leaf, abjad.inspect(leaf).effective(abjad.Clef) ... (Note("c'4."), Clef('treble')) (Note('c,8'), Clef('bass')) (Note('b,,8'), Clef('bass')) (Note('a,,8'), Clef('bass'))
Attributes Summary
__format__
Formats clef. context
Gets (historically conventional) context. from_selection
Makes clef from selection
.hide
Is true when clef should not appear in output (but should still determine effective clef). middle_c_position
Gets middle C position of clef. name
Gets name of clef. parameter
Is true. redraw
Is true. tweaks
Are not implemented on clef. Special methods
-
(
AbjadValueObject
).__copy__
(*arguments)¶ Copies Abjad value object.
Returns new Abjad value object.
-
(
AbjadValueObject
).__eq__
(argument)¶ Is true when all initialization values of Abjad value object equal the initialization values of
argument
.Returns true or false.
-
__format__
(format_specification='')¶ Formats clef.
>>> clef = abjad.Clef('treble') >>> print(format(clef)) abjad.Clef('treble')
>>> clef = abjad.Clef('treble') >>> print(format(clef, 'lilypond')) \clef "treble"
Returns string.
Return type: str
-
(
AbjadValueObject
).__hash__
()¶ Hashes Abjad value object.
Returns integer.
-
(
AbjadObject
).__repr__
()¶ Gets interpreter representation of Abjad object.
Returns string.
Class & static methods
-
static
from_selection
(selection)¶ Makes clef from
selection
.>>> maker = abjad.NoteMaker() >>> notes = maker(range(-12, -6), [(1, 4)]) >>> staff = abjad.Staff(notes) >>> abjad.Clef.from_selection(staff) Clef('bass')
Choses between treble and bass based on minimal number of ledger lines.
Return type: Clef
Read-only properties
-
context
¶ Gets (historically conventional) context.
>>> clef = abjad.Clef('treble') >>> clef.context 'Staff'
Override with
abjad.attach(..., context='...')
.Return type: str
-
hide
¶ Is true when clef should not appear in output (but should still determine effective clef).
>>> staff = abjad.Staff("c'4 d' e' f'") >>> abjad.attach(abjad.Clef('treble'), staff[0]) >>> abjad.attach(abjad.Clef('alto', hide=True), staff[2]) >>> abjad.show(staff)
>>> abjad.f(staff) \new Staff { \clef "treble" c'4 d'4 e'4 f'4 }
>>> for leaf in abjad.iterate(staff).leaves(): ... leaf, abjad.inspect(leaf).effective(abjad.Clef) ... (Note("c'4"), Clef('treble')) (Note("d'4"), Clef('treble')) (Note("e'4"), Clef('alto', hide=True)) (Note("f'4"), Clef('alto', hide=True))
Return type: Optional
[bool
]
-
middle_c_position
¶ Gets middle C position of clef.
Gets staff position of middle C in treble clef:
>>> abjad.Clef('treble').middle_c_position StaffPosition(-6)
Gets staff position of middle C in alto clef:
>>> abjad.Clef('alto').middle_c_position StaffPosition(0)
Return type: int
-
name
¶ Gets name of clef.
Gets name treble clef:
>>> abjad.Clef('treble').name 'treble'
Gets name of alto clef:
>>> abjad.Clef('alto').name 'alto'
Return type: str
-
tweaks
¶ Are not implemented on clef.
The LilyPond
\clef
command refuses tweaks.Override the LilyPond
Clef
grob instead.Return type: None
-