StaffPosition

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.pitch" { graph [label="abjad.pitch"]; node [color=1]; "abjad.pitch.StaffPosition.StaffPosition" [URL="../api/abjad/pitch/StaffPosition.html#abjad.pitch.StaffPosition.StaffPosition", color=black, fontcolor=white, label="Staff\nPosition", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/pitch/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/pitch/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.pitch.StaffPosition.StaffPosition"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.pitch.StaffPosition.StaffPosition(number=0)

Staff position.

Initializes staff position at middle line of staff:

>>> abjad.StaffPosition(0)
StaffPosition(0)

Initializes staff position one space below middle line of staff:

>>> abjad.StaffPosition(-1)
StaffPosition(-1)

Initializes staff position one line below middle line of staff:

>>> abjad.StaffPosition(-2)
StaffPosition(-2)

Initializes from other staff position:

>>> staff_position = abjad.StaffPosition(-2)
>>> abjad.StaffPosition(staff_position)
StaffPosition(-2)

Attributes Summary

__eq__ Is true when argument is a staff position with the same number as this staff position.
__ge__ Return a >= b.
__gt__ Return a > b.
__hash__ Hashes staff position.
__le__ Return a <= b.
__lt__ Is true when staff position is less than argument.
__str__ Gets string representation of staff position.
number Gets staff position number.
to_pitch Makes named pitch from staff position and clef.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument is a staff position with the same number as this staff position.

>>> staff_position_1 = abjad.StaffPosition(-2)
>>> staff_position_2 = abjad.StaffPosition(-2)
>>> staff_position_3 = abjad.StaffPosition(0)
>>> staff_position_1 == staff_position_1
True
>>> staff_position_1 == staff_position_2
True
>>> staff_position_1 == staff_position_3
False
>>> staff_position_2 == staff_position_1
True
>>> staff_position_2 == staff_position_2
True
>>> staff_position_2 == staff_position_3
False
>>> staff_position_3 == staff_position_1
False
>>> staff_position_3 == staff_position_2
False
>>> staff_position_3 == staff_position_3
True

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

__ge__(other, NotImplemented=NotImplemented)

Return a >= b. Computed by @total_ordering from (not a < b).

__gt__(other, NotImplemented=NotImplemented)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

__hash__()

Hashes staff position.

Returns integer.

__le__(other, NotImplemented=NotImplemented)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

__lt__(argument)

Is true when staff position is less than argument.

>>> staff_position_1 = abjad.StaffPosition(-2)
>>> staff_position_2 = abjad.StaffPosition(-2)
>>> staff_position_3 = abjad.StaffPosition(0)
>>> staff_position_1 < staff_position_1
False
>>> staff_position_1 < staff_position_2
False
>>> staff_position_1 < staff_position_3
True
>>> staff_position_2 < staff_position_1
False
>>> staff_position_2 < staff_position_2
False
>>> staff_position_2 < staff_position_3
True
>>> staff_position_3 < staff_position_1
False
>>> staff_position_3 < staff_position_2
False
>>> staff_position_3 < staff_position_3
False

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Gets string representation of staff position.

>>> str(abjad.StaffPosition(-2))
'StaffPosition(-2)'

Returns string.


Methods

to_pitch(clef='treble')

Makes named pitch from staff position and clef.

Treble clef:

>>> clef = abjad.Clef('treble')
>>> for n in range(-6, 6):
...     staff_position = abjad.StaffPosition(n)
...     pitch = staff_position.to_pitch(clef=clef)
...     message = '{!s}     {}'.format(staff_position, pitch)
...     print(message)
...
StaffPosition(-6)   c'
StaffPosition(-5)   d'
StaffPosition(-4)   e'
StaffPosition(-3)   f'
StaffPosition(-2)   g'
StaffPosition(-1)   a'
StaffPosition(0)    b'
StaffPosition(1)    c''
StaffPosition(2)    d''
StaffPosition(3)    e''
StaffPosition(4)    f''
StaffPosition(5)    g''

Bass clef:

>>> clef = abjad.Clef('bass')
>>> for n in range(-6, 6):
...     staff_position = abjad.StaffPosition(n)
...     pitch = staff_position.to_pitch(clef=clef)
...     message = '{!s}     {}'.format(staff_position, pitch)
...     print(message)
...
StaffPosition(-6)   e,
StaffPosition(-5)   f,
StaffPosition(-4)   g,
StaffPosition(-3)   a,
StaffPosition(-2)   b,
StaffPosition(-1)   c
StaffPosition(0)    d
StaffPosition(1)    e
StaffPosition(2)    f
StaffPosition(3)    g
StaffPosition(4)    a
StaffPosition(5)    b

Alto clef:

>>> clef = abjad.Clef('alto')
>>> for n in range(-6, 6):
...     staff_position = abjad.StaffPosition(n)
...     pitch = staff_position.to_pitch(clef=clef)
...     message = '{!s}     {}'.format(staff_position, pitch)
...     print(message)
...
StaffPosition(-6)   d
StaffPosition(-5)   e
StaffPosition(-4)   f
StaffPosition(-3)   g
StaffPosition(-2)   a
StaffPosition(-1)   b
StaffPosition(0)    c'
StaffPosition(1)    d'
StaffPosition(2)    e'
StaffPosition(3)    f'
StaffPosition(4)    g'
StaffPosition(5)    a'

Percussion clef:

>>> clef = abjad.Clef('percussion')
>>> for n in range(-6, 6):
...     staff_position = abjad.StaffPosition(n)
...     pitch = staff_position.to_pitch(clef=clef)
...     message = '{!s}     {}'.format(staff_position, pitch)
...     print(message)
...
StaffPosition(-6)   d
StaffPosition(-5)   e
StaffPosition(-4)   f
StaffPosition(-3)   g
StaffPosition(-2)   a
StaffPosition(-1)   b
StaffPosition(0)    c'
StaffPosition(1)    d'
StaffPosition(2)    e'
StaffPosition(3)    f'
StaffPosition(4)    g'
StaffPosition(5)    a'

Returns new named pitch.


Read-only properties

number

Gets staff position number.

>>> abjad.StaffPosition(-2).number
-2

Returns number.