PitchRange

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

Pitch range.

Pitches from C3 to C7, inclusive:

>>> pitch_range = PitchRange('[C3, C7]')
>>> f(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_, argument) Is true when argument is a symbolic pitch range string.
list_octave_transpositions(pitch_carrier) 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(pitch_class) Voices pitch_class:
__contains__(argument) Is true when pitch range contains argument.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when argument is a pitch range with start and stop equal to those of this pitch range.
__format__([format_specification]) Formats pitch range.
__ge__(argument) Is true when start pitch of pitch range is greater than or equal to argument.
__gt__(argument) Is true when start pitch of pitch range is greater than argument.
__hash__() Hashes pitch range.
__illustrate__() Illustrates pitch range.
__le__(argument) Is true when stop pitch of pitch-range is less than or equal to argument.
__lt__(argument) Is true when stop pitch of pitch-range is less than argument.
__ne__(argument) Is true when pitch range does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

PitchRange.range_string

Gets range string of pitch range.

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

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.

Lists octave transpositions of three-pitch chord:

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

Voices C three times:

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

Voices B two times:

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

Returns empty because B can not voice:

>>> pitch_range = PitchRange('[C4, A4)')
>>> 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.

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

Returns pitch range.

classmethod PitchRange.is_range_string(class_, argument)

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

Returns true:

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

Returns false:

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

Special methods

PitchRange.__contains__(argument)

Is true when pitch range contains argument. Otherwise false.

Returns true or false.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

PitchRange.__eq__(argument)

Is true when argument 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__(argument)

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

Returns true or false.

PitchRange.__gt__(argument)

Is true when start pitch of pitch range is greater than argument. 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__(argument)

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

Returns true or false.

PitchRange.__lt__(argument)

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

Returns true or false.

PitchRange.__ne__(argument)

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

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.