NumberedPitchClass

class pitchtools.NumberedPitchClass(expr=None)

Numbered pitch-class.

Example 1. Initializes from number of semitones:

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

Example 2. Initializes from pitch name.

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

Example 3. Initializes from named pitch.

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

Example 4. Initializes from numbered pitch.

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

Example 5. Initializes from named pitch-class.

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

Example 6. Initializes from numbered pitch-class.

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

Example 7. Initializes from numbered pitch-class.

>>> pitchtools.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 Accidental of numbered pitch-class.
accidental_spelling Accidental spelling of pitch-class.
alteration_in_semitones Alteration of numbered pitch-class in semitones.
apply_accidental([accidental]) Applies accidental to numbered pitch-class.
diatonic_pitch_class_name Diatonic pitch-class name corresponding to numbered pitch-class.
diatonic_pitch_class_number Diatonic pitch-class number corresponding to numbered pitch-class.
invert([axis]) Inverts numbered pitch-class.
is_diatonic_pitch_class_name(expr) Is true when expr is a diatonic pitch-class name.
is_diatonic_pitch_class_number(expr) Is true when expr is a diatonic pitch-class number.
is_pitch_class_name(expr) Is true when expr is a pitch-class name.
is_pitch_class_number(expr) True expr is a pitch-class number.
multiply([n]) Multiplies pitch-class number by n.
named_pitch_class Named pitch-class corresponding to numbered pitch-class.
numbered_pitch_class Numbered pitch-class.
pitch_class_label Pitch-class / octave label of numbered pitch-class.
pitch_class_name Pitch-class name.
pitch_class_number Pitch-class number.
transpose(n) Transposes numbered pitch-class by n semitones.
__add__(expr) Adds expr to numbered pitch-class.
__copy__(\*args) Copies numbered pitch-class.
__eq__(arg) Is true when arg 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 component.
__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__(expr) Is true when expr is a numbered pitch-class with a pitch number greater than that of this numberd pitch-class.
__ne__(expr) Is true when Abjad object does not equal expr.
__neg__() Negates numbered pitch-class.
__repr__() Gets interpreter representation of Abjad object.
__str__() String representation of numbered pitch-class.
__sub__(expr) Subtracts expr from numbered pitch-class.

Read-only properties

NumberedPitchClass.accidental

Accidental of numbered pitch-class.

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

Returns accidental.

(PitchClass).accidental_spelling

Accidental spelling of pitch-class.

Returns string.

NumberedPitchClass.alteration_in_semitones

Alteration of numbered pitch-class in semitones.

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

Returns integer or float.

NumberedPitchClass.diatonic_pitch_class_name

Diatonic pitch-class name corresponding to numbered pitch-class.

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

Returns string.

NumberedPitchClass.diatonic_pitch_class_number

Diatonic pitch-class number corresponding to numbered pitch-class.

>>> pitchtools.NumberedPitchClass(1).diatonic_pitch_class_number
0

Returns integer.

NumberedPitchClass.named_pitch_class

Named pitch-class corresponding to numbered pitch-class.

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

Returns named pitch-class.

NumberedPitchClass.numbered_pitch_class

Numbered pitch-class.

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

Returns new numbered pitch-class.

NumberedPitchClass.pitch_class_label

Pitch-class / octave label of numbered pitch-class.

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

Returns string.

NumberedPitchClass.pitch_class_name

Pitch-class name.

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

Returns string.

NumberedPitchClass.pitch_class_number

Pitch-class number.

>>> pitchtools.NumberedPitchClass(1).pitch_class_number
1

Returns number.

Methods

NumberedPitchClass.apply_accidental(accidental=None)

Applies accidental to numbered pitch-class.

>>> pitchtools.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.

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

Returns new numbered pitch-class.

NumberedPitchClass.transpose(n)

Transposes numbered pitch-class by n semitones.

Returns new numbered pitch-class.

Class & static methods

(PitchClass).is_diatonic_pitch_class_name(expr)

Is true when expr 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(expr)

Is true when expr 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(expr)

Is true when expr 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(expr)

True expr 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__(expr)

Adds expr to numbered pitch-class.

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

Returns new numbered pitch-class.

NumberedPitchClass.__copy__(*args)

Copies numbered pitch-class.

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

Returns new numbered pitch-class.

NumberedPitchClass.__eq__(arg)

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

>>> pitch_class_1 = pitchtools.NumberedPitchClass(9)
>>> pitch_class_2 = pitchtools.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 = pitchtools.NumberedPitchClass(9)
>>> float(pitch_class)
9.0

Returns float.

(PitchClass).__format__(format_specification='')

Formats component.

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 = pitchtools.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__(expr)

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

Example 1. Compares less than:

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

Example 2. Does not compare less than:

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

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

(AbjadObject).__ne__(expr)

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

Returns true or false.

NumberedPitchClass.__neg__()

Negates numbered pitch-class.

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

Returns new numbered pitch-class.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NumberedPitchClass.__str__()

String representation of numbered pitch-class.

Returns string.

NumberedPitchClass.__sub__(expr)

Subtracts expr from numbered pitch-class.

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

Returns numbered inversion-equivalent interval-class.