NamedPitchClass

class pitchtools.NamedPitchClass(argument=None)

Named pitch-class.

Initializes from pitch-class name:

>>> NamedPitchClass('cs')
NamedPitchClass('cs')

Initializes from number of semitones:

>>> NamedPitchClass(14)
NamedPitchClass('d')

Initializes from named pitch:

>>> NamedPitchClass(NamedPitch('g,'))
NamedPitchClass('g')

Initializes from numbered pitch:

>>> NamedPitchClass(NumberedPitch(15))
NamedPitchClass('ef')

Initializes from numbered pitch-class:

>>> NamedPitchClass(NumberedPitchClass(4))
NamedPitchClass('e')

Initializes from named pitch-class:

>>> NamedPitchClass('C#5')
NamedPitchClass('cs')

Initializes from named pitch-class:

>>> NamedPitchClass(Note("a'8."))
NamedPitchClass('a')

Initializes from pitch-class name:

>>> pitch_class = NamedPitchClass('cs')
>>> pitch_class
NamedPitchClass('cs')

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

Bases

Attribute summary

accidental Gets accidental.
alteration_in_semitones Gets alteration in semitones.
apply_accidental(accidental) Applies accidental to named pitch-class.
diatonic_pitch_class_name Gets diatonic pitch-class name.
diatonic_pitch_class_number Gets diatonic pitch-class number.
invert([axis]) Inverts named pitch-class.
is_diatonic_pitch_class_name(argument) Is true when argument is a diatonic pitch-class name.
is_diatonic_pitch_class_number(argument) Is true when argument is a diatonic pitch-class number.
is_pitch_class_name(argument) Is true when argument is a pitch-class name.
is_pitch_class_number(argument) True argument is a pitch-class number.
multiply([n]) Multiplies named pitch-class by n.
named_pitch_class Gets named pitch-class.
number Gets number.
numbered_pitch_class Gets numbered pitch-class.
pitch_class_label Gets pitch-class label.
pitch_class_name Gets pitch-class name.
pitch_class_number Gets pitch-class number.
transpose([n]) Transposes named pitch-class by index n.
__add__(named_interval) Adds named_interval to named pitch-class.
__copy__(*arguments) Copies named pitch-class.
__eq__(argument) Is true when argument can be coerced to a named pitch-class with pitch-class name equal to that of this named pitch-class.
__float__() Changes named pitch-class to a float.
__format__([format_specification]) Formats named pitch-class.
__hash__() Hashes named pitch-class.
__int__() Changes named pitch-class to an integer.
__lt__(argument) Is true when argument is a named pitch-class with a pitch number greater than that of this named pitch-class.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of named pitch-class.
__sub__(argument) Subtracts argument from named pitch-class.

Read-only properties

NamedPitchClass.accidental

Gets accidental.

>>> NamedPitchClass('cs').accidental
Accidental('s')

Returns accidental.

NamedPitchClass.alteration_in_semitones

Gets alteration in semitones.

>>> NamedPitchClass('cs').alteration_in_semitones
1

Returns nonnegative integer or float.

NamedPitchClass.diatonic_pitch_class_name

Gets diatonic pitch-class name.

>>> NamedPitchClass('cs').diatonic_pitch_class_name
'c'

Returns string.

NamedPitchClass.diatonic_pitch_class_number

Gets diatonic pitch-class number.

>>> NamedPitchClass('cs').diatonic_pitch_class_number
0

Returns nonnegative integer.

NamedPitchClass.named_pitch_class

Gets named pitch-class.

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

Returns new named pitch-class.

NamedPitchClass.number

Gets number.

>>> NamedPitchClass('cs').number
1

Returns nonnegative integer or float.

NamedPitchClass.numbered_pitch_class

Gets numbered pitch-class.

>>> NamedPitchClass('cs').numbered_pitch_class
NumberedPitchClass(1)

Returns numbered pitch-class.

NamedPitchClass.pitch_class_label

Gets pitch-class label.

>>> NamedPitchClass('cs').pitch_class_label
'C#'

Returns string.

NamedPitchClass.pitch_class_name

Gets pitch-class name.

>>> NamedPitchClass('cs').pitch_class_name
'cs'

Returns string.

NamedPitchClass.pitch_class_number

Gets pitch-class number.

>>> NamedPitchClass('cs').pitch_class_number
1

Returns integer or float.

Methods

NamedPitchClass.apply_accidental(accidental)

Applies accidental to named pitch-class.

>>> NamedPitchClass('cs').apply_accidental('qs')
NamedPitchClass('ctqs')

Returns new named pitch-class.

NamedPitchClass.invert(axis=None)

Inverts named pitch-class.

Not yet implemented.

NamedPitchClass.multiply(n=1)

Multiplies named pitch-class by n.

>>> NamedPitchClass('cs').multiply(3)
NamedPitchClass('ef')

Returns new named pitch-class.

NamedPitchClass.transpose(n=0)

Transposes named pitch-class by index n.

>>> named_interval = NamedInterval('major', 2)
>>> NamedPitchClass('cs').transpose(named_interval)
NamedPitchClass('ds')

Returns new named pitch-class.

Class & static methods

(PitchClass).is_diatonic_pitch_class_name(argument)

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

>>> pitchtools.PitchClass.is_diatonic_pitch_class_name('c')
True

The regex ^[a-g,A-G]$ underlies this predicate.

Returns true or false.

(PitchClass).is_diatonic_pitch_class_number(argument)

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

>>> pitchtools.PitchClass.is_diatonic_pitch_class_number(0)
True
>>> pitchtools.PitchClass.is_diatonic_pitch_class_number(-5)
False

The diatonic pitch-class numbers are equal to the set [0, 1, 2, 3, 4, 5, 6].

Returns true or false.

(PitchClass).is_pitch_class_name(argument)

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

>>> pitchtools.PitchClass.is_pitch_class_name('fs')
True

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

Returns true or false.

(PitchClass).is_pitch_class_number(argument)

True argument is a pitch-class number. Otherwise false.

>>> pitchtools.PitchClass.is_pitch_class_number(1)
True

The pitch-class numbers are equal to the set [0, 0.5, ..., 11, 11.5].

Returns true or false.

Special methods

NamedPitchClass.__add__(named_interval)

Adds named_interval to named pitch-class.

>>> pitch_class + NamedInterval('+M9')
NamedPitchClass('ds')

Return new named pitch-class.

NamedPitchClass.__copy__(*arguments)

Copies named pitch-class.

>>> import copy
>>> copy.copy(pitch_class)
NamedPitchClass('cs')

Returns new named pitch-class.

NamedPitchClass.__eq__(argument)

Is true when argument can be coerced to a named pitch-class with pitch-class name equal to that of this named pitch-class.

>>> pitch_class == 'cs'
True

Otherwise false:

>>> pitch_class == 'ds'
False

Returns true or false.

NamedPitchClass.__float__()

Changes named pitch-class to a float.

>>> float(pitch_class)
1.0

Returns float.

NamedPitchClass.__format__(format_specification='')

Formats named pitch-class.

>>> format(NamedPitchClass('cs'))
"pitchtools.NamedPitchClass('cs')"

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

Returns string.

NamedPitchClass.__hash__()

Hashes named pitch-class.

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

Returns integer.

NamedPitchClass.__int__()

Changes named pitch-class to an integer.

>>> int(pitch_class)
1

Returns nonnegative integer.

NamedPitchClass.__lt__(argument)

Is true when argument is a named pitch-class with a pitch number greater than that of this named pitch-class.

Compares less than:

>>> NamedPitchClass('cs') < NamedPitchClass('d')
True

Does not compare less than:

>>> NamedPitchClass('d') < NamedPitchClass('cs')
False

Raises type error when argument is not a named pitch-class.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NamedPitchClass.__str__()

Gets string representation of named pitch-class.

>>> str(pitch_class)
'cs'

Returns string.

NamedPitchClass.__sub__(argument)

Subtracts argument from named pitch-class.

>>> pitch_class - NamedPitchClass('g')
NamedInversionEquivalentIntervalClass('+aug4')

Returns named inversion-equivalent interval-class.