NumberedPitchClass

class pitchtools.NumberedPitchClass(number=0)

Numbered pitch-class.

>>> import abjad
>>> import pytest

Initializes from number of semitones:

>>> abjad.NumberedPitchClass(13)
NumberedPitchClass(1)

Initializes from pitch name.

>>> abjad.NumberedPitchClass('d')
NumberedPitchClass(2)

Initializes from named pitch.

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

Initializes from numbered pitch.

>>> abjad.NumberedPitchClass(abjad.NumberedPitch(15))
NumberedPitchClass(3)

Initializes from named pitch-class.

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

Initializes from pitch-class / octave string:

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

Initializes from other numbered pitch-class:

>>> abjad.NumberedPitchClass(abjad.NumberedPitchClass(9))
NumberedPitchClass(9)

Initializes from note:

>>> abjad.NumberedPitchClass(abjad.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.
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) Is true when argument is a pitch-class number.
multiply([n]) Multiplies pitch-class number by n.
name Gets name of numbered pitch-class.
number Gets number.
pitch_class_label Gets pitch-class / octave label.
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__() Coerce 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.
__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.
__radd__(argument) Right-addition not defined on numbered pitch-classes.
__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.

>>> abjad.NumberedPitchClass(1).accidental
Accidental('sharp')

Returns accidental.

NumberedPitchClass.name

Gets name of numbered pitch-class.

>>> abjad.NumberedPitchClass(13).name
'cs'

Returns string.

NumberedPitchClass.number

Gets number.

>>> abjad.NumberedPitchClass(1).number
1
>>> abjad.NumberedPitchClass(13).number
1
NumberedPitchClass.pitch_class_label

Gets pitch-class / octave label.

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

Returns string.

Methods

NumberedPitchClass.invert(axis=None)

Inverts numbered pitch-class.

>>> for n in range(12):
...     pitch_class = abjad.NumberedPitchClass(n)
...     print(repr(pitch_class), repr(pitch_class.invert()))
...
NumberedPitchClass(0) NumberedPitchClass(0)
NumberedPitchClass(1) NumberedPitchClass(11)
NumberedPitchClass(2) NumberedPitchClass(10)
NumberedPitchClass(3) NumberedPitchClass(9)
NumberedPitchClass(4) NumberedPitchClass(8)
NumberedPitchClass(5) NumberedPitchClass(7)
NumberedPitchClass(6) NumberedPitchClass(6)
NumberedPitchClass(7) NumberedPitchClass(5)
NumberedPitchClass(8) NumberedPitchClass(4)
NumberedPitchClass(9) NumberedPitchClass(3)
NumberedPitchClass(10) NumberedPitchClass(2)
NumberedPitchClass(11) NumberedPitchClass(1)

Interprets axis of inversion equal to pitch-class 0.

Returns new numbered pitch-class.

NumberedPitchClass.multiply(n=1)

Multiplies pitch-class number by n.

>>> for n in range(12):
...     pitch_class = abjad.NumberedPitchClass(n)
...     print(repr(pitch_class), repr(pitch_class.multiply(5)))
...
NumberedPitchClass(0) NumberedPitchClass(0)
NumberedPitchClass(1) NumberedPitchClass(5)
NumberedPitchClass(2) NumberedPitchClass(10)
NumberedPitchClass(3) NumberedPitchClass(3)
NumberedPitchClass(4) NumberedPitchClass(8)
NumberedPitchClass(5) NumberedPitchClass(1)
NumberedPitchClass(6) NumberedPitchClass(6)
NumberedPitchClass(7) NumberedPitchClass(11)
NumberedPitchClass(8) NumberedPitchClass(4)
NumberedPitchClass(9) NumberedPitchClass(9)
NumberedPitchClass(10) NumberedPitchClass(2)
NumberedPitchClass(11) NumberedPitchClass(7)

Returns new numbered pitch-class.

NumberedPitchClass.transpose(n=0)

Transposes numbered pitch-class by index n.

>>> for n in range(12):
...     pitch_class = abjad.NumberedPitchClass(n)
...     print(repr(pitch_class), repr(pitch_class.transpose(-13)))
...
NumberedPitchClass(0) NumberedPitchClass(11)
NumberedPitchClass(1) NumberedPitchClass(0)
NumberedPitchClass(2) NumberedPitchClass(1)
NumberedPitchClass(3) NumberedPitchClass(2)
NumberedPitchClass(4) NumberedPitchClass(3)
NumberedPitchClass(5) NumberedPitchClass(4)
NumberedPitchClass(6) NumberedPitchClass(5)
NumberedPitchClass(7) NumberedPitchClass(6)
NumberedPitchClass(8) NumberedPitchClass(7)
NumberedPitchClass(9) NumberedPitchClass(8)
NumberedPitchClass(10) NumberedPitchClass(9)
NumberedPitchClass(11) NumberedPitchClass(10)

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.

>>> abjad.PitchClass.is_diatonic_pitch_class_name('g')
True
>>> abjad.PitchClass.is_diatonic_pitch_class_name('G')
True
>>> abjad.PitchClass.is_diatonic_pitch_class_name('Allegro')
False

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.

>>> abjad.PitchClass.is_diatonic_pitch_class_number(0)
True
>>> abjad.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.

>>> abjad.PitchClass.is_pitch_class_name('fs')
True
>>> abjad.PitchClass.is_pitch_class_name('fqs')
True
>>> abjad.PitchClass.is_pitch_class_name('f,,')
False

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)

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

>>> abjad.PitchClass.is_pitch_class_number(1)
True
>>> abjad.PitchClass.is_pitch_class_number(1.5)
True
>>> abjad.PitchClass.is_pitch_class_number(12)
False

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 = abjad.NumberedPitchClass(9)
>>> pitch_class + abjad.NumberedInterval(0)
NumberedPitchClass(9)
>>> pitch_class + abjad.NumberedInterval(1)
NumberedPitchClass(10)
>>> pitch_class + abjad.NumberedInterval(2)
NumberedPitchClass(11)
>>> pitch_class + abjad.NumberedInterval(3)
NumberedPitchClass(0)

Returns new numbered pitch-class.

NumberedPitchClass.__copy__(*arguments)

Copies numbered pitch-class.

>>> import copy
>>> pitch_class = abjad.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 = abjad.NumberedPitchClass(0)
>>> pitch_class_2 = abjad.NumberedPitchClass(0)
>>> pitch_class_3 = abjad.NumberedPitchClass(1)
>>> pitch_class_1 == pitch_class_1
True
>>> pitch_class_1 == pitch_class_2
True
>>> pitch_class_1 == pitch_class_3
False
>>> pitch_class_2 == pitch_class_1
True
>>> pitch_class_2 == pitch_class_2
True
>>> pitch_class_2 == pitch_class_3
False
>>> pitch_class_3 == pitch_class_1
False
>>> pitch_class_3 == pitch_class_2
False
>>> pitch_class_3 == pitch_class_3
True

Returns true or false.

(PitchClass).__float__()

Coerce to float.

Returns float.

NumberedPitchClass.__format__(format_specification='')

Formats numbered pitch-class.

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

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

Returns string.

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

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

(PitchClass).__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.

(PitchClass).__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:

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

Does not compare less than:

>>> abjad.NumberedPitchClass(2) < abjad.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 = abjad.NumberedPitchClass(9)
>>> -pitch_class
NumberedPitchClass(3)

Returns new numbered pitch-class.

NumberedPitchClass.__radd__(argument)

Right-addition not defined on numbered pitch-classes.

>>> statement = '1 + abjad.NumberedPitchClass(9)'
>>> pytest.raises(NotImplementedError, statement)
<ExceptionInfo NotImplementedError ...>

Raises not implemented error.

(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 is defined against both numbered intervals and against other pitch-classes.

>>> abjad.NumberedPitchClass(6) - abjad.NumberedPitchClass(6)
NumberedInversionEquivalentIntervalClass(0)
>>> abjad.NumberedPitchClass(6) - abjad.NumberedPitchClass(7)
NumberedInversionEquivalentIntervalClass(1)
>>> abjad.NumberedPitchClass(7) - abjad.NumberedPitchClass(6)
NumberedInversionEquivalentIntervalClass(1)
>>> abjad.NumberedPitchClass(6) - abjad.NumberedInterval(-1)
NumberedPitchClass(5)
>>> abjad.NumberedPitchClass(6) - abjad.NumberedInterval(0)
NumberedPitchClass(6)
>>> abjad.NumberedPitchClass(6) - abjad.NumberedInterval(1)
NumberedPitchClass(5)

Returns numbered inversion-equivalent interval-class.