NumberedPitch

class pitchtools.NumberedPitch(pitch_number=None)

Numbered pitch.

Example 1. Initializes from pitch number:

>>> numbered_pitch = pitchtools.NumberedPitch(13)
>>> numbered_pitch
NumberedPitch(13)
>>> show(numbered_pitch) 

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

Bases

Attribute summary

accidental Accidental of numbered pitch.
accidental_spelling Accidental spelling of Abjad session.
alteration_in_semitones Alteration of numbered pitch in semitones.
apply_accidental([accidental]) Applies accidental to numbered pitch.
diatonic_pitch_class_name Diatonic pitch-class name corresponding to numbered pitch.
diatonic_pitch_class_number Diatonic pitch-class number of numbered pitch.
diatonic_pitch_name Diatonic pitch name of numbered pitch.
diatonic_pitch_number Diatonic pitch-class number corresponding to numbered pitch.
from_hertz(class_, hertz) Creates pitch from hertz.
hertz Gets hertz value of pitch.
interpolate(stop_pitch, fraction) Interpolates between this pitch and stop_pitch by fraction amount.
invert([axis]) Inverts numberd pitch around axis.
is_diatonic_pitch_name(expr) Is true when expr is a diatonic pitch name.
is_diatonic_pitch_number(expr) Is true when expr is a diatonic pitch number.
is_pitch_carrier(expr) Is true when expr is an Abjad pitch, note, note-head of chord instance.
is_pitch_class_octave_number_string(expr) Is true when expr is a pitch-class / octave number string.
is_pitch_name(expr) True expr is a pitch name.
is_pitch_number(expr) Is true when expr is a pitch number.
multiply([n]) Multiplies pitch-class of numbered pitch by n and maintains octave.
named_pitch Named pitch corresponding to numbered pitch.
named_pitch_class Named pitch-class corresponding to numbered pitch.
numbered_pitch Numbered pitch.
numbered_pitch_class Numbered pitch-class corresponding to numbered pitch.
octave Octave of numbered pitch.
octave_number Octave number of numbered pitch.
pitch_class_name Pitch-class name of numbered pitch.
pitch_class_number Pitch-class number of numbered pitch.
pitch_class_octave_label Pitch-class / octave label of numbered pitch.
pitch_name Pitch name corresponding to numbered pitch.
pitch_number Pitch number of numbered pitch.
transpose([n]) Tranposes numbered pitch by n semitones.
__add__(arg) Adds arg to numberd pitch.
__copy__(\*args) Copies Abjad value object.
__eq__(expr) Is true when all initialization values of Abjad value object equal the initialization values of expr.
__float__() Changes numbered pitch to float.
__format__([format_specification]) Formats pitch.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes Abjad value object.
__illustrate__() Illustrates pitch.
__int__() Changes numbered pitch to integer.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(arg) Is true when arg can be coerced to a numbered pitch and when this numbered pitch is less than arg.
__ne__(expr) Is true when Abjad object does not equal expr.
__neg__() Negates numbered pitch.
__repr__() Gets interpreter representation of Abjad object.
__str__() String representation of numbered pitch.
__sub__(arg) Subtracts arg from numbered pitch.

Read-only properties

NumberedPitch.accidental

Accidental of numbered pitch.

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

Returns accidental.

(Pitch).accidental_spelling

Accidental spelling of Abjad session.

>>> NamedPitch("c").accidental_spelling
'mixed'

Returns string.

NumberedPitch.alteration_in_semitones

Alteration of numbered pitch in semitones.

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

Returns integer or float.

NumberedPitch.diatonic_pitch_class_name

Diatonic pitch-class name corresponding to numbered pitch.

>>> pitchtools.NumberedPitch(13).diatonic_pitch_class_name
'c'

Returns string.

NumberedPitch.diatonic_pitch_class_number

Diatonic pitch-class number of numbered pitch.

>>> pitchtools.NumberedPitch(13).diatonic_pitch_class_number
0

Returns integer.

NumberedPitch.diatonic_pitch_name

Diatonic pitch name of numbered pitch.

>>> pitchtools.NumberedPitch(13).diatonic_pitch_name
"c''"

Returns string.

NumberedPitch.diatonic_pitch_number

Diatonic pitch-class number corresponding to numbered pitch.

>>> pitchtools.NumberedPitch(13).diatonic_pitch_number
7

Returns integer.

(Pitch).hertz

Gets hertz value of pitch.

>>> pitchtools.NamedPitch("a'").hertz
440.0
>>> pitchtools.NamedPitch("c'").hertz
261.6255653005986
>>> pitchtools.NamedPitch("c''").hertz
523.2511306011972

Returns float.

NumberedPitch.named_pitch

Named pitch corresponding to numbered pitch.

>>> pitchtools.NumberedPitch(13).named_pitch
NamedPitch("cs''")

Returns named pitch.

NumberedPitch.named_pitch_class

Named pitch-class corresponding to numbered pitch.

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

Returns named pitch-class.

NumberedPitch.numbered_pitch

Numbered pitch.

>>> pitchtools.NumberedPitch(13).numbered_pitch
NumberedPitch(13)

Returns new numbered pitch.

NumberedPitch.numbered_pitch_class

Numbered pitch-class corresponding to numbered pitch.

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

Returns numbered pitch-class.

NumberedPitch.octave

Octave of numbered pitch.

>>> pitchtools.NumberedPitch(13).octave
Octave(5)

Returns octave.

NumberedPitch.octave_number

Octave number of numbered pitch.

>>> pitchtools.NumberedPitch(13).octave_number
5

Returns integer.

NumberedPitch.pitch_class_name

Pitch-class name of numbered pitch.

>>> pitchtools.NumberedPitch(13).pitch_class_name
'cs'

Returns string.

NumberedPitch.pitch_class_number

Pitch-class number of numbered pitch.

>>> pitchtools.NumberedPitch(13).pitch_class_number
1

Returns integer or float.

NumberedPitch.pitch_class_octave_label

Pitch-class / octave label of numbered pitch.

>>> pitchtools.NumberedPitch(13).pitch_class_octave_label
'C#5'

Returns string.

NumberedPitch.pitch_name

Pitch name corresponding to numbered pitch.

>>> pitchtools.NumberedPitch(13).pitch_name
"cs''"

Returns string.

NumberedPitch.pitch_number

Pitch number of numbered pitch.

>>> pitchtools.NumberedPitch(13).pitch_number
13

Returns number.

Methods

NumberedPitch.apply_accidental(accidental=None)

Applies accidental to numbered pitch.

>>> pitchtools.NumberedPitch(13).apply_accidental('flat')
NumberedPitch(12)

Returns new numbered pitch.

NumberedPitch.interpolate(stop_pitch, fraction)

Interpolates between this pitch and stop_pitch by fraction amount.

Example 1. Interpolates up from C4 to C5:

>>> start_pitch = pitchtools.NumberedPitch(0)
>>> stop_pitch = pitchtools.NumberedPitch(12)
>>> start_pitch.interpolate(stop_pitch, Fraction(0))
NumberedPitch(0)
>>> start_pitch.interpolate(stop_pitch, Fraction(1, 4))
NumberedPitch(3)
>>> start_pitch.interpolate(stop_pitch, Fraction(1, 2))
NumberedPitch(6)
>>> start_pitch.interpolate(stop_pitch, Fraction(3, 4))
NumberedPitch(9)
>>> start_pitch.interpolate(stop_pitch, Fraction(1))
NumberedPitch(12)

Example 2. Interpolates down from C5 to C4:

>>> start_pitch = pitchtools.NumberedPitch(12)
>>> stop_pitch = pitchtools.NumberedPitch(0)
>>> start_pitch.interpolate(stop_pitch, Fraction(0))
NumberedPitch(12)
>>> start_pitch.interpolate(stop_pitch, Fraction(1, 4))
NumberedPitch(9)
>>> start_pitch.interpolate(stop_pitch, Fraction(1, 2))
NumberedPitch(6)
>>> start_pitch.interpolate(stop_pitch, Fraction(3, 4))
NumberedPitch(3)
>>> start_pitch.interpolate(stop_pitch, Fraction(1))
NumberedPitch(0)

Returns new pitch.

NumberedPitch.invert(axis=None)

Inverts numberd pitch around axis.

Example 1. Inverts pitch-class about pitch-class 0 explicitly:

>>> pitchtools.NumberedPitch(2).invert(0)
NumberedPitch(-2)
>>> pitchtools.NumberedPitch(-2).invert(0)
NumberedPitch(2)

Default behavior.

Example 2. Inverts pitch-class about pitch-class 0 implicitly:

>>> pitchtools.NumberedPitch(2).invert()
NumberedPitch(-2)
>>> pitchtools.NumberedPitch(-2).invert()
NumberedPitch(2)

Default behavior.

Example 3. Inverts pitch-class about pitch-class -3:

>>> pitchtools.NumberedPitch(2).invert(-3)
NumberedPitch(-8)

Returns new numbered pitch.

NumberedPitch.multiply(n=1)

Multiplies pitch-class of numbered pitch by n and maintains octave.

>>> pitchtools.NumberedPitch(14).multiply(3)
NumberedPitch(18)

Returns new numbered pitch.

NumberedPitch.transpose(n=0)

Tranposes numbered pitch by n semitones.

>>> pitchtools.NumberedPitch(13).transpose(1)
NumberedPitch(14)

Returns new numbered pitch.

Class & static methods

(Pitch).from_hertz(class_, hertz)

Creates pitch from hertz.

>>> pitchtools.NamedPitch.from_hertz(440)
NamedPitch("a'")
>>> pitchtools.NumberedPitch.from_hertz(440)
NumberedPitch(9)
>>> pitchtools.NamedPitch.from_hertz(519)
NamedPitch("c'")

Returns new pitch.

(Pitch).is_diatonic_pitch_name(expr)

Is true when expr is a diatonic pitch name. Otherwise false.

>>> pitchtools.Pitch.is_diatonic_pitch_name("c''")
True

The regex (^[a-g,A-G])(,+|'+|)$ underlies this predicate.

Returns true or false.

(Pitch).is_diatonic_pitch_number(expr)

Is true when expr is a diatonic pitch number. Otherwise false.

>>> pitchtools.Pitch.is_diatonic_pitch_number(7)
True

The diatonic pitch numbers are equal to the set of integers.

Returns true or false.

(Pitch).is_pitch_carrier(expr)

Is true when expr is an Abjad pitch, note, note-head of chord instance. Otherwise false.

>>> note = Note("c'4")
>>> pitchtools.Pitch.is_pitch_carrier(note)
True

Returns true or false.

(Pitch).is_pitch_class_octave_number_string(expr)

Is true when expr is a pitch-class / octave number string. Otherwise false:

>>> pitchtools.Pitch.is_pitch_class_octave_number_string('C#2')
True

Quartertone accidentals are supported.

The regex ^([A-G])([#]{1,2}|[b]{1,2}|[#]?[+]|[b]?[~]|)([-]?[0-9]+)$ underlies this predicate.

Returns true or false.

(Pitch).is_pitch_name(expr)

True expr is a pitch name. Otherwise false.

>>> pitchtools.Pitch.is_pitch_name('c,')
True

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

Returns true or false.

(Pitch).is_pitch_number(expr)

Is true when expr is a pitch number. Otherwise false.

>>> pitchtools.Pitch.is_pitch_number(13)
True

The pitch numbers are equal to the set of all integers in union with the set of all integers plus of minus 0.5.

Returns true or false.

Special methods

NumberedPitch.__add__(arg)

Adds arg to numberd pitch.

Returns new numbered pitch.

(AbjadValueObject).__copy__(*args)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(expr)

Is true when all initialization values of Abjad value object equal the initialization values of expr.

Returns true or false.

NumberedPitch.__float__()

Changes numbered pitch to float.

Returns float.

(Pitch).__format__(format_specification='')

Formats pitch.

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

Returns string.

NumberedPitch.__ge__(other, NotImplemented=NotImplemented)

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

NumberedPitch.__gt__(other, NotImplemented=NotImplemented)

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

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

(Pitch).__illustrate__()

Illustrates pitch.

Returns LilyPond file.

NumberedPitch.__int__()

Changes numbered pitch to integer.

Returns integer.

NumberedPitch.__le__(other, NotImplemented=NotImplemented)

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

NumberedPitch.__lt__(arg)

Is true when arg can be coerced to a numbered pitch and when this numbered pitch is less than arg. Otherwise false.

Returns true or false.

(AbjadObject).__ne__(expr)

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

Returns true or false.

NumberedPitch.__neg__()

Negates numbered pitch.

Returns new numbered pitch.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NumberedPitch.__str__()

String representation of numbered pitch.

Returns string.

NumberedPitch.__sub__(arg)

Subtracts arg from numbered pitch.

Returns numbered interval.