NamedPitch

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.NamedPitch.NamedPitch" [URL="../api/abjad/pitch/NamedPitch.html#abjad.pitch.NamedPitch.NamedPitch", color=black, fontcolor=white, label="Named\nPitch", target=_top]; "abjad.pitch.Pitch.Pitch" [URL="../api/abjad/pitch/Pitch.html#abjad.pitch.Pitch.Pitch", label=Pitch, shape=oval, style=bold, target=_top]; "abjad.pitch.Pitch.Pitch" -> "abjad.pitch.NamedPitch.NamedPitch"; } 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.Pitch.Pitch"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.pitch.NamedPitch.NamedPitch(name="c'", *, accidental=None, arrow=None, octave=None)

Named pitch.

Initializes from pitch name:

>>> pitch = abjad.NamedPitch("cs''")
>>> abjad.show(pitch) 

Initializes quartertone from pitch name:

>>> pitch = abjad.NamedPitch("aqs")
>>> abjad.show(pitch) 

Initializes from pitch-class / octave string:

>>> pitch = abjad.NamedPitch('C#5')
>>> abjad.show(pitch) 

Initializes quartertone from pitch-class / octave string:

>>> pitch = abjad.NamedPitch('A+3')
>>> abjad.show(pitch) 
>>> pitch = abjad.NamedPitch('Aqs3')
>>> abjad.show(pitch) 

Initializes arrowed pitch:

>>> pitch = abjad.NamedPitch('C#5', arrow=abjad.Up)
>>> abjad.show(pitch) 

REGRESSION. Small floats just less than a C initialize in the correct octave.

Initializes c / C3:

>>> pitch = abjad.NamedPitch(-12.1)
>>> abjad.show(pitch) 

Initializes c’ / C4:

>>> pitch = abjad.NamedPitch(-0.1)
>>> abjad.show(pitch) 

Initializes c’’ / C5:

>>> pitch = abjad.NamedPitch(11.9)
>>> abjad.show(pitch) 

Attributes Summary

__add__ Adds named pitch to interval.
__copy__ Copies named pitch.
__eq__ Is true when argument is a named pitch equal to this named pitch.
__hash__ Hashes named pitch.
__lt__ Is true when named pitch is less than argument.
__radd__ Right-addition not defined on named pitches.
__str__ Gets string representation of named pitch.
__sub__ Subtracts argument from named pitch.
accidental Gets accidental of named pitch.
arrow Gets arrow of named pitch.
from_hertz Makes named pitch from hertz.
get_name Gets name of named pitch according to locale.
hertz Gets frequency of named pitch in Hertz.
invert Inverts named pitch around axis.
multiply Multiplies named pitch.
name Gets name of named pitch.
number Gets number of named pitch.
octave Gets octave of named pitch.
pitch_class Gets pitch-class of named pitch.
simplify Reduce alteration to between -2 and 2 while maintaining identical pitch number.
to_staff_position Changes named pitch to staff position.
transpose Transposes named pitch by index n.

Special methods

__add__(interval)

Adds named pitch to interval.

>>> abjad.NamedPitch("cs''") + abjad.NamedInterval('-M2')
NamedPitch("b'")
>>> abjad.NamedPitch("cs''") + abjad.NamedInterval('P1')
NamedPitch("cs''")
>>> abjad.NamedPitch("cs''") + abjad.NamedInterval('+M2')
NamedPitch("ds''")

Returns new named pitch.

__copy__(*arguments)

Copies named pitch.

>>> import copy
>>> copy.copy(abjad.NamedPitch("c''"))
NamedPitch("c''")
>>> copy.copy(abjad.NamedPitch("cs''"))
NamedPitch("cs''")
>>> copy.copy(abjad.NamedPitch("df''"))
NamedPitch("df''")

Copies arrowed pitch:

>>> pitch = abjad.NamedPitch("cs''", arrow=abjad.Up)
>>> copy.copy(pitch)
NamedPitch("cs''", arrow=Up)

Returns new named pitch.

__eq__(argument)

Is true when argument is a named pitch equal to this named pitch.

>>> pitch_1 = abjad.NamedPitch('fs')
>>> pitch_2 = abjad.NamedPitch('fs')
>>> pitch_3 = abjad.NamedPitch('gf')
>>> pitch_1 == pitch_1
True
>>> pitch_1 == pitch_2
True
>>> pitch_1 == pitch_3
False
>>> pitch_2 == pitch_1
True
>>> pitch_2 == pitch_2
True
>>> pitch_2 == pitch_3
False
>>> pitch_3 == pitch_1
False
>>> pitch_3 == pitch_2
False
>>> pitch_3 == pitch_3
True

Returns true or false.

(Pitch).__float__()

Coerce to float.

Returns float.

(Pitch).__format__(format_specification='')

Formats pitch.

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

Returns string.

(Pitch).__ge__(other, NotImplemented=NotImplemented)

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

(Pitch).__gt__(other, NotImplemented=NotImplemented)

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

__hash__()

Hashes named pitch.

Returns integer.

(Pitch).__illustrate__()

Illustrates pitch.

Returns LilyPond file.

(Pitch).__le__(other, NotImplemented=NotImplemented)

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

__lt__(argument)

Is true when named pitch is less than argument.

>>> pitch_1 = abjad.NamedPitch('fs')
>>> pitch_2 = abjad.NamedPitch('fs')
>>> pitch_3 = abjad.NamedPitch('gf')
>>> pitch_1 < pitch_1
False
>>> pitch_1 < pitch_2
False
>>> pitch_1 < pitch_3
True
>>> pitch_2 < pitch_1
False
>>> pitch_2 < pitch_2
False
>>> pitch_2 < pitch_3
True
>>> pitch_3 < pitch_1
False
>>> pitch_3 < pitch_2
False
>>> pitch_3 < pitch_3
False

Returns true or false.

__radd__(interval)

Right-addition not defined on named pitches.

>>> abjad.NamedPitch("cs'").__radd__(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/Abjad/abjad/abjad/pitch/NamedPitch.py", line 369, in __radd__
    raise NotImplementedError(message)
NotImplementedError: right-addition not defined on NamedPitch.
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Gets string representation of named pitch.

>>> str(abjad.NamedPitch("c''"))
"c''"
>>> str(abjad.NamedPitch("cs''"))
"cs''"
>>> str(abjad.NamedPitch("df''"))
"df''"

Returns string.

__sub__(argument)

Subtracts argument from named pitch.

>>> abjad.NamedPitch("cs''") - abjad.NamedPitch("b'")
NamedInterval('-M2')
>>> abjad.NamedPitch("cs''") - abjad.NamedPitch("fs''")
NamedInterval('+P4')

Returns named interval.


Methods

get_name(locale=None)

Gets name of named pitch according to locale.

>>> abjad.NamedPitch("cs''").get_name()
"cs''"
>>> abjad.NamedPitch("cs''").get_name(locale='us')
'C#5'

Set locale to ‘us’ or none.

Returns string.

invert(axis=None)

Inverts named pitch around axis.

Inverts pitch around middle C explicitly:

>>> abjad.NamedPitch("d'").invert("c'")
NamedPitch('bf')
>>> abjad.NamedPitch('bf').invert("c'")
NamedPitch("d'")

Inverts pitch around middle C implicitly:

>>> abjad.NamedPitch("d'").invert()
NamedPitch('bf')
>>> abjad.NamedPitch('bf').invert()
NamedPitch("d'")

Inverts pitch around A3:

>>> abjad.NamedPitch("d'").invert('a')
NamedPitch('e')

Interprets none-valued axis equal to middle C.

Returns new named pitch.

multiply(n=1)

Multiplies named pitch.

>>> abjad.NamedPitch("d'").multiply(1)
NamedPitch("d'")
>>> abjad.NamedPitch("d'").multiply(3)
NamedPitch("fs'")
>>> abjad.NamedPitch("d'").multiply(6)
NamedPitch("c''")
>>> abjad.NamedPitch("d'").multiply(6.5)
NamedPitch("cs''")

Returns new named pitch.

simplify()

Reduce alteration to between -2 and 2 while maintaining identical pitch number.

>>> abjad.NamedPitch("cssqs'").simplify()
NamedPitch("dqs'")
>>> abjad.NamedPitch("cfffqf'").simplify()
NamedPitch('aqf')
>>> float(abjad.NamedPitch("cfffqf'").simplify()) == float(NamedPitch('aqf'))
True

Note

LilyPond by default only supports accidentals from double-flat to double-sharp.

Returns named pitch.

to_staff_position(clef=None)

Changes named pitch to staff position.

Changes C#5 to absolute staff position:

>>> abjad.NamedPitch('C#5').to_staff_position()
StaffPosition(7)
>>> abjad.NamedPitch('C#5').to_staff_position(clef='treble')
StaffPosition(1)
>>> abjad.NamedPitch('C#5').to_staff_position(clef='bass')
StaffPosition(13)

Marks up absolute staff position of many pitches:

>>> staff = abjad.Staff("g16 a b c' d' e' f' g' a' b' c'' d'' e'' f'' g'' a''")
>>> for note in staff:
...     staff_position = note.written_pitch.to_staff_position()
...     markup = abjad.Markup(staff_position.number)
...     abjad.attach(markup, note)
... 
>>> abjad.override(staff).text_script.staff_padding = 5
>>> abjad.show(staff) 

Marks up treble staff position of many pitches:

>>> staff = abjad.Staff("g16 a b c' d' e' f' g' a' b' c'' d'' e'' f'' g'' a''")
>>> clef = abjad.Clef('treble')
>>> for note in staff:
...     staff_position = note.written_pitch.to_staff_position(
...         clef=clef
...         )
...     markup = abjad.Markup(staff_position.number)
...     abjad.attach(markup, note)
... 
>>> abjad.override(staff).text_script.staff_padding = 5
>>> abjad.show(staff) 

Marks up bass staff position of many pitches:

>>> staff = abjad.Staff("g,16 a, b, c d e f g a b c' d' e' f' g' a'")
>>> clef = abjad.Clef('bass')
>>> abjad.attach(clef, staff[0])
>>> for note in staff:
...     staff_position = note.written_pitch.to_staff_position(
...         clef=clef
...         )
...     markup = abjad.Markup(staff_position.number)
...     abjad.attach(markup, note)
... 
>>> abjad.override(staff).text_script.staff_padding = 5
>>> abjad.show(staff) 

Returns staff position.

transpose(n=0)

Transposes named pitch by index n.

Transposes C4 up a minor second:

>>> abjad.NamedPitch("c'").transpose(n='m2')
NamedPitch("df'")

Transposes C4 down a major second:

>>> abjad.NamedPitch("c'").transpose(n='-M2')
NamedPitch('bf')

Returns new named pitch.


Class & static methods

classmethod from_hertz(hertz)

Makes named pitch from hertz.

>>> abjad.NamedPitch.from_hertz(440)
NamedPitch("a'")

REGRESSION. Returns c’’ (C5) and not c’ (C4):

>>> abjad.NamedPitch.from_hertz(519)
NamedPitch("c''")

Returns newly constructed named pitch.


Read-only properties

accidental

Gets accidental of named pitch.

>>> abjad.NamedPitch("c''").accidental
Accidental('natural')
>>> abjad.NamedPitch("cs''").accidental
Accidental('sharp')
>>> abjad.NamedPitch("df''").accidental
Accidental('flat')

Returns accidental.

arrow

Gets arrow of named pitch.

>>> abjad.NamedPitch("cs''").arrow is None
True
>>> abjad.NamedPitch("cs''", arrow=abjad.Up).arrow
Up
>>> abjad.NamedPitch("cs''", arrow=abjad.Down).arrow
Down

Displays arrow in interpreter representation:

>>> abjad.NamedPitch("cs''", arrow=abjad.Down)
NamedPitch("cs''", arrow=Down)

Returns up, down or none.

hertz

Gets frequency of named pitch in Hertz.

>>> abjad.NamedPitch("c''").hertz
523.2511306011972
>>> abjad.NamedPitch("cs''").hertz
554.3652619537442
>>> abjad.NamedPitch("df''").hertz
554.3652619537442

Returns float.

name

Gets name of named pitch.

>>> abjad.NamedPitch("c''").name
"c''"
>>> abjad.NamedPitch("cs''").name
"cs''"
>>> abjad.NamedPitch("df''").name
"df''"

Returns string.

number

Gets number of named pitch.

>>> abjad.NamedPitch("c''").number
12
>>> abjad.NamedPitch("cs''").number
13
>>> abjad.NamedPitch("df''").number
13
>>> abjad.NamedPitch("cf'").number
-1

Returns number.

octave

Gets octave of named pitch.

>>> abjad.NamedPitch("c''").octave
Octave(5)
>>> abjad.NamedPitch("cs''").octave
Octave(5)
>>> abjad.NamedPitch("df''").octave
Octave(5)

Returns octave.

pitch_class

Gets pitch-class of named pitch.

>>> abjad.NamedPitch("c''").pitch_class
NamedPitchClass('c')
>>> abjad.NamedPitch("cs''").pitch_class
NamedPitchClass('cs')
>>> abjad.NamedPitch("df''").pitch_class
NamedPitchClass('df')

Returns named pitch-class.