Clef

class indicatortools.Clef(name='treble')

Clef.

Example 1. At the beginning of a staff:

>>> clef = Clef('treble')
>>> clef
Clef(name='treble')
>>> staff = Staff("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8")
>>> show(staff) 

Example 2. Some available clefs:

>>> clef = Clef('treble')
>>> attach(clef, staff)
>>> clef = Clef('alto')
>>> attach(clef, staff[1])
>>> clef = Clef('bass')
>>> attach(clef, staff[2])
>>> clef = Clef('treble^8')
>>> attach(clef, staff[3])
>>> clef = Clef('bass_8')
>>> attach(clef, staff[4])
>>> clef = Clef('tenor')
>>> attach(clef, staff[5])
>>> clef = Clef('bass^15')
>>> attach(clef, staff[6])
>>> clef = Clef('percussion')
>>> attach(clef, staff[7])
>>> show(staff) 

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_indicatortools { graph [label=indicatortools]; "abjad.tools.indicatortools.Clef.Clef" [color=black, fontcolor=white, group=2, label=<<B>Clef</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.indicatortools.Clef.Clef"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

default_scope Gets default scope of clef.
from_selection(selection) Makes clef from selection.
middle_c_position Gets middle C position of clef.
name Gets name of clef.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when all initialization values of Abjad value object equal the initialization values of argument.
__format__([format_specification]) Formats clef.
__hash__() Hashes Abjad value object.
__ne__(argument) Is true when clef of argument does not equal clef name of clef.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

Clef.default_scope

Gets default scope of clef.

>>> clef = Clef('treble')
>>> clef.default_scope
<class 'abjad.tools.scoretools.Staff.Staff'>

Clefs are staff-scoped by default.

Returns staff.

Clef.middle_c_position

Gets middle C position of clef.

Example 1. Gets staff position of middle C in treble clef:

>>> Clef('treble').middle_c_position
StaffPosition(number=-6)

Example 2. Gets staff position of middle C in alto clef:

>>> Clef('alto').middle_c_position
StaffPosition(number=0)

Returns nonnegative integer staff position.

Clef.name

Gets name of clef.

Example 1. Gets name treble clef:

>>> Clef('treble').name
'treble'

Example 2. Gets name of alto clef:

>>> Clef('alto').name
'alto'

Returns string.

Class & static methods

static Clef.from_selection(selection)

Makes clef from selection.

>>> numbers = list(range(-12, -6))
>>> notes = scoretools.make_notes(numbers, [Duration(1, 4)])
>>> staff = Staff(notes)
>>> Clef.from_selection(staff)
Clef(name='bass')

Choses between treble and bass based on minimal number of ledger lines.

Returns new 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.

Clef.__format__(format_specification='')

Formats clef.

Set format_specification to ‘’, ‘lilypond’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

>>> clef = Clef('treble')
>>> print(format(clef))
indicatortools.Clef(
    name='treble',
    )
>>> clef = Clef('treble')
>>> print(format(clef, 'lilypond'))
\clef "treble"

Returns string.

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

Clef.__ne__(argument)

Is true when clef of argument does not equal clef name of clef. Otherwise false.

>>> clef_1 = Clef('treble')
>>> clef_2 = Clef('alto')
>>> clef_1 != clef_1
False
>>> clef_1 != clef_2
True
>>> clef_2 != clef_1
True
>>> clef_2 != clef_2
False

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.