Scale

class tonalanalysistools.Scale(*args)

A diatonic scale.

>>> scale = tonalanalysistools.Scale('c', 'minor')

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

alpha() Morris alpha transform of pitch-class segment:
count(item) Changes item to item.
create_named_pitch_set_in_pitch_range(...) Creates named pitch-set in pitch_range.
dominant Dominant of scale.
from_selection(class_, selection[, ...]) Make scale from selection.
has_duplicates True if segment contains duplicate items:
index(item) Changes item to item.
invert([axis]) Inverts pitch-class segment:
is_equivalent_under_transposition(expr) True if equivalent under transposition to expr.
item_class Item class to coerce items into.
items Gets collection items.
key_signature Key signature of scale.
leading_tone Leading tone of scale.
make_notes(n[, written_duration]) Makes first n notes in ascending diatonic scale according to key_signature.
make_score() Make MIDI playback score from scale:
mediant Mediant of scale.
multiply(n) Multiply pitch-class segment by n:
named_interval_class_segment Named interval class segment of scale.
named_pitch_class_to_scale_degree(\*args) Changes named pitch-class to scale degree.
retrograde() Retrograde of pitch-class segment:
rotate(n[, transpose]) Rotate pitch-class segment:
scale_degree_to_named_pitch_class(\*args) Changes scale degree to named pitch-class.
subdominant Subdominant of scale.
submediant Submediate of scale.
superdominant Superdominant of scale.
tonic Tonic of scale.
transpose(expr) Transpose pitch-class segment:
voice_horizontally([initial_octave]) Voices pitch-class segment as pitch segment, with each pitch as close in distance to the previous pitch as possible.
voice_scale_degrees_in_open_position(...) Voice scale_degrees in open position:
voice_vertically([initial_octave]) Voices pitch-class segment as pitch segment, with each pitch always higher than the previous.
__add__(expr) Adds typed tuple to expr.
__contains__(item) Change item to item and return true if item exists in collection.
__eq__(expr) Is true when expr is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats Abjad object.
__getitem__(i) Gets i from type tuple.
__getslice__(start, stop) Gets slice from start to stop in typed tuple.
__hash__() Hashes typed tuple.
__illustrate__(\*\*kwargs) Illustrates pitch-class segment.
__iter__() Iterates typed collection.
__len__() Length of typed collection.
__mul__(expr) Multiplies typed tuple by expr.
__ne__(expr) Is true when expr is not a typed collection with items equal to this typed collection.
__radd__(expr) Right-adds expr to typed tuple.
__repr__() Gets interpreter representation of Abjad object.
__rmul__(expr) Multiplies expr by typed tuple.
__str__() Gets string representation of segment.

Read-only properties

Scale.dominant

Dominant of scale.

Return pitch-class.

(PitchClassSegment).has_duplicates

True if segment contains duplicate items:

>>> pitch_class_segment = pitchtools.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     )
>>> pitch_class_segment.has_duplicates
True
>>> pitch_class_segment = pitchtools.PitchClassSegment(
...     items="c d e f g a b",
...     )
>>> pitch_class_segment.has_duplicates
False

Returns true or false.

(TypedCollection).item_class

Item class to coerce items into.

(TypedCollection).items

Gets collection items.

Scale.key_signature

Key signature of scale.

Returns key signature.

Scale.leading_tone

Leading tone of scale.

Returns pitch-class.

Scale.mediant

Mediant of scale.

Returns pitch-class.

Scale.named_interval_class_segment

Named interval class segment of scale.

Returns interval-class segment.

Scale.subdominant

Subdominant of scale.

Returns pitch-class.

Scale.submediant

Submediate of scale.

Returns pitch-class.

Scale.superdominant

Superdominant of scale.

Returns pitch-class.

Scale.tonic

Tonic of scale.

Returns pitch-class.

Methods

(PitchClassSegment).alpha()

Morris alpha transform of pitch-class segment:

>>> pitch_class_segment = pitchtools.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     )
>>> pitch_class_segment.alpha()
PitchClassSegment([11, 11.5, 7, 6, 11.5, 6])

Returns new pitch-class segment.

(TypedTuple).count(item)

Changes item to item.

Returns count in collection.

Scale.create_named_pitch_set_in_pitch_range(pitch_range)

Creates named pitch-set in pitch_range.

Returns pitch-set.

(TypedTuple).index(item)

Changes item to item.

Returns index in collection.

(PitchClassSegment).invert(axis=None)

Inverts pitch-class segment:

>>> pitch_class_segment = pitchtools.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     )
>>> pitch_class_segment.invert()
PitchClassSegment([2, 1.5, 6, 5, 1.5, 5])

Returns new pitch-class segment.

(PitchClassSegment).is_equivalent_under_transposition(expr)

True if equivalent under transposition to expr. Otherwise False.

Returns true or false.

Scale.make_notes(n, written_duration=None)

Makes first n notes in ascending diatonic scale according to key_signature.

Set written_duration equal to written_duration or 1/8:

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

Allow nonassignable written_duration:

>>> notes = scale.make_notes(4, Duration(5, 16))
>>> staff = Staff(notes)
>>> time_signature = TimeSignature((5, 4))
>>> attach(time_signature, staff)
>>> show(staff) 

Returns list of notes.

Scale.make_score()

Make MIDI playback score from scale:

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

Returns score.

(PitchClassSegment).multiply(n)

Multiply pitch-class segment by n:

>>> pitch_class_segment = pitchtools.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     )
>>> pitch_class_segment.multiply(5)
PitchClassSegment([2, 4.5, 6, 11, 4.5, 11])

Returns new pitch-class segment.

Scale.named_pitch_class_to_scale_degree(*args)

Changes named pitch-class to scale degree.

Returns scale degree.

(PitchClassSegment).retrograde()

Retrograde of pitch-class segment:

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

Returns new pitch-class segment.

(PitchClassSegment).rotate(n, transpose=False)

Rotate pitch-class segment:

>>> pitchtools.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     ).rotate(1)
PitchClassSegment([7, 10, 10.5, 6, 7, 10.5])
>>> pitchtools.PitchClassSegment(
...     items=['c', 'ef', 'bqs,', 'd'],
...     ).rotate(-2)
PitchClassSegment(['bqs', 'd', 'c', 'ef'])

If transpose is true, transpose the rotated segment to begin at the same pitch class as this segment:

>>> pitchtools.PitchClassSegment(
...     items=['c', 'b', 'd']
...     ).rotate(1, transpose=True)
PitchClassSegment(['c', 'bf', 'a'])

Returns new pitch-class segment.

Scale.scale_degree_to_named_pitch_class(*args)

Changes scale degree to named pitch-class.

>>> scale = tonalanalysistools.Scale('c', 'major')
>>> scale_degree = tonalanalysistools.ScaleDegree('flat', 5)
>>> scale.scale_degree_to_named_pitch_class(scale_degree)
NamedPitchClass('gf')
>>> scale_degree = tonalanalysistools.ScaleDegree('flat', 9)
>>> scale.scale_degree_to_named_pitch_class(scale_degree)
NamedPitchClass('df')

Returns named pitch-class.

(PitchClassSegment).transpose(expr)

Transpose pitch-class segment:

>>> pitchtools.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     ).transpose(10)
PitchClassSegment([8, 8.5, 4, 5, 8.5, 5])

Returns new pitch-class segment.

(PitchClassSegment).voice_horizontally(initial_octave=4)

Voices pitch-class segment as pitch segment, with each pitch as close in distance to the previous pitch as possible.

>>> pitch_classes = pitchtools.PitchClassSegment(
...     "c b d e f g e b a c")
>>> pitch_segment = pitch_classes.voice_horizontally()
>>> show(pitch_segment) 

Returns pitch segment.

Scale.voice_scale_degrees_in_open_position(scale_degrees)

Voice scale_degrees in open position:

>>> scale = tonalanalysistools.Scale('c', 'major')
>>> scale_degrees = [1, 3, ('flat', 5), 7, ('sharp', 9)]
>>> pitches = scale.voice_scale_degrees_in_open_position(
...     scale_degrees)
>>> pitches
PitchSegment(["c'", "e'", "gf'", "b'", "ds''"])

Return pitch segment.

(PitchClassSegment).voice_vertically(initial_octave=4)

Voices pitch-class segment as pitch segment, with each pitch always higher than the previous.

>>> scale_degree_numbers = [1, 3, 5, 7, 9, 11, 13]
>>> scale = tonalanalysistools.Scale('c', 'minor')
>>> pitch_classes = pitchtools.PitchClassSegment((
...     scale.scale_degree_to_named_pitch_class(x)
...     for x in scale_degree_numbers))
>>> pitch_segment = pitch_classes.voice_vertically()
>>> pitch_segment
PitchSegment(["c'", "ef'", "g'", "bf'", "d''", "f''", "af''"])
>>> show(pitch_segment) 

Returns pitch segment.

Class & static methods

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

Make scale from selection.

Returns new scale.

Special methods

(TypedTuple).__add__(expr)

Adds typed tuple to expr.

Returns new typed tuple.

(TypedTuple).__contains__(item)

Change item to item and return true if item exists in collection.

Returns none.

(TypedCollection).__eq__(expr)

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

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__(i)

Gets i from type tuple.

Returns item.

(TypedTuple).__getslice__(start, stop)

Gets slice from start to stop in typed tuple.

Returns new typed tuple.

(TypedTuple).__hash__()

Hashes typed tuple.

Returns integer.

(PitchClassSegment).__illustrate__(**kwargs)

Illustrates pitch-class segment.

Example 1. Numbered pitch-class segment:

>>> pitch_class_segment = pitchtools.PitchClassSegment(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     item_class=pitchtools.NumberedPitchClass,
...     )
>>> show(pitch_class_segment) 

Returns LilyPond file.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Length of typed collection.

Returns nonnegative integer.

(TypedTuple).__mul__(expr)

Multiplies typed tuple by expr.

Returns new typed tuple.

(TypedCollection).__ne__(expr)

Is true when expr is not a typed collection with items equal to this typed collection. Otherwise false.

Returns true or false.

(TypedTuple).__radd__(expr)

Right-adds expr to typed tuple.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedTuple).__rmul__(expr)

Multiplies expr by typed tuple.

Returns new typed tuple.

(Segment).__str__()

Gets string representation of segment.

Returns string.