NamedPitch

class pitchtools.NamedPitch(*args)

Named pitch.

Example 1. Initializes from pitch name:

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

Example 2. Initializes from pitch-class / octave string:

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

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_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.NamedPitch.NamedPitch" [color=black, fontcolor=white, group=2, label=<<B>NamedPitch</B>>, shape=box, style="filled, rounded"]; "abjad.tools.pitchtools.Pitch.Pitch" [color=3, group=2, label=Pitch, shape=oval, style=bold]; "abjad.tools.pitchtools.Pitch.Pitch" -> "abjad.tools.pitchtools.NamedPitch.NamedPitch"; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.pitchtools.Pitch.Pitch"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

accidental Gets accidental of named pitch.
accidental_spelling Accidental spelling of Abjad session.
alteration_in_semitones Gets alteration of named pitch in semitones.
apply_accidental([accidental]) Applies accidental to named pitch.
diatonic_pitch_class_name Gets diatonic pitch-class name of named pitch.
diatonic_pitch_class_number Gets diatonic pitch-class number of named pitch.
diatonic_pitch_name Gets diatonic pitch name of named pitch.
diatonic_pitch_number Gets diatonic pitch number of named pitch.
from_hertz(class_, hertz) Creates pitch from hertz.
from_pitch_carrier(pitch_carrier) Initializes named pitch from pitch_carrier.
from_staff_position(staff_position[, clef]) Initializes named pitch from staff_position and optional clef.
hertz Gets hertz value of pitch.
invert([axis]) Inverts named pitch around axis.
is_diatonic_pitch_name(expr) Is true when expr is a diatonic pitch name.
is_diatonic_pitch_number(expr) Is true when expr is a diatonic pitch number.
is_pitch_carrier(expr) Is true when expr is an Abjad pitch, note, note-head of chord instance.
is_pitch_class_octave_number_string(expr) Is true when expr is a pitch-class / octave number string.
is_pitch_name(expr) True expr is a pitch name.
is_pitch_number(expr) Is true when expr is a pitch number.
multiply([n]) Multiplies pitch-class of named pitch by n while maintaining octave of named pitch.
named_pitch Gets new named pitch.
named_pitch_class Gets named pitch-class of named pitch.
numbered_pitch Gets numbered pitch corresponding to named pitch.
numbered_pitch_class Gets numbered pitch-class corresponding to named pitch.
octave Gets octave of named pitch.
octave_number Gets octave number of named pitch.
pitch_class_name Gets pitch-class name of named pitch.
pitch_class_number Gets pitch-class number of named pitch.
pitch_class_octave_label Gets pitch-class / octave label of named pitch.
pitch_name Gets pitch name of named pitch.
pitch_number Gets pitch number of named pitch.
respell_with_flats() Respells named pitch with flats.
respell_with_sharps() Respells named pitch with sharps.
to_staff_position([clef]) Changes named pitch to staff position with optional clef.
transpose(expr) Transposes named pitch by expr.
__add__(interval) Adds named pitch to interval.
__copy__(\*args) Copies named pitch.
__eq__(arg) Is true when arg is a named pitch equal to this named pitch.
__float__() Changes named pitch to float.
__format__([format_specification]) Formats pitch.
__ge__(arg) Is true when named pitch is greater than or equal to arg.
__gt__(arg) Is true when named pitch is greater than arg.
__hash__() Required to be explicitly redefined on Python 3 if __eq__ changes.
__illustrate__() Illustrates pitch.
__int__() Changes named pitch to integer.
__le__(arg) Is true when named pitch is less than or equal to arg.
__lt__(arg) Is true when named pitch is less than arg.
__ne__(arg) Is true when named pitch does not equal arg.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of named pitch.
__sub__(arg) Subtracts arg from named pitch.

Read-only properties

NamedPitch.accidental

Gets accidental of named pitch.

Example 1. Gets accidental of C#5:

>>> NamedPitch("cs''").accidental
Accidental('s')

Example 2. Gets accidental of C5:

>>> NamedPitch("c''").accidental
Accidental('')

Returns accidental.

(Pitch).accidental_spelling

Accidental spelling of Abjad session.

>>> NamedPitch("c").accidental_spelling
'mixed'

Returns string.

NamedPitch.alteration_in_semitones

Gets alteration of named pitch in semitones.

Example 1. Gets alteration of C#5 in semitones:

>>> NamedPitch("cs''").alteration_in_semitones
1

Example 2. Gets alteration of Ctqs5 in semitones:

>>> NamedPitch("ctqs''").alteration_in_semitones
1.5

Returns integer or float.

NamedPitch.diatonic_pitch_class_name

Gets diatonic pitch-class name of named pitch.

Example 1. Gets diatonic pitch-class name of C#5:

>>> NamedPitch("cs''").diatonic_pitch_class_name
'c'

Example 2. Gets diatonic pitch-class names of many pitches:

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

Returns string.

NamedPitch.diatonic_pitch_class_number

Gets diatonic pitch-class number of named pitch.

Example 1. Gets diatonic pitch-class number of C#5:

>>> NamedPitch("cs''").diatonic_pitch_class_number
0

Example 2. Gets diatonic pitch-class numbers of many pitches:

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

Returns integer.

NamedPitch.diatonic_pitch_name

Gets diatonic pitch name of named pitch.

Example 1. Gets diatonic pitch name of C#5:

>>> NamedPitch("cs''").diatonic_pitch_name
"c''"

Example 2. Gets diatonic pitch names of many pitches:

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

Returns string.

NamedPitch.diatonic_pitch_number

Gets diatonic pitch number of named pitch.

Example 1. Gets diatonic pitch number of C#5:

>>> NamedPitch("cs''").diatonic_pitch_number
7

Example 2. Gets diatonic pitch numbers of many pitches:

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

Returns integer.

(Pitch).hertz

Gets hertz value of pitch.

>>> pitchtools.NamedPitch("a'").hertz
440.0
>>> pitchtools.NamedPitch("c'").hertz
261.6255653005986
>>> pitchtools.NamedPitch("c''").hertz
523.2511306011972

Returns float.

NamedPitch.named_pitch

Gets new named pitch.

Example 1. Gets new named pitch from C#5:

>>> NamedPitch("cs''").named_pitch
NamedPitch("cs''")

Example 2. Gets new named pitch from Db5:

>>> NamedPitch("df''").named_pitch
NamedPitch("df''")

Returns new named pitch.

NamedPitch.named_pitch_class

Gets named pitch-class of named pitch.

Example 1. Gets named pitch-class of C#5:

>>> NamedPitch("cs''").named_pitch_class
NamedPitchClass('cs')

Example 2. Gets named pitch-class of Db5:

>>> NamedPitch("df''").named_pitch_class
NamedPitchClass('df')

Returns named pitch-class.

NamedPitch.numbered_pitch

Gets numbered pitch corresponding to named pitch.

Example 1. Gets numbered pitch corresponding to C#5:

>>> NamedPitch("cs''").numbered_pitch
NumberedPitch(13)

Example 2. Gets numbered pitch corresponding to Db5:

>>> NamedPitch("df''").numbered_pitch
NumberedPitch(13)

Returns numbered pitch.

NamedPitch.numbered_pitch_class

Gets numbered pitch-class corresponding to named pitch.

Example 1. Gets numbered pitch-class corresponding to C#5:

>>> NamedPitch("cs''").numbered_pitch_class
NumberedPitchClass(1)

Example 2. Gets numbered pitch-class corresponding to Db5:

>>> NamedPitch("df''").numbered_pitch_class
NumberedPitchClass(1)

Returns numbered pitch-class.

NamedPitch.octave

Gets octave of named pitch.

Example 1. Gets octave of C#5:

>>> NamedPitch("cs''").octave
Octave(5)

Example 2. Gets octave of Db5:

>>> NamedPitch("df''").octave
Octave(5)

Returns octave.

NamedPitch.octave_number

Gets octave number of named pitch.

Example 1. Gets octave number of C#5:

>>> NamedPitch("cs''").octave_number
5

Example 2. Gets octave number of Db5:

>>> NamedPitch("df''").octave_number
5

Returns integer.

NamedPitch.pitch_class_name

Gets pitch-class name of named pitch.

Example 1. Gets pitch-class name of C#5:

>>> NamedPitch("cs''").pitch_class_name
'cs'

Example 2. Gets pitch-class name of Db5:

>>> NamedPitch("df''").pitch_class_name
'df'

Returns string.

NamedPitch.pitch_class_number

Gets pitch-class number of named pitch.

Example 1. Gets pitch-class number of C#5:

>>> NamedPitch("cs''").pitch_class_number
1

Example 2. Gets pitch-class number of Ctqs5:

>>> NamedPitch("ctqs''").pitch_class_number
1.5

Returns integer or float.

NamedPitch.pitch_class_octave_label

Gets pitch-class / octave label of named pitch.

Example 1. Gets pitch-class / octave label of C#5:

>>> NamedPitch("cs''").pitch_class_octave_label
'C#5'

Example 2. Gets pitch-class / octave label of Ctqs5:

>>> NamedPitch("ctqs''").pitch_class_octave_label
'C#+5'

Returns string.

NamedPitch.pitch_name

Gets pitch name of named pitch.

Example 1. Gets pitch name of C#5:

>>> NamedPitch("cs''").pitch_name
"cs''"

Example 2. Gets pitch name of Ctqs5:

>>> NamedPitch("ctqs''").pitch_name
"ctqs''"

Returns string.

NamedPitch.pitch_number

Gets pitch number of named pitch.

Example 1. Gets pitch number of C#5:

>>> NamedPitch("cs''").pitch_number
13

Example 2. Gets pitch number of Cbb5:

>>> NamedPitch("cff''").pitch_number
10

Returns integer or float.

Methods

NamedPitch.apply_accidental(accidental=None)

Applies accidental to named pitch.

Example 1. Applies sharp to C#5:

>>> NamedPitch("cs''").apply_accidental('s')
NamedPitch("css''")

Example 2. Applies sharp to Db5:

>>> NamedPitch("df''").apply_accidental('s')
NamedPitch("d''")

Returns new named pitch.

NamedPitch.invert(axis=None)

Inverts named pitch around axis.

Example 1. Inverts pitch around middle C explicitly:

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

Default behavior.

Example 2. Inverts pitch around middle C implicitly:

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

Default behavior.

Example 3. Inverts pitch around A3:

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

Interprets none-valued axis equal to middle C.

Returns new named pitch.

NamedPitch.multiply(n=1)

Multiplies pitch-class of named pitch by n while maintaining octave of named pitch.

Example 1. Multiplies D2 by 3:

>>> NamedPitch('d,').multiply(3)
NamedPitch('fs,')

Example 2. Multiplies D2 by 4:

>>> NamedPitch('d,').multiply(4)
NamedPitch('af,')

Returns new named pitch.

NamedPitch.respell_with_flats()

Respells named pitch with flats.

Example 1. Respells C#5 with flats:

>>> NamedPitch("cs''").respell_with_flats()
NamedPitch("df''")

Example 2. Respells Db5 with flats:

>>> NamedPitch("df''").respell_with_flats()
NamedPitch("df''")

Returns new named pitch.

NamedPitch.respell_with_sharps()

Respells named pitch with sharps.

Example 1. Respells Db5 with sharps:

>>> NamedPitch("df''").respell_with_sharps()
NamedPitch("cs''")

Example 2. Respells C#5 with sharps:

>>> NamedPitch("cs''").respell_with_sharps()
NamedPitch("cs''")

Returns new named pitch.

NamedPitch.to_staff_position(clef=None)

Changes named pitch to staff position with optional clef.

Example 1. Changes C#5 to absolute staff position:

>>> NamedPitch('C#5').to_staff_position()
StaffPosition(number=7)

Example 2. Changes C#5 to treble staff position:

>>> NamedPitch('C#5').to_staff_position(clef=Clef('treble'))
StaffPosition(number=1)

Example 3. Changes C#5 to bass staff position:

>>> NamedPitch('C#5').to_staff_position(clef=Clef('bass'))
StaffPosition(number=13)

Example 4. Marks up absolute staff position of many pitches:

>>> staff = 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 = Markup(staff_position.number)
...     attach(markup, note)
... 
>>> override(staff).text_script.staff_padding = 5
>>> show(staff) 

Example 5. Marks up treble staff position of many pitches:

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

Example 6. Marks up bass staff position of many pitches:

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

Returns staff position.

NamedPitch.transpose(expr)

Transposes named pitch by expr.

Example 1. Transposes C4 up a minor second:

>>> NamedPitch("c'").transpose('m2')
NamedPitch("df'")

Example 2. Transposes C4 down a major second:

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

Returns new named pitch.

Class & static methods

(Pitch).from_hertz(class_, hertz)

Creates pitch from hertz.

>>> pitchtools.NamedPitch.from_hertz(440)
NamedPitch("a'")
>>> pitchtools.NumberedPitch.from_hertz(440)
NumberedPitch(9)
>>> pitchtools.NamedPitch.from_hertz(519)
NamedPitch("c'")

Returns new pitch.

static NamedPitch.from_pitch_carrier(pitch_carrier)

Initializes named pitch from pitch_carrier.

Example 1. Initializes named pitch from named pitch:

>>> pitch = NamedPitch('df', 5)
>>> NamedPitch.from_pitch_carrier(pitch)
NamedPitch("df''")

Example 2. Initializes named pitch from note:

>>> note = Note("df''4")
>>> NamedPitch.from_pitch_carrier(note)
NamedPitch("df''")

Example 3. Initializes named pitch from note head:

>>> note = Note("df''4")
>>> NamedPitch.from_pitch_carrier(note.note_head)
NamedPitch("df''")

Example 4. Initializes named pitch from chord:

>>> chord = Chord("<df''>4")
>>> NamedPitch.from_pitch_carrier(chord)
NamedPitch("df''")

Example 5. Initializes named pitch from integer:

>>> NamedPitch.from_pitch_carrier(13)
NamedPitch("cs''")

Example 6. Initializes named pitch from numbered pitch-class:

>>> pitch_class = pitchtools.NumberedPitchClass(7)
>>> NamedPitch.from_pitch_carrier(pitch_class)
NamedPitch("g'")

Raises value error when pitch_carrier carries no pitch.

Raises value error when pitch_carrier carries more than one pitch.

Returns new named pitch.

static NamedPitch.from_staff_position(staff_position, clef=None)

Initializes named pitch from staff_position and optional clef.

Example 1. Initializes notes from absolute staff positions:

>>> for n in range(-6, 6):
...     staff_position = pitchtools.StaffPosition(n)
...     pitch = NamedPitch.from_staff_position(staff_position)
...     message = '{!s}\t{}'.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'

Example 2. Initializes notes inside treble staff from staff positions:

>>> clef = Clef('treble')
>>> for n in range(-6, 6):
...     staff_position = pitchtools.StaffPosition(n)
...     pitch = NamedPitch.from_staff_position(
...         staff_position,
...         clef=clef,
...         )
...     message = '{!s}\t{}'.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''

Example 3. Initializes notes inside bass staff from staff positions:

>>> clef = Clef('bass')
>>> for n in range(-6, 6):
...     staff_position = pitchtools.StaffPosition(n)
...     pitch = NamedPitch.from_staff_position(
...         staff_position,
...         clef=clef,
...         )
...     message = '{!s}\t{}'.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

Example 4. Initializes notes inside alto staff from staff positions:

>>> clef = Clef('alto')
>>> for n in range(-6, 6):
...     staff_position = pitchtools.StaffPosition(n)
...     pitch = NamedPitch.from_staff_position(
...         staff_position,
...         clef=clef,
...         )
...     message = '{!s}\t{}'.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.

(Pitch).is_diatonic_pitch_name(expr)

Is true when expr is a diatonic pitch name. Otherwise false.

>>> pitchtools.Pitch.is_diatonic_pitch_name("c''")
True

The regex (^[a-g,A-G])(,+|'+|)$ underlies this predicate.

Returns true or false.

(Pitch).is_diatonic_pitch_number(expr)

Is true when expr is a diatonic pitch number. Otherwise false.

>>> pitchtools.Pitch.is_diatonic_pitch_number(7)
True

The diatonic pitch numbers are equal to the set of integers.

Returns true or false.

(Pitch).is_pitch_carrier(expr)

Is true when expr is an Abjad pitch, note, note-head of chord instance. Otherwise false.

>>> note = Note("c'4")
>>> pitchtools.Pitch.is_pitch_carrier(note)
True

Returns true or false.

(Pitch).is_pitch_class_octave_number_string(expr)

Is true when expr is a pitch-class / octave number string. Otherwise false:

>>> pitchtools.Pitch.is_pitch_class_octave_number_string('C#2')
True

Quartertone accidentals are supported.

The regex ^([A-G])([#]{1,2}|[b]{1,2}|[#]?[+]|[b]?[~]|)([-]?[0-9]+)$ underlies this predicate.

Returns true or false.

(Pitch).is_pitch_name(expr)

True expr is a pitch name. Otherwise false.

>>> pitchtools.Pitch.is_pitch_name('c,')
True

The regex ^([a-g,A-G])(([s]{1,2}|[f]{1,2}|t?q?[f,s]|)!?)(,+|'+|)$ underlies this predicate.

Returns true or false.

(Pitch).is_pitch_number(expr)

Is true when expr is a pitch number. Otherwise false.

>>> pitchtools.Pitch.is_pitch_number(13)
True

The pitch numbers are equal to the set of all integers in union with the set of all integers plus of minus 0.5.

Returns true or false.

Special methods

NamedPitch.__add__(interval)

Adds named pitch to interval.

Example 1. Adds an ascending major second to C#5:

>>> NamedPitch("cs''") + pitchtools.NamedInterval('+M2')
NamedPitch("ds''")

Example 2. Adds a descending major second to C#5:

>>> NamedPitch("cs''") + pitchtools.NamedInterval('-M2')
NamedPitch("b'")

Returns new named pitch.

NamedPitch.__copy__(*args)

Copies named pitch.

Example 1. Copies C#5:

>>> import copy
>>> copy.copy(NamedPitch("cs''"))
NamedPitch("cs''")

Example 2. Copies Db5:

>>> copy.copy(NamedPitch("df''"))
NamedPitch("df''")

Returns new named pitch.

NamedPitch.__eq__(arg)

Is true when arg is a named pitch equal to this named pitch. Otherwise false.

Example 1. C#5 equals C#5:

>>> NamedPitch('C#5') == NamedPitch("cs''")
True

Example 2. C#5 does not equal Db5:

>>> NamedPitch('C#5') == NamedPitch('Db5')
False

Returns true or false.

NamedPitch.__float__()

Changes named pitch to float.

Example 1. Changes C#5 to float:

>>> float(NamedPitch('C#5'))
13.0

Example 2. Changes Ctqs5 to float:

>>> float(NamedPitch('C#+5'))
13.5

Returns float.

(Pitch).__format__(format_specification='')

Formats pitch.

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

Returns string.

NamedPitch.__ge__(arg)

Is true when named pitch is greater than or equal to arg. Otherwise false.

Returns true or false.

NamedPitch.__gt__(arg)

Is true when named pitch is greater than arg. Otherwise false.

Returns true or false.

NamedPitch.__hash__()

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(Pitch).__illustrate__()

Illustrates pitch.

Returns LilyPond file.

NamedPitch.__int__()

Changes named pitch to integer.

Example 1. Changes C#5 to integer:

>>> int(NamedPitch('C#5'))
13

Example 2. Changes Db5 to integer:

>>> int(NamedPitch('Db5'))
13

Returns integer.

NamedPitch.__le__(arg)

Is true when named pitch is less than or equal to arg. Otherwise false.

Returns true or false.

NamedPitch.__lt__(arg)

Is true when named pitch is less than arg. Otherwise false.

Returns true or false.

NamedPitch.__ne__(arg)

Is true when named pitch does not equal arg. Otherwise false.

Example 1. C#5 is not equal to D#5:

>>> NamedPitch("cs''") != NamedPitch("ds''")
True

Example 2. C#5 is equal to C#5:

>>> NamedPitch("cs''") != NamedPitch("cs''")
False

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NamedPitch.__str__()

Gets string representation of named pitch.

Example 1. Gets string representation of C#5:

>>> str(NamedPitch("cs''"))
"cs''"

Example 2. Gets string representation of Db5:

>>> str(NamedPitch("df''"))
"df''"

Returns string.

NamedPitch.__sub__(arg)

Subtracts arg from named pitch.

Example 1. Subtracts B4 from C#5:

>>> NamedPitch("cs''") - NamedPitch("b'")
NamedInterval('-M2')

Example 2. Subtracts F#5 from C#5:

>>> NamedPitch("cs''") - NamedPitch("fs''")
NamedInterval('+P4')

Returns named interval.