NumberedPitchClass¶

class
pitchtools.
NumberedPitchClass
(expr=None)¶ Numbered pitchclass.
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 pitchclass.
>>> pitchtools.NumberedPitchClass(pitchtools.NamedPitchClass('e')) NumberedPitchClass(4)
Example 6. Initializes from numbered pitchclass.
>>> pitchtools.NumberedPitchClass('C#5') NumberedPitchClass(1)
Example 7. Initializes from numbered pitchclass.
>>> pitchtools.NumberedPitchClass(Note("a'8.")) NumberedPitchClass(9)
Lineage¶
Bases¶
abjad.tools.pitchtools.PitchClass
abjad.tools.abctools.AbjadValueObject
abjad.tools.abctools.AbjadObject
abjad.tools.abctools.AbjadObject.AbstractBase
builtins.object
Attribute summary¶
accidental 
Accidental of numbered pitchclass. 
accidental_spelling 
Accidental spelling of pitchclass. 
alteration_in_semitones 
Alteration of numbered pitchclass in semitones. 
apply_accidental ([accidental]) 
Applies accidental to numbered pitchclass. 
diatonic_pitch_class_name 
Diatonic pitchclass name corresponding to numbered pitchclass. 
diatonic_pitch_class_number 
Diatonic pitchclass number corresponding to numbered pitchclass. 
invert ([axis]) 
Inverts numbered pitchclass. 
is_diatonic_pitch_class_name (expr) 
Is true when expr is a diatonic pitchclass name. 
is_diatonic_pitch_class_number (expr) 
Is true when expr is a diatonic pitchclass number. 
is_pitch_class_name (expr) 
Is true when expr is a pitchclass name. 
is_pitch_class_number (expr) 
True expr is a pitchclass number. 
multiply ([n]) 
Multiplies pitchclass number by n. 
named_pitch_class 
Named pitchclass corresponding to numbered pitchclass. 
numbered_pitch_class 
Numbered pitchclass. 
pitch_class_label 
Pitchclass / octave label of numbered pitchclass. 
pitch_class_name 
Pitchclass name. 
pitch_class_number 
Pitchclass number. 
transpose (n) 
Transposes numbered pitchclass by n semitones. 
__add__ (expr) 
Adds expr to numbered pitchclass. 
__copy__ (\*args) 
Copies numbered pitchclass. 
__eq__ (arg) 
Is true when arg is a numbered pitchclass with pitchclass number equal to that of this numbered pitchclass. 
__float__ () 
Changes numbered pitchclass to float. 
__format__ ([format_specification]) 
Formats component. 
__ge__ (other[, NotImplemented]) 
Return a >= b. 
__gt__ (other[, NotImplemented]) 
Return a > b. 
__hash__ () 
Hashes numbered pitchclass. 
__int__ () 
Changes numbered pitchclass to integer. 
__le__ (other[, NotImplemented]) 
Return a <= b. 
__lt__ (expr) 
Is true when expr is a numbered pitchclass with a pitch number greater than that of this numberd pitchclass. 
__ne__ (expr) 
Is true when Abjad object does not equal expr. 
__neg__ () 
Negates numbered pitchclass. 
__repr__ () 
Gets interpreter representation of Abjad object. 
__str__ () 
String representation of numbered pitchclass. 
__sub__ (expr) 
Subtracts expr from numbered pitchclass. 
Readonly properties¶

NumberedPitchClass.
accidental
¶ Accidental of numbered pitchclass.
>>> pitchtools.NumberedPitchClass(1).accidental Accidental('s')
Returns accidental.

(
PitchClass
).accidental_spelling
¶ Accidental spelling of pitchclass.
Returns string.

NumberedPitchClass.
alteration_in_semitones
¶ Alteration of numbered pitchclass 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 pitchclass name corresponding to numbered pitchclass.
>>> pitchtools.NumberedPitchClass(1).diatonic_pitch_class_name 'c'
Returns string.

NumberedPitchClass.
diatonic_pitch_class_number
¶ Diatonic pitchclass number corresponding to numbered pitchclass.
>>> pitchtools.NumberedPitchClass(1).diatonic_pitch_class_number 0
Returns integer.

NumberedPitchClass.
named_pitch_class
¶ Named pitchclass corresponding to numbered pitchclass.
>>> pitchtools.NumberedPitchClass(13).named_pitch_class NamedPitchClass('cs')
Returns named pitchclass.

NumberedPitchClass.
numbered_pitch_class
¶ Numbered pitchclass.
>>> pitchtools.NumberedPitchClass(13).numbered_pitch_class NumberedPitchClass(1)
Returns new numbered pitchclass.

NumberedPitchClass.
pitch_class_label
¶ Pitchclass / octave label of numbered pitchclass.
>>> pitchtools.NumberedPitchClass(13).pitch_class_label 'C#'
Returns string.

NumberedPitchClass.
pitch_class_name
¶ Pitchclass name.
>>> pitchtools.NumberedPitchClass(1).pitch_class_name 'cs'
Returns string.

NumberedPitchClass.
pitch_class_number
¶ Pitchclass number.
>>> pitchtools.NumberedPitchClass(1).pitch_class_number 1
Returns number.
Methods¶

NumberedPitchClass.
apply_accidental
(accidental=None)¶ Applies accidental to numbered pitchclass.
>>> pitchtools.NumberedPitchClass(1).apply_accidental('flat') NumberedPitchClass(0)
Returns new numbered pitchclass.

NumberedPitchClass.
invert
(axis=None)¶ Inverts numbered pitchclass.
Interprets axis of inversion equal to pitchclass 0.
Returns new numbered pitchclass.

NumberedPitchClass.
multiply
(n=1)¶ Multiplies pitchclass number by n.
>>> pitchtools.NumberedPitchClass(11).multiply(3) NumberedPitchClass(9)
Returns new numbered pitchclass.

NumberedPitchClass.
transpose
(n)¶ Transposes numbered pitchclass by n semitones.
Returns new numbered pitchclass.
Class & static methods¶

(
PitchClass
).is_diatonic_pitch_class_name
(expr)¶ Is true when expr is a diatonic pitchclass name. Otherwise false.
>>> pitchtools.PitchClass.is_diatonic_pitch_class_name('c') True
The regex
^[ag,AG]$
underlies this predicate.Returns true or false.

(
PitchClass
).is_diatonic_pitch_class_number
(expr)¶ Is true when expr is a diatonic pitchclass number. Otherwise false.
>>> pitchtools.PitchClass.is_diatonic_pitch_class_number(0) True
>>> pitchtools.PitchClass.is_diatonic_pitch_class_number(5) False
The diatonic pitchclass 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 pitchclass name. Otherwise false.
>>> pitchtools.PitchClass.is_pitch_class_name('fs') True
The regex
^([ag,AG])(([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 pitchclass number. Otherwise false.
>>> pitchtools.PitchClass.is_pitch_class_number(1) True
The pitchclass 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 pitchclass.
>>> pitch_class = pitchtools.NumberedPitchClass(9) >>> interval = pitchtools.NumberedInterval(4) >>> pitch_class + interval NumberedPitchClass(1)
Returns new numbered pitchclass.

NumberedPitchClass.
__copy__
(*args)¶ Copies numbered pitchclass.
>>> import copy >>> pitch_class = pitchtools.NumberedPitchClass(9) >>> copy.copy(pitch_class) NumberedPitchClass(9)
Returns new numbered pitchclass.

NumberedPitchClass.
__eq__
(arg)¶ Is true when arg is a numbered pitchclass with pitchclass number equal to that of this numbered pitchclass.
>>> 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 pitchclass 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 pitchclass.
Required to be explicitly redefined on Python 3 if __eq__ changes.
Returns integer.

NumberedPitchClass.
__int__
()¶ Changes numbered pitchclass 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 pitchclass with a pitch number greater than that of this numberd pitchclass.
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 pitchclass.

(
AbjadObject
).__ne__
(expr)¶ Is true when Abjad object does not equal expr. Otherwise false.
Returns true or false.

NumberedPitchClass.
__neg__
()¶ Negates numbered pitchclass.
>>> pitch_class = pitchtools.NumberedPitchClass(9) >>> pitch_class NumberedPitchClass(3)
Returns new numbered pitchclass.

(
AbjadObject
).__repr__
()¶ Gets interpreter representation of Abjad object.
Returns string.

NumberedPitchClass.
__str__
()¶ String representation of numbered pitchclass.
Returns string.

NumberedPitchClass.
__sub__
(expr)¶ Subtracts expr from numbered pitchclass.
Subtraction defined against both numbered intervals and against other pitchclasses.
Returns numbered inversionequivalent intervalclass.