NumberedPitchClass

class pitchtools.NumberedPitchClass(argument=None)

Numbered pitch-class.

Initializes from number of semitones:

>>> NumberedPitchClass(13)
NumberedPitchClass(1)

Initializes from pitch name.

>>> NumberedPitchClass('d')
NumberedPitchClass(2)

Initializes from named pitch.

>>> NumberedPitchClass(NamedPitch('g,'))
NumberedPitchClass(7)

Initializes from numbered pitch.

>>> NumberedPitchClass(NumberedPitch(15))
NumberedPitchClass(3)

Initializes from named pitch-class.

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

Initializes from numbered pitch-class.

>>> NumberedPitchClass('C#5')
NumberedPitchClass(1)

Initializes from numbered pitch-class.

>>> NumberedPitchClass(Note("a'8."))
NumberedPitchClass(9)

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.NumberedPitchClass.NumberedPitchClass" [color=black, fontcolor=white, group=2, label=<<B>NumberedPitchClass</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.NumberedPitchClass.NumberedPitchClass"; } 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 numbered pitch-class.
diatonic_pitch_class_name Gets diatonic pitch-class name.
diatonic_pitch_class_number Gets diatonic pitch-class number.
invert([axis]) Inverts numbered 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 pitch-class number 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 / octave label.
pitch_class_name Gets pitch-class name.
pitch_class_number Gets pitch-class number.
transpose([n]) Transposes numbered pitch-class by index n.
__add__(argument) Adds argument to numbered pitch-class.
__copy__(*arguments) Copies numbered pitch-class.
__eq__(argument) Is true when argument is a numbered pitch-class with pitch-class number equal to that of this numbered pitch-class.
__float__() Changes numbered pitch-class to float.
__format__([format_specification]) Formats numbered pitch-class.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes numbered pitch-class.
__int__() Changes numbered pitch-class to integer.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(argument) Is true when argument is a numbered pitch-class with a pitch number greater than that of this numberd pitch-class.
__ne__(argument) Is true when Abjad object does not equal argument.
__neg__() Negates numbered pitch-class.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of numbered pitch-class.
__sub__(argument) Subtracts argument from numbered pitch-class.

Read-only properties

NumberedPitchClass.accidental

Gets accidental.

>>> NumberedPitchClass(1).accidental
Accidental('s')

Returns accidental.

NumberedPitchClass.alteration_in_semitones

Gets alteration in semitones.

>>> NumberedPitchClass(1).alteration_in_semitones
1
>>> NumberedPitchClass(10.5).alteration_in_semitones
-0.5

Returns integer or float.

NumberedPitchClass.diatonic_pitch_class_name

Gets diatonic pitch-class name.

>>> NumberedPitchClass(1).diatonic_pitch_class_name
'c'

Returns string.

NumberedPitchClass.diatonic_pitch_class_number

Gets diatonic pitch-class number.

>>> NumberedPitchClass(1).diatonic_pitch_class_number
0

Returns integer.

NumberedPitchClass.named_pitch_class

Gets named pitch-class.

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

Returns named pitch-class.

NumberedPitchClass.number

Gets number.

>>> NumberedPitchClass(1).number
1
>>> NumberedPitchClass(13).number
1
NumberedPitchClass.numbered_pitch_class

Gets numbered pitch-class.

>>> NumberedPitchClass(13).numbered_pitch_class
NumberedPitchClass(1)

Returns new numbered pitch-class.

NumberedPitchClass.pitch_class_label

Gets pitch-class / octave label.

>>> NumberedPitchClass(13).pitch_class_label
'C#'

Returns string.

NumberedPitchClass.pitch_class_name

Gets pitch-class name.

>>> NumberedPitchClass(1).pitch_class_name
'cs'

Returns string.

NumberedPitchClass.pitch_class_number

Gets pitch-class number.

>>> NumberedPitchClass(1).pitch_class_number
1

Returns number.

Methods

NumberedPitchClass.apply_accidental(accidental=None)

Applies accidental to numbered pitch-class.

>>> NumberedPitchClass(1).apply_accidental('flat')
NumberedPitchClass(0)

Returns new numbered pitch-class.

NumberedPitchClass.invert(axis=None)

Inverts numbered pitch-class.

Interprets axis of inversion equal to pitch-class 0.

Returns new numbered pitch-class.

NumberedPitchClass.multiply(n=1)

Multiplies pitch-class number by n.

>>> NumberedPitchClass(11).multiply(3)
NumberedPitchClass(9)

Returns new numbered pitch-class.

NumberedPitchClass.transpose(n=0)

Transposes numbered pitch-class by index n.

Returns new numbered 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

NumberedPitchClass.__add__(argument)

Adds argument to numbered pitch-class.

>>> pitch_class = NumberedPitchClass(9)
>>> interval = NumberedInterval(4)
>>> pitch_class + interval
NumberedPitchClass(1)

Returns new numbered pitch-class.

NumberedPitchClass.__copy__(*arguments)

Copies numbered pitch-class.

>>> import copy
>>> pitch_class = NumberedPitchClass(9)
>>> copy.copy(pitch_class)
NumberedPitchClass(9)

Returns new numbered pitch-class.

NumberedPitchClass.__eq__(argument)

Is true when argument is a numbered pitch-class with pitch-class number equal to that of this numbered pitch-class.

>>> pitch_class_1 = NumberedPitchClass(9)
>>> pitch_class_2 = NumberedPitchClass(3)
>>> pitch_class_1 == pitch_class_1
True

Otherwise false:

>>> pitch_class_1 == pitch_class_2
False

Returns true or false.

NumberedPitchClass.__float__()

Changes numbered pitch-class to float.

>>> pitch_class = NumberedPitchClass(9)
>>> float(pitch_class)
9.0

Returns float.

NumberedPitchClass.__format__(format_specification='')

Formats numbered pitch-class.

>>> format(NumberedPitchClass(13))
'pitchtools.NumberedPitchClass(1)'

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

Returns string.

NumberedPitchClass.__ge__(other, NotImplemented=NotImplemented)

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

NumberedPitchClass.__gt__(other, NotImplemented=NotImplemented)

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

NumberedPitchClass.__hash__()

Hashes numbered pitch-class.

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

Returns integer.

NumberedPitchClass.__int__()

Changes numbered pitch-class to integer.

>>> pitch_class = NumberedPitchClass(9)
>>> int(pitch_class)
9

Returns integer.

NumberedPitchClass.__le__(other, NotImplemented=NotImplemented)

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

NumberedPitchClass.__lt__(argument)

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

Compares less than:

>>> NumberedPitchClass(1) < NumberedPitchClass(2)
True

Does not compare less than:

>>> NumberedPitchClass(2) < NumberedPitchClass(1)
False

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

(AbjadObject).__ne__(argument)

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

Returns true or false.

NumberedPitchClass.__neg__()

Negates numbered pitch-class.

>>> pitch_class = NumberedPitchClass(9)
>>> -pitch_class
NumberedPitchClass(3)

Returns new numbered pitch-class.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NumberedPitchClass.__str__()

Gets string representation of numbered pitch-class.

Returns string.

NumberedPitchClass.__sub__(argument)

Subtracts argument from numbered pitch-class.

Subtraction defined against both numbered intervals and against other pitch-classes.

Returns numbered inversion-equivalent interval-class.