NumberedPitch

class pitchtools.NumberedPitch(number=0, arrow=None)

Numbered pitch.

>>> import abjad

Initializes from number:

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

Initializes from other numbered pitch

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

Initializes from pitch-class / octave pair:

>>> numbered_pitch = abjad.NumberedPitch((1, 5))
>>> 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 Gets accidental of numbered pitch.
arrow Gets arrow of numbered pitch.
from_hertz(hertz) Makes numbered pitch from hertz.
from_pitch_carrier(pitch_carrier) Makes numbered pitch from pitch_carrier.
get_name([locale]) Gets name of numbered pitch name according to locale.
hertz Gets frequency of numbered pitch in Hertz.
interpolate(stop_pitch, fraction) Interpolates between numbered pitch and stop_pitch by fraction.
invert([axis]) Inverts numbered pitch around axis.
multiply([n]) Multiplies numbered pitch by index n.
name Gets name of numbered pitch.
number Gets number of numbered pitch.
octave Gets octave of numbered pitch.
pitch_class Gets pitch-class of numbered pitch.
transpose([n]) Tranposes numbered pitch by n semitones.
__add__(argument) Adds argument to numbered pitch.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when all initialization values of Abjad value object equal the initialization values of argument.
__float__() Coerce 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.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(argument) Is true when argument can be coerced to a numbered pitch and when this numbered pitch is less than argument.
__ne__(argument) Is true when Abjad object does not equal argument.
__neg__() Negates numbered pitch.
__radd__(argument) Adds numbered pitch to argument.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of numbered pitch.
__sub__(argument) Subtracts argument from numbered pitch.

Read-only properties

NumberedPitch.accidental

Gets accidental of numbered pitch.

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

Returns accidental.

NumberedPitch.arrow

Gets arrow of numbered pitch.

Gets no arrow:

>>> abjad.NumberedPitch(13).arrow is None
True

Gets up-arrow:

>>> abjad.NumberedPitch(13, arrow=Up).arrow
Up

Gets down-arrow:

>>> abjad.NumberedPitch(13, arrow=Down).arrow
Down

Returns up, down or none.

NumberedPitch.hertz

Gets frequency of numbered pitch in Hertz.

>>> abjad.NumberedPitch(9).hertz
440.0
>>> abjad.NumberedPitch(0).hertz
261.6255653005986
>>> abjad.NumberedPitch(12).hertz
523.2511306011972

Returns float.

NumberedPitch.name

Gets name of numbered pitch.

>>> abjad.NumberedPitch(13).name
"cs''"

Returns string

NumberedPitch.number

Gets number of numbered pitch.

>>> abjad.NumberedPitch(13).number
13

Returns number.

NumberedPitch.octave

Gets octave of numbered pitch.

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

Returns octave.

NumberedPitch.pitch_class

Gets pitch-class of numbered pitch.

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

Returns numbered pitch-class.

Methods

NumberedPitch.get_name(locale=None)

Gets name of numbered pitch name according to locale.

>>> abjad.NumberedPitch(13).get_name()
"cs''"
>>> abjad.NumberedPitch(13).get_name(locale='us')
'C#5'

Set locale to ‘us’ or none.

Returns string.

NumberedPitch.interpolate(stop_pitch, fraction)

Interpolates between numbered pitch and stop_pitch by fraction.

Interpolates from C4 to C5:

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

Interpolates from C5 to C4:

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

Returns new numbered pitch.

NumberedPitch.invert(axis=None)

Inverts numbered pitch around axis.

Inverts pitch-class about pitch-class 0 explicitly:

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

Inverts pitch-class about pitch-class 0 implicitly:

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

Inverts pitch-class about pitch-class -3:

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

Returns new numbered pitch.

NumberedPitch.multiply(n=1)

Multiplies numbered pitch by index n.

>>> abjad.NumberedPitch(14).multiply(3)
NumberedPitch(42)

Returns new numbered pitch.

NumberedPitch.transpose(n=0)

Tranposes numbered pitch by n semitones.

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

Returns new numbered pitch.

Class & static methods

classmethod NumberedPitch.from_hertz(hertz)

Makes numbered pitch from hertz.

>>> abjad.NumberedPitch.from_hertz(440)
NumberedPitch(9)
>>> abjad.NumberedPitch.from_hertz(519)
NumberedPitch(0)

Returns newly constructed numbered pitch.

classmethod NumberedPitch.from_pitch_carrier(pitch_carrier)

Makes numbered pitch from pitch_carrier.

Makes numbered pitch from named pitch:

>>> pitch = abjad.NamedPitch(('df', 5))
>>> abjad.NumberedPitch.from_pitch_carrier(pitch)
NumberedPitch(13)

Makes numbered pitch from note:

>>> note = abjad.Note("df''4")
>>> abjad.NumberedPitch.from_pitch_carrier(note)
NumberedPitch(13)

Makes numbered pitch from note-head:

>>> note = abjad.Note("df''4")
>>> abjad.NumberedPitch.from_pitch_carrier(note.note_head)
NumberedPitch(13)

Makes numbered pitch from chord:

>>> chord = abjad.Chord("<df''>4")
>>> abjad.NumberedPitch.from_pitch_carrier(chord)
NumberedPitch(13)

Makes numbered pitch from integer:

>>> abjad.NumberedPitch.from_pitch_carrier(13)
NumberedPitch(13)

Makes numbered pitch from numbered pitch-class:

>>> pitch_class = abjad.NumberedPitchClass(13)
>>> abjad.NumberedPitch.from_pitch_carrier(pitch_class)
NumberedPitch(1)

Raises value error when pitch_carrier carries no pitch.

Raises value error when pitch_carrier carries more than one pitch.

Returns new numbered pitch.

Special methods

NumberedPitch.__add__(argument)

Adds argument to numbered pitch.

>>> abjad.NumberedPitch(12) + abjad.NumberedPitch(13)
NumberedPitch(25)
>>> abjad.NumberedPitch(13) + abjad.NumberedPitch(12)
NumberedPitch(25)

Returns new numbered pitch.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

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

Returns true or false.

(Pitch).__float__()

Coerce to float.

Returns float.

(Pitch).__format__(format_specification='')

Formats pitch.

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

Returns string.

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

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

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

(Pitch).__le__(other, NotImplemented=NotImplemented)

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

NumberedPitch.__lt__(argument)

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

>>> pitch_1 = abjad.NumberedPitch(12)
>>> pitch_2 = abjad.NumberedPitch(12)
>>> pitch_3 = abjad.NumberedPitch(13)
>>> pitch_1 < pitch_1
False
>>> pitch_1 < pitch_2
False
>>> pitch_1 < pitch_3
True
>>> pitch_2 < pitch_1
False
>>> pitch_2 < pitch_2
False
>>> pitch_2 < pitch_3
True
>>> pitch_3 < pitch_1
False
>>> pitch_3 < pitch_2
False
>>> pitch_3 < pitch_3
False

Returns true or false.

(AbjadObject).__ne__(argument)

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

Returns true or false.

NumberedPitch.__neg__()

Negates numbered pitch.

>>> -abjad.NumberedPitch(13.5)
NumberedPitch(-13.5)
>>> -abjad.NumberedPitch(-13.5)
NumberedPitch(13.5)

Returns new numbered pitch.

NumberedPitch.__radd__(argument)

Adds numbered pitch to argument.

>>> pitch = abjad.NumberedPitch(13)
>>> abjad.NumberedPitch(12).__radd__(pitch)
NumberedPitch(25)
>>> pitch = abjad.NumberedPitch(12)
>>> abjad.NumberedPitch(13).__radd__(pitch)
NumberedPitch(25)

Returns new numbered pitch.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NumberedPitch.__str__()

Gets string representation of numbered pitch.

Returns string.

NumberedPitch.__sub__(argument)

Subtracts argument from numbered pitch.

>>> abjad.NumberedPitch(12) - abjad.NumberedPitch(12)
NumberedInterval(0)
>>> abjad.NumberedPitch(12) - abjad.NumberedPitch(13)
NumberedInterval(1)
>>> abjad.NumberedPitch(13) - abjad.NumberedPitch(12)
NumberedInterval(-1)

Returns numbered interval.