PitchSegment

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.PitchSegment.PitchSegment" [URL="../api/abjad/pitch/PitchSegment.html#abjad.pitch.PitchSegment.PitchSegment", color=black, fontcolor=white, label="Pitch\nSegment", target=_top]; "abjad.pitch.Segment.Segment" [URL="../api/abjad/pitch/Segment.html#abjad.pitch.Segment.Segment", label=Segment, shape=oval, style=bold, target=_top]; "abjad.pitch.Segment.Segment" -> "abjad.pitch.PitchSegment.PitchSegment"; } 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]; } subgraph "cluster_abjad.utilities" { graph [label="abjad.utilities"]; node [color=3]; "abjad.utilities.TypedCollection.TypedCollection" [URL="../api/abjad/pitch/../utilities/TypedCollection.html#abjad.utilities.TypedCollection.TypedCollection", label="Typed\nCollection", shape=oval, style=bold, target=_top]; "abjad.utilities.TypedTuple.TypedTuple" [URL="../api/abjad/pitch/../utilities/TypedTuple.html#abjad.utilities.TypedTuple.TypedTuple", label="Typed\nTuple", target=_top]; "abjad.utilities.TypedCollection.TypedCollection" -> "abjad.utilities.TypedTuple.TypedTuple"; } subgraph cluster_builtins { graph [label=builtins]; node [color=4]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_collections.abc" { graph [label="collections.abc"]; node [color=5]; "collections.abc.Collection" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Collection", label=Collection, shape=oval, style=bold, target=_top]; "collections.abc.Container" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Container", label=Container, shape=oval, style=bold, target=_top]; "collections.abc.Iterable" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Iterable", label=Iterable, shape=oval, style=bold, target=_top]; "collections.abc.Reversible" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Reversible", label=Reversible, shape=oval, style=bold, target=_top]; "collections.abc.Sequence" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sequence", label=Sequence, shape=oval, style=bold, target=_top]; "collections.abc.Sized" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sized", label=Sized, shape=oval, style=bold, target=_top]; "collections.abc.Collection" -> "collections.abc.Sequence"; "collections.abc.Container" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Reversible"; "collections.abc.Reversible" -> "collections.abc.Sequence"; "collections.abc.Sized" -> "collections.abc.Collection"; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.utilities.TypedCollection.TypedCollection"; "abjad.utilities.TypedTuple.TypedTuple" -> "abjad.pitch.Segment.Segment"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.Sequence" -> "abjad.utilities.TypedTuple.TypedTuple"; }

class abjad.pitch.PitchSegment.PitchSegment(items=None, item_class=None)

Pitch segment.

Numbered pitch segment:

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment)
'<-2, -1.5, 6, 7, -1.5, 7>'
>>> abjad.show(segment) 

Named pitch segment:

>>> segment = abjad.PitchSegment("bf, aqs fs' g' bqf g'")
>>> str(segment)
"<bf, aqs fs' g' bqf g'>"
>>> abjad.show(segment) 

Built-in max() works:

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> max(segment)
NumberedPitch(7)

Built-in min() works:

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> min(segment)
NumberedPitch(-2)

Attributes Summary

__contains__ Is true when pitch segment contains argument.
__illustrate__ Illustrates pitch segment.
__repr__ Gets interpreter representation of segment.
__str__ Gets pitch segment string.
from_selection Makes pitch segment from selection.
has_duplicates Is true when segment has duplicates.
hertz Gets Hertz of pitches in segment.
inflection_point_count Gets segment inflection point count.
invert Inverts pitch segment about axis.
local_maxima Gets segment local maxima.
local_minima Gets segment local minima.
make_notes Makes first n notes in pitch segment.
multiply Multiplies pitch segment by index n.
retrograde Retrograde of pitch segment.
rotate Rotates pitch segment by index n.
to_pitch_classes Changes to pitch-classes.
to_pitches Changes to pitches.
transpose Transposes pitch segment by index n.

Special methods

(TypedTuple).__add__(argument)

Adds typed tuple to argument.

Returns new typed tuple.

__contains__(argument)

Is true when pitch segment contains argument.

Numbered pitch segment:

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.NamedPitch('fs') in segment
False
>>> 6 in segment
True
>>> abjad.NamedPitch('f') in segment
False
>>> 5 in segment
False

Returns true or false.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(TypedTuple).__getitem__(argument)

Gets item or slice identified by argument.

Returns item or new typed tuple.

(TypedTuple).__hash__()

Hashes typed tuple.

Returns integer.

__illustrate__()

Illustrates pitch segment.

>>> segment = abjad.PitchSegment("bf, aqs fs' g' bqf g'")
>>> abjad.show(segment) 

Returns LilyPond file.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(TypedTuple).__mul__(argument)

Multiplies typed tuple by argument.

Returns new typed tuple.

(TypedTuple).__radd__(argument)

Right-adds argument to typed tuple.

__repr__()

Gets interpreter representation of segment.

Returns string.

(Sequence).__reversed__()
(TypedTuple).__rmul__(argument)

Multiplies argument by typed tuple.

Returns new typed tuple.

__str__()

Gets pitch segment string.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment)
'<-2, -1.5, 6, 7, -1.5, 7>'
>>> segment = abjad.PitchSegment("bf, aqs fs' g' bqf g'")
>>> str(segment)
"<bf, aqs fs' g' bqf g'>"

Returns string.


Methods

(TypedTuple).count(item)

Counts item in collection.

Coerces item.

Returns nonnegative integer.

has_duplicates()

Is true when segment has duplicates.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.has_duplicates()
True
>>> segment = abjad.PitchSegment("c d e f g a b")
>>> segment.has_duplicates()
False

Returns true or false.

(TypedTuple).index(item)

Gets index of item in collection.

Coerces item.

Returns nonnegative integer.

invert(axis=None)

Inverts pitch segment about axis.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment = segment.invert(axis=0)
>>> str(segment)
'<2, 1.5, -6, -7, 1.5, -7>'
>>> abjad.show(segment) 

Returns new pitch segment.

make_notes(n=None, written_duration=None)

Makes first n notes in pitch segment.

Todo

Move somewhere else.

Sets n equal to n or length of segment.

Sets written_duration equal to written_duration or 1/8:

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> notes = segment.make_notes()
>>> staff = abjad.Staff(notes)
>>> abjad.show(staff) 

Allows nonassignable written_duration:

>>> notes = segment.make_notes(4, abjad.Duration(5, 16))
>>> staff = abjad.Staff(notes)
>>> time_signature = abjad.TimeSignature((5, 4))
>>> abjad.attach(time_signature, staff[0])
>>> abjad.show(staff) 

Returns list of notes.

multiply(n=1)

Multiplies pitch segment by index n.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment = segment.multiply(n=3)
>>> str(segment)
'<-6, -4.5, 18, 21, -4.5, 21>'
>>> abjad.show(segment) 

Returns new pitch segment.

retrograde()

Retrograde of pitch segment.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment = segment.retrograde()
>>> str(segment)
'<7, -1.5, 7, 6, -1.5, -2>'
>>> abjad.show(segment) 

Returns new pitch segment.

rotate(n=0, stravinsky=False)

Rotates pitch segment by index n.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment = segment.rotate(n=1)
>>> str(segment)
'<7, -2, -1.5, 6, 7, -1.5>'
>>> abjad.show(segment) 

Returns new pitch segment.

to_pitch_classes()

Changes to pitch-classes.

To numbered pitch-class segment:

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment = segment.to_pitch_classes()
>>> str(segment)
'PC<10, 10.5, 6, 7, 10.5, 7>'
>>> abjad.show(segment) 

To named pitch-class segment:

>>> segment = abjad.PitchSegment("bf, aqs fs' g' bqf g'")
>>> abjad.show(segment) 
>>> segment = segment.to_pitch_classes()
>>> str(segment)
'PC<bf aqs fs g bqf g>'
>>> abjad.show(segment) 

Returns new segment.

to_pitches()

Changes to pitches.

To numbered pitch segment:

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment = segment.to_pitches()
>>> str(segment)
'<-2, -1.5, 6, 7, -1.5, 7>'
>>> abjad.show(segment) 

To named pitch segment:

>>> segment = abjad.PitchSegment("bf, aqs fs' g' bqf g'")
>>> abjad.show(segment) 
>>> segment = segment.to_pitches()
>>> str(segment)
"<bf, aqs fs' g' bqf g'>"
>>> abjad.show(segment) 

Returns new segment.

transpose(n=0)

Transposes pitch segment by index n.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment = segment.transpose(n=11)
>>> str(segment)
'<9, 9.5, 17, 18, 9.5, 18>'
>>> abjad.show(segment) 

Returns new pitch segment.


Class & static methods

classmethod from_selection(selection, item_class=None)

Makes pitch segment from selection.

>>> staff_1 = abjad.Staff("c'4 <d' fs' a'>4 b2")
>>> staff_2 = abjad.Staff("c4. r8 g2")
>>> selection = abjad.select((staff_1, staff_2))
>>> segment = abjad.PitchSegment.from_selection(selection)
>>> str(segment)
"<c' d' fs' a' b c g>"
>>> abjad.show(segment) 

Returns pitch segment.


Read-only properties

hertz

Gets Hertz of pitches in segment.

>>> segment = abjad.PitchSegment('c e g b')
>>> segment.hertz
[130.8127826502993, 164.81377845643496, 195.99771799087463, 246.94165062806206]

Returns list.

inflection_point_count

Gets segment inflection point count.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment.inflection_point_count
2

Returns nonnegative integer.

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.

(TypedCollection).items

Gets items in collection.

Returns list.

local_maxima

Gets segment local maxima.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment.local_maxima
[NumberedPitch(7)]

Returns list.

local_minima

Gets segment local minima.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(segment) 
>>> segment.local_minima
[NumberedPitch(-1.5)]

Returns list.