PitchRange

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.pitch" { graph [label="abjad.pitch"]; node [color=1]; "abjad.pitch.PitchRange.PitchRange" [URL="../api/abjad/pitch/PitchRange.html#abjad.pitch.PitchRange.PitchRange", color=black, fontcolor=white, label="Pitch\nRange", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/pitch/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/pitch/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.pitch.PitchRange.PitchRange"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.pitch.PitchRange.PitchRange(range_string='[A0, C8]')

Pitch range.

Pitches from C3 to C7, inclusive:

>>> pitch_range = abjad.PitchRange('[C3, C7]')
>>> abjad.show(pitch_range) 

Initalizes from pitch numbers, pitch names, pitch instances, one-line reprs or other pitch range objects.

Pitch ranges do not sort relative to other pitch ranges.


Attributes Summary

__contains__ Is true when pitch range contains argument.
__eq__ Is true when argument is a pitch range with start and stop equal to those of this pitch range.
__format__ Formats pitch range.
__ge__ Return a >= b.
__gt__ Return a > b.
__hash__ Hashes pitch range.
__illustrate__ Illustrates pitch range.
__le__ Return a <= b.
__lt__ Is true when start pitch of this pitch-range is less than start pitch of argument pitch range.
from_pitches Initializes pitch range from numbers.
is_range_string Is true when argument is a pitch range string.
list_octave_transpositions Lists octave transpositions of pitch_carrier in pitch range.
range_string Gets range string of pitch range.
start_pitch Start pitch of pitch range.
start_pitch_is_included_in_range Is true when start pitch is included in range.
stop_pitch Stop pitch of pitch range.
stop_pitch_is_included_in_range Is true when stop pitch is included in range.
voice_pitch_class Voices pitch_class:

Special methods

__contains__(argument)

Is true when pitch range contains argument.

Closed / closed range:

>>> range_ = abjad.PitchRange('[A0, C8]')
>>> -99 in range_
False
>>> -39 in range_
True
>>> 0 in range_
True
>>> 48 in range_
True
>>> 99 in range_
False

Closed / open range:

>>> range_ = abjad.PitchRange('[A0, C8)')
>>> -99 in range_
False
>>> -39 in range_
True
>>> 0 in range_
True
>>> 48 in range_
False
>>> 99 in range_
False

Closed / infinite range:

>>> range_ = abjad.PitchRange('[-39, +inf]')
>>> -99 in range_
False
>>> -39 in range_
True
>>> 0 in range_
True
>>> 48 in range_
True
>>> 99 in range_
True

Open / closed range:

>>> range_ = abjad.PitchRange('(A0, C8]')
>>> -99 in range_
False
>>> -39 in range_
False
>>> 0 in range_
True
>>> 48 in range_
True
>>> 99 in range_
False

Open / open range:

>>> range_ = abjad.PitchRange('(A0, C8)')
>>> -99 in range_
False
>>> -39 in range_
False
>>> 0 in range_
True
>>> 48 in range_
False
>>> 99 in range_
False

Infinite / closed range:

>>> range_ = abjad.PitchRange('[-inf, C8]')
>>> -99 in range_
True
>>> -39 in range_
True
>>> 0 in range_
True
>>> 48 in range_
True
>>> 99 in range_
False

Infinite / open range:

>>> range_ = abjad.PitchRange('[-inf, C8)')
>>> -99 in range_
True
>>> -39 in range_
True
>>> 0 in range_
True
>>> 48 in range_
False
>>> 99 in range_
False

Infinite / infinite range:

>>> range_ = abjad.PitchRange('[-inf, +inf]')
>>> -99 in range_
True
>>> -39 in range_
True
>>> 0 in range_
True
>>> 48 in range_
True
>>> 99 in range_
True

Returns true or false.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument is a pitch range with start and stop equal to those of this pitch range.

>>> range_1 = abjad.PitchRange.from_pitches(-39, 0)
>>> range_2 = abjad.PitchRange.from_pitches(-39, 0)
>>> range_3 = abjad.PitchRange.from_pitches(-39, 48)
>>> range_1 == range_1
True
>>> range_1 == range_2
True
>>> range_1 == range_3
False
>>> range_2 == range_1
True
>>> range_2 == range_2
True
>>> range_2 == range_3
False
>>> range_3 == range_1
False
>>> range_3 == range_2
False
>>> range_3 == range_3
True

Returns true or false.

__format__(format_specification='')

Formats pitch range.

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

Returns string.

__ge__(other, NotImplemented=NotImplemented)

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

__gt__(other, NotImplemented=NotImplemented)

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

__hash__()

Hashes pitch range.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

__illustrate__()

Illustrates pitch range.

>>> pitch_range = abjad.PitchRange('[C3, C7]')
>>> abjad.show(pitch_range) 

Returns LilyPond file.

__le__(other, NotImplemented=NotImplemented)

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

__lt__(argument)

Is true when start pitch of this pitch-range is less than start pitch of argument pitch range.

>>> range_1 = abjad.PitchRange.from_pitches(-39, 0)
>>> range_2 = abjad.PitchRange.from_pitches(-39, 0)
>>> range_3 = abjad.PitchRange.from_pitches(-39, 48)
>>> range_1 < range_1
False
>>> range_1 < range_2
False
>>> range_1 < range_3
True
>>> range_2 < range_1
False
>>> range_2 < range_2
False
>>> range_2 < range_3
True
>>> range_3 < range_1
False
>>> range_3 < range_2
False
>>> range_3 < range_3
False

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Methods

list_octave_transpositions(pitch_carrier)

Lists octave transpositions of pitch_carrier in pitch range.

Lists octave transpositions of three-pitch chord:

>>> chord = abjad.Chord("<c' d' e'>4")
>>> pitch_range = abjad.PitchRange.from_pitches(0, 48)
>>> result = pitch_range.list_octave_transpositions(chord)
>>> for chord in result:
...     chord
... 
Chord("<c' d' e'>4")
Chord("<c'' d'' e''>4")
Chord("<c''' d''' e'''>4")
Chord("<c'''' d'''' e''''>4")

Returns a list of pitch_carrier objects.

voice_pitch_class(pitch_class)

Voices pitch_class:

Voices C three times:

>>> pitch_range = abjad.PitchRange('[C4, C6]')
>>> pitch_range.voice_pitch_class('c')
(NamedPitch("c'"), NamedPitch("c''"), NamedPitch("c'''"))

Voices B two times:

>>> pitch_range = abjad.PitchRange('[C4, C6]')
>>> pitch_range.voice_pitch_class('b')
(NamedPitch("b'"), NamedPitch("b''"))

Returns empty because B can not voice:

>>> pitch_range = abjad.PitchRange('[C4, A4)')
>>> pitch_range.voice_pitch_class('b')
()

Returns tuple of zero or more named pitches.


Class & static methods

static from_pitches(start_pitch, stop_pitch, start_pitch_is_included_in_range=True, stop_pitch_is_included_in_range=True)

Initializes pitch range from numbers.

>>> abjad.PitchRange.from_pitches(-18, 19)
PitchRange('[F#2, G5]')

Returns pitch range.

classmethod is_range_string(argument)

Is true when argument is a pitch range string.

>>> abjad.PitchRange.is_range_string('[A0, C8]')
True
>>> abjad.PitchRange.is_range_string('[A#0, Cb~8]')
True
>>> abjad.PitchRange.is_range_string('[A#+0, cs'')')
True
>>> abjad.PitchRange.is_range_string('(b,,,, ctqs]')
True
>>> abjad.PitchRange.is_range_string('text')
False

The regex that underlies this predicate matches against two comma-separated pitches enclosed in some combination of square brackets and round parentheses.

Returns true or false.


Read-only properties

range_string

Gets range string of pitch range.

>>> pitch_range = abjad.PitchRange('[C3, C7]')
>>> pitch_range.range_string
'[C3, C7]'

Returns string.

start_pitch

Start pitch of pitch range.

>>> pitch_range = abjad.PitchRange('[C3, C7]')
>>> pitch_range.start_pitch
NamedPitch('c')

Returns pitch.

start_pitch_is_included_in_range

Is true when start pitch is included in range.

>>> pitch_range = abjad.PitchRange('[C3, C7]')
>>> pitch_range.start_pitch_is_included_in_range
True

Returns true or false.

stop_pitch

Stop pitch of pitch range.

>>> pitch_range = abjad.PitchRange('[C3, C7]')
>>> pitch_range.stop_pitch
NamedPitch("c''''")

Returns pitch.

stop_pitch_is_included_in_range

Is true when stop pitch is included in range.

>>> pitch_range = abjad.PitchRange('[C3, C7]')
>>> pitch_range.stop_pitch_is_included_in_range
True

Returns true or false.