NamedInterval

class pitchtools.NamedInterval(name='P1')

Named interval.

>>> import abjad

Initializes ascending major ninth from string:

>>> abjad.NamedInterval('+M9')
NamedInterval('+M9')

Initializes descending major third from number of semitones:

>>> abjad.NamedInterval(-4)
NamedInterval('-M3')

Initializes from other named interval:

>>> abjad.NamedInterval(abjad.NamedInterval(-4))
NamedInterval('-M3')

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.NamedInterval.NamedInterval" [color=black, fontcolor=white, group=2, label=<<B>NamedInterval</B>>, shape=box, style="filled, rounded"]; "abjad.tools.pitchtools.Interval.Interval" -> "abjad.tools.pitchtools.NamedInterval.NamedInterval"; } 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 named interval.
direction_string Gets direction string of named interval.
from_pitch_carriers(pitch_carrier_1, …) Makes named interval calculated from pitch_carrier_1 to pitch_carrier_2.
from_quality_and_number(quality, number) Makes named interval from quality and number.
interval_class Gets interval class of named interval.
interval_string Gets interval string of named interval.
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.
name Gets name of named interval.
named_interval_class DEPRECATED.
number Gets number of named interval.
octaves Gets octaves of named interval.
quality_string Gets quality string of named interval.
semitones Gets semitones of named interval.
staff_spaces Gets staff spaces of named interval.
transpose(pitch_carrier) Transposes pitch_carrier by named interval.
__abs__() Gets absolute value of named interval.
__add__(argument) Adds argument to named interval.
__copy__(*arguments) Copies named interval.
__eq__(argument) Is true when named interval equal argument.
__float__() Coerce to float.
__format__([format_specification]) Formats Abjad object.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes named interval.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(argument) Is true when argument is a named interval with a number greater than that of this named interval.
__mul__(argument) Multiplies named interval by argument.
__ne__(argument) Is true when Abjad object does not equal argument.
__neg__() Negates named interval.
__radd__(argument) Adds named interval to argument.
__repr__() Gets interpreter representation of Abjad object.
__rmul__(argument) Multiplies argument by named interval.
__str__() Gets string representation of named interval.
__sub__(argument) Subtracts argument from named interval.

Read-only properties

(Interval).cents

Gets cents of interval.

Returns nonnegative number.

NamedInterval.direction_number

Gets direction number of named interval.

>>> abjad.NamedInterval('+M9').direction_number
1

Returns -1, 0 or 1.

NamedInterval.direction_string

Gets direction string of named interval.

>>> abjad.NamedInterval('+M9').direction_string
'ascending'
>>> abjad.NamedInterval('-M9').direction_string
'descending'
>>> abjad.NamedInterval('P1').direction_string is None
True

Returns 'ascending', 'descending' or none.

NamedInterval.interval_class

Gets interval class of named interval.

>>> abjad.NamedInterval('+M9').interval_class
2

Returns nonnegative integer.

NamedInterval.interval_string

Gets interval string of named interval.

>>> abjad.NamedInterval('+M9').interval_string
'ninth'

Returns string.

NamedInterval.name

Gets name of named interval.

>>> abjad.NamedInterval('+M9').name
'+M9'

Returns string.

NamedInterval.named_interval_class

DEPRECATED.

Gets named interval class of named interval.

>>> abjad.NamedInterval('+M9').named_interval_class
NamedIntervalClass('+M2')
>>> abjad.NamedInterval('-M9').named_interval_class
NamedIntervalClass('-M2')
>>> abjad.NamedInterval('P1').named_interval_class
NamedIntervalClass('P1')
>>> abjad.NamedInterval('+P8').named_interval_class
NamedIntervalClass('+P8')

Returns named inversion-equivalent interval-class.

NamedInterval.number

Gets number of named interval.

>>> abjad.NamedInterval('+M9').number
9

Returns nonnegative number.

NamedInterval.octaves

Gets octaves of named interval.

::
>>> abjad.NamedInterval('+M9').octaves
1

Returns nonnegative number.

NamedInterval.quality_string

Gets quality string of named interval.

>>> abjad.NamedInterval('+M9').quality_string
'major'
>>> abjad.NamedInterval('+m9').quality_string
'minor'
>>> abjad.NamedInterval('+P8').quality_string
'perfect'
>>> abjad.NamedInterval('+aug4').quality_string
'augmented'

Returns string.

NamedInterval.semitones

Gets semitones of named interval.

>>> abjad.NamedInterval('+M9').semitones
14
>>> abjad.NamedInterval('-M9').semitones
-14
>>> abjad.NamedInterval('P1').semitones
0
>>> abjad.NamedInterval('+P8').semitones
12
>>> abjad.NamedInterval('-P8').semitones
-12

Returns number.

NamedInterval.staff_spaces

Gets staff spaces of named interval.

>>> abjad.NamedInterval('+M9').staff_spaces
8
>>> abjad.NamedInterval('-M9').staff_spaces
-8
>>> abjad.NamedInterval('P1').staff_spaces
0
>>> abjad.NamedInterval('+P8').staff_spaces
7
>>> abjad.NamedInterval('-P8').staff_spaces
-7

Returns nonnegative integer.

Methods

NamedInterval.transpose(pitch_carrier)

Transposes pitch_carrier by named interval.

Transposes chord:

>>> chord = abjad.Chord("<c' e' g'>4")
>>> interval = abjad.NamedInterval('+m2')
>>> interval.transpose(chord)
Chord("<df' f' af'>4")

Returns new (copied) object of pitch_carrier type.

Class & static methods

classmethod NamedInterval.from_pitch_carriers(pitch_carrier_1, pitch_carrier_2)

Makes named interval calculated from pitch_carrier_1 to pitch_carrier_2.

>>> abjad.NamedInterval.from_pitch_carriers(
...     abjad.NamedPitch(-2),
...     abjad.NamedPitch(12),
...     )
NamedInterval('+M9')
..  todo:: Improve this behavior.

>>> abjad.NamedInterval.from_pitch_carriers(
...     abjad.NamedPitch("cs'"),
...     abjad.NamedPitch("cf'"),
...     )
NamedInterval('-M2')

Returns named interval.

classmethod NamedInterval.from_quality_and_number(quality, number)

Makes named interval from quality and number.

>>> abjad.NamedInterval.from_quality_and_number(
...     'major',
...     -3,
...     )
NamedInterval('-M3')

Returns newly constructed named 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

NamedInterval.__abs__()

Gets absolute value of named interval.

>>> abs(abjad.NamedInterval('+M9'))
NamedInterval('+M9')
>>> abs(abjad.NamedInterval('-M9'))
NamedInterval('+M9')

Returns named interval.

NamedInterval.__add__(argument)

Adds argument to named interval.

>>> abjad.NamedInterval('M9') + abjad.NamedInterval('M2')
NamedInterval('+M10')

Returns new named interval.

NamedInterval.__copy__(*arguments)

Copies named interval.

>>> import copy
>>> copy.copy(abjad.NamedInterval('+M9'))
NamedInterval('+M9')

Returns new named interval.

NamedInterval.__eq__(argument)

Is true when named interval equal argument. Otherwise false.

>>> interval_1 = abjad.NamedInterval('m2')
>>> interval_2 = abjad.NamedInterval('m2')
>>> interval_3 = abjad.NamedInterval('m9')
>>> 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
(Interval).__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).

NamedInterval.__hash__()

Hashes named interval.

Returns number.

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

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

NamedInterval.__lt__(argument)

Is true when argument is a named interval with a number greater than that of this named interval.

>>> abjad.NamedInterval('+M9') < abjad.NamedInterval('+M10')
True

Also true when argument is a named interval with a number equal to this named interval and with semitones greater than this named interval:

>>> abjad.NamedInterval('+m9') < abjad.NamedInterval('+M9')
True

Otherwise false:

>>> abjad.NamedInterval('+M9') < abjad.NamedInterval('+M2')
False

Returns true or false.

NamedInterval.__mul__(argument)

Multiplies named interval by argument.

>>> 3 * abjad.NamedInterval('+M9')
NamedInterval('+aug25')

Returns new named interval.

(AbjadObject).__ne__(argument)

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

Returns true or false.

NamedInterval.__neg__()

Negates named interval.

>>> -abjad.NamedInterval('+M9')
NamedInterval('-M9')
>>> -abjad.NamedInterval('-M9')
NamedInterval('+M9')

Returns new named interval.

NamedInterval.__radd__(argument)

Adds named interval to argument.

>>> abjad.NamedInterval('M9') + abjad.NamedInterval('M2')
NamedInterval('+M10')

Returns new named interval.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NamedInterval.__rmul__(argument)

Multiplies argument by named interval.

>>> abjad.NamedInterval('+M9') * 3
NamedInterval('+aug25')

Returns new named interval.

NamedInterval.__str__()

Gets string representation of named interval.

>>> str(abjad.NamedInterval('+M9'))
'+M9'

Returns string.

NamedInterval.__sub__(argument)

Subtracts argument from named interval.

>>> abjad.NamedInterval('+M9') - abjad.NamedInterval('+M2')
NamedInterval('+P8')
>>> abjad.NamedInterval('+M2') - abjad.NamedInterval('+M9')
NamedInterval('-P8')

Returns new named interval.