NamedInterval

class pitchtools.NamedInterval(*arguments)

Named interval.

Initializes ascending major ninth from string:

>>> interval = NamedInterval('+M9')
>>> interval
NamedInterval('+M9')

Initializes descending major third from number of semitones:

>>> interval = NamedInterval(-4)
>>> interval
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 Cents of interval.
direction_number Direction number of named interval.
direction_string Direction string of named interval.
from_pitch_carriers(class_, pitch_carrier_1, ...) Calculate named interval from pitch_carrier_1 to
interval_class Interval class of named interval.
interval_string 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.
named_interval_class Named interval class of named interval.
number Number of named interval.
octaves Number of octaves in interval.
quality_string Quality string of named interval.
semitones Semitones of named interval.
staff_spaces Staff spaces of named interval.
transpose(pitch_carrier) Transposes pitch_carrier.
__abs__() Absolute value of named interval.
__add__(argument) Adds argument to named interval.
__copy__(*arguments) Copies named interval.
__eq__(argument) Is true when all initialization values of Abjad value object equal the initialization values of argument.
__float__() Changes number of named interval to a float.
__format__([format_specification]) Formats Abjad object.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes Abjad value object.
__int__() Returns number of 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 argument does not equal this named interval.
__neg__() Negates named interval.
__repr__() Gets interpreter representation of Abjad object.
__rmul__(argument) Multiplies argument by named interval.
__str__() String representation of named interval.
__sub__(argument) Subtracts argument from named interval.

Read-only properties

(Interval).cents

Cents of interval.

Returns nonnegative number.

NamedInterval.direction_number

Direction number of named interval.

>>> interval.direction_number
1

Returns -1, 0 or 1.

NamedInterval.direction_string

Direction string of named interval.

>>> interval.direction_string
'ascending'

Returns 'ascending', 'descending' or none.

NamedInterval.interval_class

Interval class of named interval.

>>> interval.interval_class
2

Returns nonnegative integer.

NamedInterval.interval_string

Interval string of named interval.

>>> interval.interval_string
'ninth'

Returns string.

NamedInterval.named_interval_class

Named interval class of named interval.

>>> interval.named_interval_class
NamedIntervalClass('+M2')

Returns named inversion-equivalent interval-class.

NamedInterval.number

Number of named interval.

>>> interval.number
9

Returns nonnegative number.

NamedInterval.octaves

Number of octaves in interval.

Returns nonnegative number.

NamedInterval.quality_string

Quality string of named interval.

>>> interval.quality_string
'major'

Returns string.

NamedInterval.semitones

Semitones of named interval.

>>> interval.semitones
14

Returns number.

NamedInterval.staff_spaces

Staff spaces of named interval.

>>> interval.staff_spaces
8

Returns nonnegative integer.

Methods

NamedInterval.transpose(pitch_carrier)

Transposes pitch_carrier.

Transposes chord:

>>> chord = Chord("<c' e' g'>4")
>>> interval = 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(class_, pitch_carrier_1, pitch_carrier_2)

Calculate named interval from pitch_carrier_1 to pitch_carrier_2:

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

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

Returns named interval.

(Interval).is_named_interval_abbreviation(argument)

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

>>> pitchtools.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:

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

Absolute value of named interval.

>>> interval = NamedInterval('+M9')
>>> abs(interval)
NamedInterval('+M9')

Returns named interval.

NamedInterval.__add__(argument)

Adds argument to named interval.

>>> interval + NamedInterval('M2')
NamedInterval('+M10')

Returns new named interval.

NamedInterval.__copy__(*arguments)

Copies named interval.

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

Returns new named interval.

(AbjadValueObject).__eq__(argument)

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

Returns true or false.

NamedInterval.__float__()

Changes number of named interval to a float.

>>> float(interval)
9.0

Returns float.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

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

Returns string.

NamedInterval.__ge__(other, NotImplemented=NotImplemented)

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

NamedInterval.__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.

NamedInterval.__int__()

Returns number of named interval.

>>> int(interval)
9

Returns integer.

NamedInterval.__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.

>>> interval < 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:

>>> NamedInterval('+m9') < interval
True

Otherwise false:

>>> interval < NamedInterval('+M2')
False

Returns true or false.

NamedInterval.__mul__(argument)

Multiplies named interval by argument.

>>> 3 * interval
NamedInterval('+aug25')

Returns new named interval.

NamedInterval.__ne__(argument)

Is true when argument does not equal this named interval. Otherwise false.

Returns true or false.

NamedInterval.__neg__()

Negates named interval.

>>> -interval
NamedInterval('-M9')

Returns new named interval.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NamedInterval.__rmul__(argument)

Multiplies argument by named interval.

>>> interval * 3
NamedInterval('+aug25')

Returns new named interval.

NamedInterval.__str__()

String representation of named interval.

>>> str(interval)
'+M9'

Returns string.

NamedInterval.__sub__(argument)

Subtracts argument from named interval.

>>> interval - NamedInterval('+M2')
NamedInterval('+P8')

Returns new named interval.