NumberedInterval

class pitchtools.NumberedInterval(number=0)

Numbered interval.

>>> import abjad

Initializes from number of semitones:

>>> abjad.NumberedInterval(-14)
NumberedInterval(-14)

Initializes from other numbered interval

>>> abjad.NumberedInterval(abjad.NumberedInterval(-14))
NumberedInterval(-14)

Initializes from named interval:

>>> abjad.NumberedInterval(abjad.NamedInterval('-P4'))
NumberedInterval(-5)

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

Bases

Attribute summary

cents Gets cents of interval.
direction_number Gets direction number of numbered interval.
direction_string Gets direction string of numbered interval.
from_pitch_carriers(pitch_carrier_1, …) Makes numbered interval from pitch_carrier_1 and pitch_carrier_2.
is_named_interval_abbreviation(argument) Is true when argument is a named interval abbreviation.
is_named_interval_quality_abbreviation(argument) Is true when argument is a named-interval quality abbreviation.
number Gets number of numbered interval.
numbered_interval_number DEPRECATED.
semitones Gets semitones corresponding to numbered interval.
to_named_interval(staff_positions) Changes numbered interval to named interval that encompasses staff_positions.
transpose(pitch_carrier) Transposes pitch_carrier.
__abs__() Absolute value of numbered interval.
__add__(argument) Adds argument to numbered interval.
__copy__() Copies numbered interval.
__eq__(argument) Is true when argument is a numbered interval with number equal to that of this numbered interval.
__float__() Coerce to float.
__format__([format_specification]) Formats Abjad object.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes numbered interval.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(argument) Is true when argument is a numbered interval with same direction number as this numbered interval and with number greater than that of this numbered interval.
__ne__(argument) Is true when Abjad object does not equal argument.
__neg__() Negates numbered interval.
__radd__(argument) Adds numbered interval to argument.
__repr__() Gets interpreter representation of Abjad object.
__str__() String representation of numbered interval.
__sub__(argument) Subtracts argument from numbered interval.

Read-only properties

(Interval).cents

Gets cents of interval.

Returns nonnegative number.

NumberedInterval.direction_number

Gets direction number of numbered interval.

>>> abjad.NumberedInterval(-14).direction_number
-1

Returns integer.

NumberedInterval.direction_string

Gets direction string of numbered interval.

>>> abjad.NumberedInterval(-14).direction_string
'descending'

Returns 'ascending', 'descending' or none.

NumberedInterval.number

Gets number of numbered interval.

>>> abjad.NumberedInterval(-14).number
-14
>>> abjad.NumberedInterval(-2).number
-2
>>> abjad.NumberedInterval(0).number
0

Returns number.

NumberedInterval.numbered_interval_number

DEPRECATED.

>>> abjad.NumberedInterval(-14).numbered_interval_number
-14

Returns integer or float.

NumberedInterval.semitones

Gets semitones corresponding to numbered interval.

>>> abjad.NumberedInterval(-14).semitones
-14

Returns nonnegative number.

Methods

NumberedInterval.to_named_interval(staff_positions)

Changes numbered interval to named interval that encompasses staff_positions.

>>> abjad.NumberedInterval(0).to_named_interval(0)
NamedInterval('aug0')
>>> abjad.NumberedInterval(0).to_named_interval(1)
NamedInterval('P1')
>>> abjad.NumberedInterval(0).to_named_interval(2)
NamedInterval('+dim2')
>>> abjad.NumberedInterval(1).to_named_interval(1)
NamedInterval('+aug1')
>>> abjad.NumberedInterval(1).to_named_interval(2)
NamedInterval('+m2')
>>> abjad.NumberedInterval(-1).to_named_interval(1)
NamedInterval('-aug1')
>>> abjad.NumberedInterval(-1).to_named_interval(2)
NamedInterval('-m2')
>>> abjad.NumberedInterval(2).to_named_interval(2)
NamedInterval('+M2')

Returns named interval.

NumberedInterval.transpose(pitch_carrier)

Transposes pitch_carrier.

Transposes chord:

>>> chord = abjad.Chord("<c' e' g'>4")
>>> interval = abjad.NumberedInterval(1)
>>> interval.transpose(chord)
Chord("<cs' f' af'>4")

Returns newly constructed object of pitch_carrier type.

Class & static methods

classmethod NumberedInterval.from_pitch_carriers(pitch_carrier_1, pitch_carrier_2)

Makes numbered interval from pitch_carrier_1 and pitch_carrier_2.

>>> abjad.NumberedInterval.from_pitch_carriers(
...     abjad.NamedPitch(-2),
...     abjad.NamedPitch(12),
...     )
NumberedInterval(14)
>>> abjad.NumberedInterval.from_pitch_carriers(
...     abjad.NamedPitch(12),
...     abjad.NamedPitch(12),
...     )
NumberedInterval(0)
>>> abjad.NumberedInterval.from_pitch_carriers(
...     abjad.NamedPitch(9),
...     abjad.NamedPitch(12),
...     )
NumberedInterval(3)
>>> abjad.NumberedInterval.from_pitch_carriers(
...     abjad.NamedPitch(12),
...     abjad.NamedPitch(9),
...     )
NumberedInterval(-3)
>>> abjad.NumberedInterval.from_pitch_carriers(
...     abjad.NamedPitch(12),
...     abjad.NamedPitch(-2),
...     )
NumberedInterval(-14)

Returns numbered interval.

(Interval).is_named_interval_abbreviation(argument)

Is true when argument is a named interval abbreviation. Otherwise false.

>>> abjad.Interval.is_named_interval_abbreviation('+M9')
True

The regex ^([+,-]?)(M|m|P|aug|dim)(\d+)$ underlies this predicate.

Returns true or false.

(Interval).is_named_interval_quality_abbreviation(argument)

Is true when argument is a named-interval quality abbreviation. Otherwise false.

>>> abjad.Interval.is_named_interval_quality_abbreviation('aug')
True

The regex ^M|m|P|aug|dim$ underlies this predicate.

Returns true or false.

Special methods

NumberedInterval.__abs__()

Absolute value of numbered interval.

>>> abs(abjad.NumberedInterval(-14))
NumberedInterval(14)

Returns new numbered interval.

NumberedInterval.__add__(argument)

Adds argument to numbered interval.

>>> abjad.NumberedInterval(3) + abjad.NumberedInterval(14)
NumberedInterval(17)
>>> abjad.NumberedInterval(3) + abjad.NumberedInterval(-14)
NumberedInterval(-11)

Returns new numbered interval.

NumberedInterval.__copy__()

Copies numbered interval.

>>> import copy
>>> copy.copy(abjad.NumberedInterval(-14))
NumberedInterval(-14)

Returns new numbered interval.

NumberedInterval.__eq__(argument)

Is true when argument is a numbered interval with number equal to that of this numbered interval. Otherwise false.

>>> interval_1 = abjad.NumberedInterval(12)
>>> interval_2 = abjad.NumberedInterval(12)
>>> interval_3 = abjad.NumberedInterval(13)
>>> interval_1 == interval_1
True
>>> interval_1 == interval_2
True
>>> interval_1 == interval_3
False
>>> interval_2 == interval_1
True
>>> interval_2 == interval_2
True
>>> interval_2 == interval_3
False
>>> interval_3 == interval_1
False
>>> interval_3 == interval_2
False
>>> interval_3 == interval_3
True

Returns true or false.

NumberedInterval.__float__()

Coerce to float.

Returns float.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

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

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

(Interval).__gt__(other, NotImplemented=NotImplemented)

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

NumberedInterval.__hash__()

Hashes numbered interval.

Returns integer.

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

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

NumberedInterval.__lt__(argument)

Is true when argument is a numbered interval with same direction number as this numbered interval and with number greater than that of this numbered interval. Otherwise false.

>>> interval_1 = abjad.NumberedInterval(12)
>>> interval_2 = abjad.NumberedInterval(12)
>>> interval_3 = abjad.NumberedInterval(13)
>>> interval_1 < interval_1
False
>>> interval_1 < interval_2
False
>>> interval_1 < interval_3
True
>>> interval_2 < interval_1
False
>>> interval_2 < interval_2
False
>>> interval_2 < interval_3
True
>>> interval_3 < interval_1
False
>>> interval_3 < interval_2
False
>>> interval_3 < interval_3
False

Returns true or false.

(AbjadObject).__ne__(argument)

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

Returns true or false.

NumberedInterval.__neg__()

Negates numbered interval.

>>> -abjad.NumberedInterval(-14)
NumberedInterval(14)

Returns new numbered interval.

NumberedInterval.__radd__(argument)

Adds numbered interval to argument.

>>> interval = abjad.NumberedInterval(14)
>>> abjad.NumberedInterval(3).__radd__(interval)
NumberedInterval(17)
>>> interval = abjad.NumberedInterval(-14)
>>> abjad.NumberedInterval(3).__radd__(interval)
NumberedInterval(-11)

Returns new numbered interval.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NumberedInterval.__str__()

String representation of numbered interval.

Returns string.

NumberedInterval.__sub__(argument)

Subtracts argument from numbered interval.

Returns new numbered interval.