NamedPitch

class pitchtools.NamedPitch(*arguments)

Named pitch.

Initializes from pitch name:

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

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.
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 frequency of pitch in Herz.
invert([axis]) Inverts named pitch around axis.
is_diatonic_pitch_name(argument) Is true when argument is a diatonic pitch name.
is_diatonic_pitch_number(argument) Is true when argument is a diatonic pitch number.
is_pitch_carrier(argument) Is true when argument is an Abjad pitch, note, note-head of chord instance.
is_pitch_class_octave_number_string(argument) Is true when argument is a pitch-class / octave number string.
is_pitch_name(argument) Is true when argument is a pitch name.
is_pitch_number(argument) Is true when argument is a pitch number.
multiply([n]) Multiplies pitch-class of named pitch by n while maintaining octave of named pitch.
name Gets pitch name.
named_pitch Gets new named pitch.
named_pitch_class Gets named pitch-class of named pitch.
number Gets pitch number.
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.
pitch_class Gets pitch-class.
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([n]) Transposes named pitch by index n.
transpose_staff_position(staff_positions, ...) Transposes named pitch by staff_positions and interval.
__add__(interval) Adds named pitch to interval.
__copy__(*arguments) Copies named pitch.
__eq__(argument) Is true when argument is a named pitch equal to this named pitch.
__float__() Changes named pitch to float.
__format__([format_specification]) Formats pitch.
__ge__(argument) Is true when named pitch is greater than or equal to argument.
__gt__(argument) Is true when named pitch is greater than argument.
__hash__() Required to be explicitly redefined on Python 3 if __eq__ changes.
__illustrate__() Illustrates pitch.
__int__() Changes named pitch to integer.
__le__(argument) Is true when named pitch is less than or equal to argument.
__lt__(argument) Is true when named pitch is less than argument.
__ne__(argument) Is true when named pitch does not equal argument.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of named pitch.
__sub__(argument) Subtracts argument from named pitch.

Read-only properties

NamedPitch.accidental

Gets accidental of named pitch.

Gets accidental of C#5:

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

Gets accidental of C5:

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

Returns accidental.

NamedPitch.alteration_in_semitones

Gets alteration of named pitch in semitones.

Gets alteration of C#5 in semitones:

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

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.

Note

Deprecated.

Gets diatonic pitch-class name of C#5:

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

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.

Note

Deprecated.

Gets diatonic pitch-class number of C#5:

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

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.

Note

Deprecated.

Gets diatonic pitch name of C#5:

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

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.

Note

Deprecated.

Gets diatonic pitch number of C#5:

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

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 frequency of pitch in Herz.

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

Returns float.

NamedPitch.name

Gets pitch name.

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

Returns string.

NamedPitch.named_pitch

Gets new named pitch.

Note

Deprecated.

Gets new named pitch from C#5:

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

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.

Note

Deprecated.

Gets named pitch-class of C#5:

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

Gets named pitch-class of Db5:

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

Returns named pitch-class.

NamedPitch.number

Gets pitch number.

Gets pitch number of C#5:

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

Returns number.

NamedPitch.numbered_pitch

Gets numbered pitch corresponding to named pitch.

Note

Deprecated.

Gets numbered pitch corresponding to C#5:

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

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.

Note

Deprecated.

Gets numbered pitch-class corresponding to C#5:

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

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.

Gets octave of C#5:

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

Gets octave of Db5:

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

Returns octave.

NamedPitch.pitch_class

Gets pitch-class.

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

Returns named pitch-class.

NamedPitch.pitch_class_name

Gets pitch-class name of named pitch.

Note

Deprecated.

Gets pitch-class name of C#5:

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

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.

Note

Deprecated.

Gets pitch-class number of C#5:

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

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.

Note

Deprecated.

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

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

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.

Note

Deprecated.

Gets pitch name of C#5:

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

Gets pitch name of Ctqs5:

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

Returns string.

NamedPitch.pitch_number

Gets pitch number of named pitch.

Note

Deprecated.

Gets pitch number of C#5:

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

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.

Applies sharp to C#5:

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

Applies sharp to Db5:

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

Returns new named pitch.

NamedPitch.invert(axis=None)

Inverts named pitch around axis.

Inverts pitch around middle C explicitly:

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

Inverts pitch around middle C implicitly:

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

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.

Note

This is wrong. Should not preserve octave.

Multiplies D2 by 3:

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

Multiplies D2 by 4:

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

Returns new named pitch.

NamedPitch.respell_with_flats()

Respells named pitch with flats.

Respells C#5 with flats:

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

Respells Db5 with flats:

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

Returns new named pitch.

NamedPitch.respell_with_sharps()

Respells named pitch with sharps.

Respells Db5 with sharps:

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

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.

Changes C#5 to absolute staff position:

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

Changes C#5 to treble staff position:

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

Changes C#5 to bass staff position:

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

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) 

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) 

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(n=0)

Transposes named pitch by index n.

Transposes C4 up a minor second:

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

Transposes C4 down a major second:

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

Returns new named pitch.

NamedPitch.transpose_staff_position(staff_positions, interval)

Transposes named pitch by staff_positions and interval.

Transposes middle C but leaves at same staff position:

>>> pitch = NamedPitch(0)
>>> pitch.transpose_staff_position(0, -2)
NamedPitch("cff'")
>>> pitch.transpose_staff_position(0, -1.5)
NamedPitch("ctqf'")
>>> pitch.transpose_staff_position(0, -1)
NamedPitch("cf'")
>>> pitch.transpose_staff_position(0, -0.5)
NamedPitch("cqf'")
>>> pitch.transpose_staff_position(0, 0)
NamedPitch("c'")
>>> pitch.transpose_staff_position(0, 0.5)
NamedPitch("cqs'")
>>> pitch.transpose_staff_position(0, 1)
NamedPitch("cs'")
>>> pitch.transpose_staff_position(0, 1.5)
NamedPitch("ctqs'")

Transposes middle C and then respells up 1 staff position:

>>> pitch.transpose_staff_position(1, 0)
NamedPitch("dff'")
>>> pitch.transpose_staff_position(1, 0.5)
NamedPitch("dtqf'")
>>> pitch.transpose_staff_position(1, 1)
NamedPitch("df'")
>>> pitch.transpose_staff_position(1, 1.5)
NamedPitch("dqf'")
>>> pitch.transpose_staff_position(1, 2)
NamedPitch("d'")
>>> pitch.transpose_staff_position(1, 2.5)
NamedPitch("dqs'")
>>> pitch.transpose_staff_position(1, 3)
NamedPitch("ds'")
>>> pitch.transpose_staff_position(1, 3.5)
NamedPitch("dtqs'")
>>> pitch.transpose_staff_position(1, 4)
NamedPitch("dss'")

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.

Initializes named pitch from named pitch:

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

Initializes named pitch from note:

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

Initializes named pitch from note-head:

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

Initializes named pitch from chord:

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

Initializes named pitch from integer:

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

Initializes named pitch from numbered pitch-class:

>>> pitch_class = 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.

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'

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''

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

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(argument)

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

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

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

Returns true or false.

(Pitch).is_diatonic_pitch_number(argument)

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

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

Diatonic pitch numbers are equal to the set of integers.

Returns true or false.

(Pitch).is_pitch_carrier(argument)

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

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

Returns true or false.

(Pitch).is_pitch_class_octave_number_string(argument)

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

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

Supports quartertone accidentals:

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

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

Returns true or false.

(Pitch).is_pitch_name(argument)

Is true when argument is a pitch name. Otherwise false.

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

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(argument)

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

>>> pitchtools.Pitch.is_pitch_number(13)
True
>>> pitchtools.Pitch.is_pitch_number('text')
False

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.

Adds an ascending major second to C#5:

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

Adds a descending major second to C#5:

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

Returns new named pitch.

NamedPitch.__copy__(*arguments)

Copies named pitch.

Copies C#5:

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

Copies Db5:

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

Returns new named pitch.

NamedPitch.__eq__(argument)

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

C#5 equals C#5:

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

C#5 does not equal Db5:

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

Returns true or false.

NamedPitch.__float__()

Changes named pitch to float.

Changes C#5 to float:

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

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__(argument)

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

Returns true or false.

NamedPitch.__gt__(argument)

Is true when named pitch is greater than argument. 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.

Changes C#5 to integer:

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

Changes Db5 to integer:

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

Returns integer.

NamedPitch.__le__(argument)

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

Returns true or false.

NamedPitch.__lt__(argument)

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

Returns true or false.

NamedPitch.__ne__(argument)

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

C#5 is not equal to D#5:

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

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.

Gets string representation of C#5:

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

Gets string representation of Db5:

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

Returns string.

NamedPitch.__sub__(argument)

Subtracts argument from named pitch.

Subtracts B4 from C#5:

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

Subtracts F#5 from C#5:

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

Returns named interval.