Scale

class tonalanalysistools.Scale(key_signature=None)

Scale.

>>> import abjad
>>> from abjad.tools import tonalanalysistools

Initializes from pair:

>>> tonalanalysistools.Scale(('c', 'minor'))
Scale("c d ef f g af bf")

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.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_datastructuretools { graph [label=datastructuretools]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" [color=3, group=2, label=TypedCollection, shape=oval, style=bold]; "abjad.tools.datastructuretools.TypedTuple.TypedTuple" [color=3, group=2, label=TypedTuple, shape=box]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" -> "abjad.tools.datastructuretools.TypedTuple.TypedTuple"; } subgraph cluster_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.PitchClassSegment.PitchClassSegment" [color=4, group=3, label=PitchClassSegment, shape=box]; "abjad.tools.pitchtools.Segment.Segment" [color=4, group=3, label=Segment, shape=oval, style=bold]; "abjad.tools.pitchtools.Segment.Segment" -> "abjad.tools.pitchtools.PitchClassSegment.PitchClassSegment"; } subgraph cluster_tonalanalysistools { graph [label=tonalanalysistools]; "abjad.tools.tonalanalysistools.Scale.Scale" [color=black, fontcolor=white, group=4, label=<<B>Scale</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.AbjadObject.AbjadObject" -> "abjad.tools.datastructuretools.TypedCollection.TypedCollection"; "abjad.tools.datastructuretools.TypedTuple.TypedTuple" -> "abjad.tools.pitchtools.Segment.Segment"; "abjad.tools.pitchtools.PitchClassSegment.PitchClassSegment" -> "abjad.tools.tonalanalysistools.Scale.Scale"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

count(item) Counts item in segment.
create_named_pitch_set_in_pitch_range(…) Creates named pitch-set in pitch_range.
dominant Gets dominant.
from_selection(selection[, item_class, name]) Makes scale from selection.
has_duplicates() Is true when segment contains duplicate items.
index(item) Gets index of item in segment.
invert([axis]) Inverts segment.
item_class Gets item class of segment.
items Gets items in segment.
key_signature Gets key signature.
leading_tone Gets leading tone.
make_notes(n[, written_duration]) Makes first n notes in ascending scale.
make_score() Makes MIDI playback score from scale.
mediant Gets mediant.
multiply([n]) Multiplies pitch-classes in segment by n.
named_interval_class_segment Gets named interval class segment.
named_pitch_class_to_scale_degree(pitch_class) Changes named pitch_class to scale degree.
permute([row]) Permutes segment by twelve-tone row.
retrograde() Gets retrograde of segment.
rotate([n, stravinsky]) Rotates segment by index n.
scale_degree_to_named_pitch_class(scale_degree) Changes scale degree to named pitch-class.
subdominant Gets subdominant.
submediant Submediate of scale.
superdominant Gets superdominant.
to_pitch_classes() Changes to pitch-classes.
to_pitches() Changes to pitches.
tonic Gets tonic.
transpose([n]) Transposes segment by index n.
voice_horizontally([initial_octave]) Voices segment with each pitch as close to the previous pitch as possible.
voice_scale_degrees_in_open_position(…) Voices scale_degrees in open position.
voice_vertically([initial_octave]) Voices segment with each pitch higher than the previous.
__add__(argument) Adds argument to segment.
__contains__(argument) Is true when pitch-class segment contains argument.
__eq__(argument) Is true when argument is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats segment.
__getitem__(argument) Gets item in scale.
__hash__() Hashes typed tuple.
__illustrate__([expression_markup_direction]) Illustrates segment.
__iter__() Iterates typed collection.
__len__() Gets length of typed collection.
__mul__(n) Multiplies pitch-class segment by n.
__ne__(argument) Is true when Abjad object does not equal argument.
__radd__(argument) Right-adds argument to typed tuple.
__repr__() Gets interpreter representation.
__rmul__(n) Multiplies n by pitch-class segment.
__str__() Gets string representation of pitch-class segment.

Read-only properties

Scale.dominant

Gets dominant.

>>> tonalanalysistools.Scale(('c', 'minor')).dominant
NamedPitchClass('g')

Return pitch-class.

(PitchClassSegment).item_class

Gets item class of segment.

Gets item class of numbered segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(items=items)
>>> show(segment) 
>>> segment.item_class
<class 'abjad.tools.pitchtools.NumberedPitchClass.NumberedPitchClass'>

Gets item class of named segment:

>>> items = ['c', 'ef', 'bqs,', 'd']
>>> segment = abjad.PitchClassSegment(
...     items=items,
...     item_class=abjad.NamedPitchClass,
...     )
>>> show(segment) 
>>> segment.item_class
<class 'abjad.tools.pitchtools.NamedPitchClass.NamedPitchClass'>

Returns class:

>>> type(segment.item_class)
<class 'abc.ABCMeta'>
(PitchClassSegment).items

Gets items in segment.

Initializes items positionally:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(items)
>>> for item in segment.items:
...     item
...
NumberedPitchClass(10)
NumberedPitchClass(10.5)
NumberedPitchClass(6)
NumberedPitchClass(7)
NumberedPitchClass(10.5)
NumberedPitchClass(7)

Initializes items from keyword:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(items=items)
>>> for item in segment.items:
...     item
... 
NumberedPitchClass(10)
NumberedPitchClass(10.5)
NumberedPitchClass(6)
NumberedPitchClass(7)
NumberedPitchClass(10.5)
NumberedPitchClass(7)

Initializes items positionally:

>>> expression = abjad.Expression()
>>> expression = expression.pitch_class_segment()
>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = expression(items)
>>> for item in segment.items:
...     item
... 
NumberedPitchClass(10)
NumberedPitchClass(10.5)
NumberedPitchClass(6)
NumberedPitchClass(7)
NumberedPitchClass(10.5)
NumberedPitchClass(7)

Initializes items from keyword:

>>> expression = abjad.Expression()
>>> expression = expression.pitch_class_segment()
>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = expression(items=items)
>>> for item in segment.items:
...     item
... 
NumberedPitchClass(10)
NumberedPitchClass(10.5)
NumberedPitchClass(6)
NumberedPitchClass(7)
NumberedPitchClass(10.5)
NumberedPitchClass(7)

Returns list:

>>> isinstance(segment.items, list)
True
Scale.key_signature

Gets key signature.

>>> tonalanalysistools.Scale(('c', 'minor')).key_signature
KeySignature(NamedPitchClass('c'), Mode('minor'))

Returns key signature.

Scale.leading_tone

Gets leading tone.

>>> tonalanalysistools.Scale(('c', 'minor')).leading_tone
NamedPitchClass('bf')

Returns pitch-class.

Scale.mediant

Gets mediant.

>>> tonalanalysistools.Scale(('c', 'minor')).mediant
NamedPitchClass('ef')

Returns pitch-class.

Scale.named_interval_class_segment

Gets named interval class segment.

>>> scale = tonalanalysistools.Scale(('c', 'minor'))
>>> str(scale.named_interval_class_segment)
'<+M2, +m2, +M2, +M2, +m2, +M2, +M2>'
>>> scale = tonalanalysistools.Scale(('d', 'dorian'))
>>> str(scale.named_interval_class_segment)
'<+M2, +m2, +M2, +M2, +M2, +m2, +M2>'

Returns interval-class segment.

Scale.subdominant

Gets subdominant.

>>> tonalanalysistools.Scale(('c', 'minor')).subdominant
NamedPitchClass('f')

Returns pitch-class.

Scale.submediant

Submediate of scale.

>>> tonalanalysistools.Scale(('c', 'minor')).submediant
NamedPitchClass('af')

Returns pitch-class.

Scale.superdominant

Gets superdominant.

>>> tonalanalysistools.Scale(('c', 'minor')).superdominant
NamedPitchClass('d')

Returns pitch-class.

Scale.tonic

Gets tonic.

>>> tonalanalysistools.Scale(('c', 'minor')).tonic
NamedPitchClass('c')

Returns pitch-class.

Methods

(PitchClassSegment).count(item)

Counts item in segment.

Example segment:

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

Counts existing item in segment:

>>> segment.count(-1.5)
2

Counts nonexisting item in segment:

>>> segment.count('text')
0

Returns nonnegative integer:

>>> isinstance(segment.count('text'), int)
True
Scale.create_named_pitch_set_in_pitch_range(pitch_range)

Creates named pitch-set in pitch_range.

Returns pitch-set.

(PitchClassSegment).has_duplicates()

Is true when segment contains duplicate items. Otherwise false.

Has duplicates:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(items=items)
>>> show(segment) 
>>> segment.has_duplicates()
True

Has no duplicates:

>>> items = "c d e f g a b"
>>> segment = abjad.PitchClassSegment(items=items)
>>> show(segment) 
>>> segment.has_duplicates()
False

Returns true or false.

(PitchClassSegment).index(item)

Gets index of item in segment.

Example segment:

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

Gets index of first item in segment:

>>> segment.index(-2)
0

Gets index of second item in segment:

>>> segment.index(-1.5)
1

Returns nonnegative integer:

>>> isinstance(segment.index(-1.5), int)
True
(PitchClassSegment).invert(axis=None)

Inverts segment.

Example segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> J = abjad.PitchClassSegment(items=items)
>>> J
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(J) 

Inverts segment:

>>> J.invert()
PitchClassSegment([2, 1.5, 6, 5, 1.5, 5])
>>> segment = J.invert()
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.invert()
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([2, 1.5, 6, 5, 1.5, 5])
>>> expression.get_string()
'I(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Inverts inversion of segment:

>>> J.invert().invert()
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment = J.invert().invert()
>>> show(segment) 
>>> segment == J
True
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.invert()
>>> expression = expression.invert()
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> expression.get_string()
'I(I(J))'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Returns pitch-class segment:

>>> isinstance(segment, abjad.PitchClassSegment)
True
Scale.make_notes(n, written_duration=(1, 8))

Makes first n notes in ascending scale.

>>> scale = tonalanalysistools.Scale(('c', 'major'))
>>> notes = scale.make_notes(8)
>>> staff = abjad.Staff(notes)
>>> show(staff) 

Returns selection of notes.

Scale.make_score()

Makes MIDI playback score from scale.

>>> scale = tonalanalysistools.Scale(('E', 'major'))
>>> score = scale.make_score()
>>> show(score) 

Returns score.

(PitchClassSegment).multiply(n=1)

Multiplies pitch-classes in segment by n.

Example segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> J = abjad.PitchClassSegment(items=items)
>>> J
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(J) 

Multiplies pitch-classes in segment by 1:

>>> J.multiply(n=1)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment = J.multiply(n=1)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.multiply(n=1)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> expression.get_string()
'M1(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Multiplies pitch-classes in segment by 5:

>>> J.multiply(n=5)
PitchClassSegment([2, 4.5, 6, 11, 4.5, 11])
>>> segment = J.multiply(n=5)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.multiply(n=5)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([2, 4.5, 6, 11, 4.5, 11])
>>> expression.get_string()
'M5(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Multiplies pitch-classes in segment by 7:

>>> J.multiply(n=7)
PitchClassSegment([10, 1.5, 6, 1, 1.5, 1])
>>> segment = J.multiply(n=7)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.multiply(n=7)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([10, 1.5, 6, 1, 1.5, 1])
>>> expression.get_string()
'M7(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Multiplies pitch-classes in segment by 11:

>>> segment = J.multiply(n=11)
>>> segment
PitchClassSegment([2, 7.5, 6, 5, 7.5, 5])
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.multiply(n=11)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([2, 7.5, 6, 5, 7.5, 5])
>>> expression.get_string()
'M11(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Returns pitch-class segment:

>>> isinstance(segment, abjad.PitchClassSegment)
True
Scale.named_pitch_class_to_scale_degree(pitch_class)

Changes named pitch_class to scale degree.

>>> scale = tonalanalysistools.Scale(('c', 'major'))
>>> scale.named_pitch_class_to_scale_degree('c')
ScaleDegree('1')
>>> scale.named_pitch_class_to_scale_degree('d')
ScaleDegree('2')
>>> scale.named_pitch_class_to_scale_degree('e')
ScaleDegree('3')
>>> scale.named_pitch_class_to_scale_degree('f')
ScaleDegree('4')
>>> scale.named_pitch_class_to_scale_degree('g')
ScaleDegree('5')
>>> scale.named_pitch_class_to_scale_degree('a')
ScaleDegree('6')
>>> scale.named_pitch_class_to_scale_degree('b')
ScaleDegree('7')
>>> scale.named_pitch_class_to_scale_degree('df')
ScaleDegree('b2')

Returns scale degree.

(PitchClassSegment).permute(row=None)

Permutes segment by twelve-tone row.

>>> abjad.PitchClassSegment([-2, -1, 6, 7, -1, 7])
PitchClassSegment([10, 11, 6, 7, 11, 7])
>>> segment = abjad.PitchClassSegment([-2, -1, 6, 7, -1, 7])
>>> show(segment) 
>>> segment.permute([10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11])
PitchClassSegment([4, 11, 5, 3, 11, 3])
>>> segment = segment.permute([10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11])
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> row = [10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11]
>>> expression = expression.permute(row)
>>> expression([-2, -1, 6, 7, -1, 7])
PitchClassSegment([4, 11, 5, 3, 11, 3])
>>> expression.get_string()
'permute(J, row=[10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11])'
>>> segment = expression([-2, -1, 6, 7, -1, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Returns new segment.

(PitchClassSegment).retrograde()

Gets retrograde of segment.

Example segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> J = abjad.PitchClassSegment(items=items)
>>> J
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(J) 

Gets retrograde of segment:

>>> segment = J.retrograde()
>>> segment
PitchClassSegment([7, 10.5, 7, 6, 10.5, 10])
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.retrograde()
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([7, 10.5, 7, 6, 10.5, 10])
>>> expression.get_string()
'R(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Gets retrograde of retrograde of segment:

>>> segment = J.retrograde().retrograde()
>>> segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(segment) 
>>> segment == J
True
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.retrograde()
>>> expression = expression.retrograde()
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> expression.get_string()
'R(R(J))'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 
>>> segment == J
True

Returns pitch-class segment:

>>> isinstance(segment, abjad.PitchClassSegment)
True
(PitchClassSegment).rotate(n=0, stravinsky=False)

Rotates segment by index n.

Example segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> J = abjad.PitchClassSegment(items=items)
>>> J
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(J) 

Rotates segment to the right:

>>> J.rotate(n=1)
PitchClassSegment([7, 10, 10.5, 6, 7, 10.5])
>>> segment = J.rotate(n=1)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.rotate(n=1)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([7, 10, 10.5, 6, 7, 10.5])
>>> expression.get_string()
'r1(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Rotates segment to the left:

>>> J.rotate(n=-1)
PitchClassSegment([10.5, 6, 7, 10.5, 7, 10])
>>> segment = J.rotate(n=-1)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.rotate(n=-1)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([10.5, 6, 7, 10.5, 7, 10])
>>> expression.get_string()
'r-1(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Rotates segment by zero:

>>> J.rotate(n=0)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment = J.rotate(n=0)
>>> show(segment) 
>>> segment == J
True
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.rotate(n=0)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> expression.get_string()
'r0(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 
>>> segment == J
True

Stravinsky-style rotation back-transposes segment to begin at zero:

>>> J.rotate(n=1, stravinsky=True)
PitchClassSegment([0, 3, 3.5, 11, 0, 3.5])
>>> segment = J.rotate(n=1, stravinsky=True)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.rotate(n=1, stravinsky=True)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([0, 3, 3.5, 11, 0, 3.5])
>>> expression.get_string()
'rs1(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Returns pitch-class segment:

>>> isinstance(segment, abjad.PitchClassSegment)
True
Scale.scale_degree_to_named_pitch_class(scale_degree)

Changes scale degree to named pitch-class.

>>> scale = tonalanalysistools.Scale(('c', 'major'))
>>> scale.scale_degree_to_named_pitch_class('1')
NamedPitchClass('c')
>>> scale.scale_degree_to_named_pitch_class('2')
NamedPitchClass('d')
>>> scale.scale_degree_to_named_pitch_class('3')
NamedPitchClass('e')
>>> scale.scale_degree_to_named_pitch_class('4')
NamedPitchClass('f')
>>> scale.scale_degree_to_named_pitch_class('5')
NamedPitchClass('g')
>>> scale.scale_degree_to_named_pitch_class('6')
NamedPitchClass('a')
>>> scale.scale_degree_to_named_pitch_class('7')
NamedPitchClass('b')
>>> scale.scale_degree_to_named_pitch_class('b2')
NamedPitchClass('df')

Returns named pitch-class.

(PitchClassSegment).to_pitch_classes()

Changes to pitch-classes.

To numbered pitch-class segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(items=items)
>>> segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(segment) 
>>> segment = segment.to_pitch_classes()
>>> segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(segment) 

To named pitch-class segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(
...     items=items,
...     item_class=abjad.NamedPitchClass,
...     )
>>> segment
PitchClassSegment("bf bqf fs g bqf g")
>>> show(segment) 
>>> segment = segment.to_pitch_classes()
>>> segment
PitchClassSegment("bf bqf fs g bqf g")
>>> show(segment) 

Returns new segment.

(PitchClassSegment).to_pitches()

Changes to pitches.

To numbered pitch segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(items=items)
>>> segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(segment) 
>>> segment = segment.to_pitches()
>>> segment
PitchSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(segment) 

To named pitch segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(
...     items=items,
...     item_class=abjad.NamedPitchClass,
...     )
>>> segment
PitchClassSegment("bf bqf fs g bqf g")
>>> show(segment) 
>>> segment = segment.to_pitches()
>>> segment
PitchSegment("bf' bqf' fs' g' bqf' g'")
>>> show(segment) 

Returns new segment.

(PitchClassSegment).transpose(n=0)

Transposes segment by index n.

Example segment:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> J = abjad.PitchClassSegment(items=items)
>>> J
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> show(J) 

Transposes segment by positive index:

>>> J.transpose(n=13)
PitchClassSegment([11, 11.5, 7, 8, 11.5, 8])
>>> segment = J.transpose(n=13)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.transpose(n=13)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([11, 11.5, 7, 8, 11.5, 8])
>>> expression.get_string()
'T13(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Transposes segment by negative index:

>>> J.transpose(n=-13)
PitchClassSegment([9, 9.5, 5, 6, 9.5, 6])
>>> segment = J.transpose(n=-13)
>>> show(segment) 
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.transpose(n=-13)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([9, 9.5, 5, 6, 9.5, 6])
>>> expression.get_string()
'T-13(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Transposes segment by zero index:

>>> J.transpose(n=0)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment = J.transpose(n=0)
>>> show(segment) 
>>> segment == J
True
>>> expression = abjad.Expression(name='J')
>>> expression = expression.pitch_class_segment()
>>> expression = expression.transpose(n=0)
>>> expression([-2, -1.5, 6, 7, -1.5, 7])
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> expression.get_string()
'T0(J)'
>>> segment = expression([-2, -1.5, 6, 7, -1.5, 7])
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 
>>> segment == J
True

Returns pitch-class segment:

>>> isinstance(segment, abjad.PitchClassSegment)
True
(PitchClassSegment).voice_horizontally(initial_octave=4)

Voices segment with each pitch as close to the previous pitch as possible.

Todo

Should be implemented somewhere else.

Voices horizontally:

>>> items = "c b d e f g e b a c"
>>> segment = abjad.PitchClassSegment(items=items)
>>> show(segment) 
>>> voiced_segment = segment.voice_horizontally()
>>> show(voiced_segment) 

Returns pitch segment:

>>> voiced_segment
PitchSegment("c' b d' e' f' g' e' b a c'")
Scale.voice_scale_degrees_in_open_position(scale_degrees)

Voices scale_degrees in open position.

>>> scale = tonalanalysistools.Scale(('c', 'major'))
>>> scale_degrees = [1, 3, 'b5', 7, '#9']
>>> segment = scale.voice_scale_degrees_in_open_position(
...     scale_degrees)
>>> segment
PitchSegment("c' e' gf' b' ds''")

Return pitch segment.

(PitchClassSegment).voice_vertically(initial_octave=4)

Voices segment with each pitch higher than the previous.

Todo

Should be implemented somewhere else.

Voices vertically:

>>> scale_degree_numbers = [1, 3, 5, 7, 9, 11, 13]
>>> scale = abjad.tonalanalysistools.Scale(('c', 'minor'))
>>> segment = abjad.PitchClassSegment((
...     scale.scale_degree_to_named_pitch_class(x)
...     for x in scale_degree_numbers))
>>> show(segment) 
>>> voiced_segment = segment.voice_vertically()
>>> show(voiced_segment) 

Returns pitch segment:

>>> voiced_segment
PitchSegment("c' ef' g' bf' d'' f'' af''")

Class & static methods

classmethod Scale.from_selection(selection, item_class=None, name=None)

Makes scale from selection.

Returns new scale.

Special methods

(PitchClassSegment).__add__(argument)

Adds argument to segment.

Example segments:

>>> pitch_numbers = [-2, -1.5, 6, 7, -1.5, 7]
>>> abjad.PitchClassSegment(items=pitch_numbers)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> J = abjad.PitchClassSegment(items=pitch_numbers)
>>> show(J) 
>>> pitch_names = ['c', 'ef', 'bqs,', 'd']
>>> abjad.PitchClassSegment(items=pitch_names)
PitchClassSegment("c ef bqs d")
>>> K = abjad.PitchClassSegment(items=pitch_names)
>>> show(K) 

Adds J and K:

>>> J + K
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 0, 3, 11.5, 2])
>>> segment = J + K
>>> show(segment) 
>>> expression_J = abjad.Expression(name='J')
>>> expression_J = expression_J.pitch_class_segment()
>>> expression_K = abjad.Expression(name='K')
>>> expression_K = expression_K.pitch_class_segment()
>>> expression = expression_J + expression_K
>>> expression(pitch_numbers, pitch_names)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 0, 3, 11.5, 2])
>>> expression.get_string()
'J + K'
>>> segment = expression(pitch_numbers, pitch_names)
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Adds K and J:

>>> K + J
PitchClassSegment("c ef bqs d bf bqf fs g bqf g")
>>> segment = K + J
>>> show(segment) 
>>> expression_J = abjad.Expression(name='J')
>>> expression_J = expression_J.pitch_class_segment()
>>> expression_K = abjad.Expression(name='K')
>>> expression_K = expression_K.pitch_class_segment()
>>> expression = expression_K + expression_J
>>> expression(pitch_names, pitch_numbers)
PitchClassSegment("c ef bqs d bf bqf fs g bqf g")
>>> expression.get_string()
'K + J'
>>> segment = expression(pitch_names, pitch_numbers)
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Adds J repeatedly:

>>> J + J + J
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])
>>> segment = J + J + J
>>> show(segment) 
>>> expression_J = abjad.Expression(name='J')
>>> expression_J = expression_J.pitch_class_segment()
>>> expression = expression_J + expression_J + expression_J
>>> expression(pitch_numbers, pitch_numbers, pitch_numbers)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])
>>> expression.get_string()
'J + J + J'
>>> list_ = [pitch_numbers, pitch_numbers, pitch_numbers]
>>> segment = expression(*list_)
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Adds transformed segments:

>>> J.rotate(n=1) + K.rotate(n=2)
PitchClassSegment([7, 10, 10.5, 6, 7, 10.5, 11.5, 2, 0, 3])
>>> segment = J.rotate(n=1) + K.rotate(n=2)
>>> show(segment) 
>>> expression_J = abjad.Expression(name='J')
>>> expression_J = expression_J.pitch_class_segment()
>>> expression_J = expression_J.rotate(n=1)
>>> expression_K = abjad.Expression(name='K')
>>> expression_K = expression_K.pitch_class_segment()
>>> expression_K = expression_K.rotate(n=2)
>>> expression = expression_J + expression_K
>>> expression(pitch_numbers, pitch_names)
PitchClassSegment([7, 10, 10.5, 6, 7, 10.5, 11.5, 2, 0, 3])
>>> expression.get_string()
'r1(J) + r2(K)'
>>> segment = expression(pitch_numbers, pitch_names)
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Reverses result:

>>> segment = J.rotate(n=1) + K.rotate(n=2)
>>> segment.retrograde()
PitchClassSegment([3, 0, 2, 11.5, 10.5, 7, 6, 10.5, 10, 7])
>>> segment = segment.retrograde()
>>> show(segment) 
>>> expression_J = abjad.Expression(name='J')
>>> expression_J = expression_J.pitch_class_segment()
>>> expression_J = expression_J.rotate(n=1)
>>> expression_K = abjad.Expression(name='K')
>>> expression_K = expression_K.pitch_class_segment()
>>> expression_K = expression_K.rotate(n=2)
>>> expression = expression_J + expression_K
>>> expression = expression.retrograde()
>>> expression(pitch_numbers, pitch_names)
PitchClassSegment([3, 0, 2, 11.5, 10.5, 7, 6, 10.5, 10, 7])
>>> expression.get_string()
'R(r1(J) + r2(K))'
>>> segment = expression(pitch_numbers, pitch_names)
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Establishes equivalence:

>>> expression_J = abjad.Expression(name='J')
>>> expression_J = expression_J.pitch_class_segment()
>>> expression_J = expression_J.rotate(n=1)
>>> expression_K = abjad.Expression(name='K')
>>> expression_K = expression_K.pitch_class_segment()
>>> expression_K = expression_K.rotate(n=2)
>>> expression = expression_J + expression_K
>>> expression = expression.establish_equivalence(name='Q')
>>> expression(pitch_numbers, pitch_names)
PitchClassSegment([7, 10, 10.5, 6, 7, 10.5, 11.5, 2, 0, 3])
>>> expression.get_string()
'Q = r1(J) + r2(K)'
>>> segment = expression(pitch_numbers, pitch_names)
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Transforms equivalence:

>>> expression = expression.transpose(n=1)
>>> expression(pitch_numbers, pitch_names)
PitchClassSegment([8, 11, 11.5, 7, 8, 11.5, 0.5, 3, 1, 4])
>>> expression.get_string()
'T1(Q)'
>>> segment = expression(pitch_numbers, pitch_names)
>>> markup = expression.get_markup()
>>> show(segment, figure_name=markup) 

Returns new segment.

(PitchClassSegment).__contains__(argument)

Is true when pitch-class segment contains argument.

Example segments:

>>> pitch_numbers = [-2, -1.5, 6, 7, -1.5, 7]
>>> segment = abjad.PitchClassSegment(items=pitch_numbers)
>>> segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> abjad.NamedPitch('bf') in segment
True
>>> abjad.NamedPitch('cs') in segment
False
>>> 'bf' in segment
True
>>> 'cs' in segment
False
>>> 10 in segment
True
>>> 13 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. Otherwise false.

Returns true or false.

(PitchClassSegment).__format__(format_specification='')

Formats segment.

With numbered pitch-classes:

>>> pitch_numbers = [-2, -1.5, 6, 7, -1.5, 7]
>>> J = abjad.PitchClassSegment(items=pitch_numbers)
>>> f(J)
abjad.PitchClassSegment(
    (
        abjad.NumberedPitchClass(10),
        abjad.NumberedPitchClass(10.5),
        abjad.NumberedPitchClass(6),
        abjad.NumberedPitchClass(7),
        abjad.NumberedPitchClass(10.5),
        abjad.NumberedPitchClass(7),
        ),
    item_class=abjad.NumberedPitchClass,
    )
>>> show(J) 

With named pitch-classes:

>>> pitch_names = ['c', 'ef', 'bqs,', 'd']
>>> K = abjad.PitchClassSegment(
...     items=pitch_names,
...     item_class=abjad.NamedPitchClass,
...     )
>>> f(K)
abjad.PitchClassSegment(
    (
        abjad.NamedPitchClass('c'),
        abjad.NamedPitchClass('ef'),
        abjad.NamedPitchClass('bqs'),
        abjad.NamedPitchClass('d'),
        ),
    item_class=abjad.NamedPitchClass,
    )
>>> show(K) 

Returns string.

Scale.__getitem__(argument)

Gets item in scale.

Returns pitch-class segment.

(TypedTuple).__hash__()

Hashes typed tuple.

Returns integer.

(PitchClassSegment).__illustrate__(expression_markup_direction=Up, **keywords)

Illustrates segment.

Illustrates numbered segment:

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

Illustrates named segment:

>>> items = ['c', 'ef', 'bqs,', 'd']
>>> segment = abjad.PitchClassSegment(
...     items=items,
...     item_class=abjad.NumberedPitchClass,
...     )
>>> show(segment) 

Returns LilyPond file:

>>> prototype = abjad.LilyPondFile
>>> isinstance(segment.__illustrate__(), prototype)
True
(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(PitchClassSegment).__mul__(n)

Multiplies pitch-class segment by n.

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> 2 * abjad.PitchClassSegment(items=items)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])

Returns new pitch-class segment.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(TypedTuple).__radd__(argument)

Right-adds argument to typed tuple.

(PitchClassSegment).__repr__()

Gets interpreter representation.

Interpreter representation:

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> abjad.PitchClassSegment(items=items)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])

Returns string.

(PitchClassSegment).__rmul__(n)

Multiplies n by pitch-class segment.

>>> items = [-2, -1.5, 6, 7, -1.5, 7]
>>> abjad.PitchClassSegment(items=items) * 2
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])

Returns new pitch-class segment.

(PitchClassSegment).__str__()

Gets string representation of pitch-class segment.

Gets string represenation of numbered pitch class:

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

Gets string represenation of named pitch class:

>>> segment = abjad.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     item_class=abjad.NamedPitchClass,
...     )
>>> str(segment)
'PC<bf bqf fs g bqf g>'

Returns string.