PitchRange

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

Pitch range.

Example 1. Pitches from C3 to C7, inclusive:

>>> pitch_range = pitchtools.PitchRange('[C3, C7]')
>>> print(format(pitch_range))
pitchtools.PitchRange(
    range_string='[C3, C7]',
    )
>>> show(pitch_range) 

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

Pitch ranges implement equality testing against other pitch ranges.

Pitch ranges test less than, greater than, less-equal and greater-equal against pitches.

Pitch ranges do not sort relative to other pitch ranges.

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

Bases

Attribute summary

from_pitches(start_pitch, stop_pitch[, ...]) Initializes pitch range from numbers.
is_range_string(class_, expr) Is true when expr is a symbolic pitch range string.
list_octave_transpositions(pitch_carrier) Lists octave transpositions of pitch_carrier in pitch range.
one_line_named_pitch_repr One-line named pitch representation of pitch range.
one_line_numbered_pitch_repr One-line numbered pitch representation of 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(pitch_class) Voices pitch_class in this pitch-range.
__contains__(arg) Is true when pitch range contains arg.
__copy__(\*args) Copies Abjad value object.
__eq__(expr) Is true when expr is a pitch range with start and stop equal to those of this pitch range.
__format__([format_specification]) Formats pitch range.
__ge__(arg) Is true when start pitch of pitch range is greater than or equal to arg.
__gt__(arg) Is true when start pitch of pitch range is greater than arg.
__hash__() Hashes pitch range.
__illustrate__() Illustrates pitch range.
__le__(arg) Is true when stop pitch of pitch-range is less than or equal to arg.
__lt__(arg) Is true when stop pitch of pitch-range is less than arg.
__ne__(arg) Is true when pitch range does not equal arg.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

PitchRange.one_line_named_pitch_repr

One-line named pitch representation of pitch range.

>>> pitch_range = pitchtools.PitchRange('[C3, C7]')
>>> pitch_range.one_line_named_pitch_repr
'[C3, C7]'

Returns string.

PitchRange.one_line_numbered_pitch_repr

One-line numbered pitch representation of pitch range.

>>> pitch_range.one_line_numbered_pitch_repr
'[-12, 36]'

Returns string.

PitchRange.range_string

Gets range string of pitch range.

>>> pitch_range.range_string
'[C3, C7]'

Aliased to one_line_named_pitch_repr.

Returns string.

PitchRange.start_pitch

Start pitch of pitch range.

>>> pitch_range.start_pitch
NamedPitch('c')

Returns pitch.

PitchRange.start_pitch_is_included_in_range

Is true when start pitch is included in range. Otherwise false:

>>> pitch_range.start_pitch_is_included_in_range
True

Returns true or false.

PitchRange.stop_pitch

Stop pitch of pitch range.

>>> pitch_range.stop_pitch
NamedPitch("c''''")

Returns pitch.

PitchRange.stop_pitch_is_included_in_range

Is true when stop pitch is included in range. Otherwise false:

>>> pitch_range.stop_pitch_is_included_in_range
True

Returns true or false.

Methods

PitchRange.list_octave_transpositions(pitch_carrier)

Lists octave transpositions of pitch_carrier in pitch range.

>>> chord = Chord("<c' d' e'>4")
>>> pitch_range = pitchtools.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.

PitchRange.voice_pitch_class(pitch_class)

Voices pitch_class in this pitch-range.

>>> a_pitch_range = pitchtools.PitchRange('[C4, C6]')
>>> a_pitch_range.voice_pitch_class('c')
(NamedPitch("c'"), NamedPitch("c''"), NamedPitch("c'''"))
>>> a_pitch_range.voice_pitch_class('b')
(NamedPitch("b'"), NamedPitch("b''"))
>>> a_pitch_range = pitchtools.PitchRange('[C4, A4)')
>>> a_pitch_range.voice_pitch_class('b')
()

Returns tuple of zero or more named pitches.

Class & static methods

static PitchRange.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.

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

Returns pitch range.

classmethod PitchRange.is_range_string(class_, expr)

Is true when expr is a symbolic pitch range string. Otherwise false:

>>> pitchtools.PitchRange.is_range_string('[A0, C8]')
True

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.

Special methods

PitchRange.__contains__(arg)

Is true when pitch range contains arg. Otherwise false.

Returns true or false.

(AbjadValueObject).__copy__(*args)

Copies Abjad value object.

Returns new Abjad value object.

PitchRange.__eq__(expr)

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

Returns true or false.

PitchRange.__format__(format_specification='')

Formats pitch range.

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

Returns string.

PitchRange.__ge__(arg)

Is true when start pitch of pitch range is greater than or equal to arg. Otherwise false.

Returns true or false.

PitchRange.__gt__(arg)

Is true when start pitch of pitch range is greater than arg. Otherwise false.

Returns true or false.

PitchRange.__hash__()

Hashes pitch range.

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

Returns integer.

PitchRange.__illustrate__()

Illustrates pitch range.

>>> show(pitch_range) 

Returns LilyPond file.

PitchRange.__le__(arg)

Is true when stop pitch of pitch-range is less than or equal to arg. Otherwise false.

Returns true or false.

PitchRange.__lt__(arg)

Is true when stop pitch of pitch-range is less than arg. Otherwise false.

Returns true or false.

PitchRange.__ne__(arg)

Is true when pitch range does not equal arg. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.