TonalAnalysisAgent

class tonalanalysistools.TonalAnalysisAgent(client=None)

Tonal analysis agent.

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

Intializes agent on conjunct selection:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> show(staff) 
>>> agent_1 = abjad.analyze(staff[:])

Initializes agent on disjunct selection:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> show(staff) 
>>> agent_2 = abjad.analyze(staff[:1] + staff[-1:])

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_tonalanalysistools { graph [label=tonalanalysistools]; "abjad.tools.tonalanalysistools.TonalAnalysisAgent.TonalAnalysisAgent" [color=black, fontcolor=white, group=2, label=<<B>TonalAnalysisAgent</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.tonalanalysistools.TonalAnalysisAgent.TonalAnalysisAgent"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

analyze_chords() Analyzes chords in selection.
analyze_incomplete_chords() Analyzes incomplete chords.
analyze_incomplete_tonal_functions(key_signature) Analyzes incomplete tonal functions of chords in client according to key_signature.
analyze_neighbor_notes() Is true when note in client is preceeded by a stepwise interval in one direction and followed by a stepwise interval in the other direction.
analyze_passing_tones() Is true when note in client is both preceeded and followed by scalewise notes.
analyze_tonal_functions(key_signature) Analyzes tonal function of chords in client according to key_signature.
are_scalar_notes() Is true when notes in client are scalar.
are_stepwise_ascending_notes() Is true when notes in client are stepwise ascending.
are_stepwise_descending_notes() Is true when notes in client are stepwise descending.
are_stepwise_notes() Is true when notes in client are stepwise.
client Gets client.
__eq__(argument) Is true when ID of argument equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad object.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

TonalAnalysisAgent.client

Gets client.

Returns selection or component.

Methods

TonalAnalysisAgent.analyze_chords()

Analyzes chords in selection.

>>> chords = [
...     abjad.Chord([0, 4, 7], (1, 4)),
...     abjad.Chord([4, 7, 12], (1, 4)),
...     abjad.Chord([7, 12, 16], (1, 4)),
...     ]
>>> staff = abjad.Staff(chords)
>>> show(staff) 
>>> for chord in abjad.analyze(staff[:]).analyze_chords():
...     chord
...
CMajorTriadInRootPosition
CMajorTriadInFirstInversion
CMajorTriadInSecondInversion

The three inversions of an a minor triad:

>>> chords = [
...     abjad.Chord([9, 12, 16], (1, 4)),
...     abjad.Chord([12, 16, 21], (1, 4)),
...     abjad.Chord([16, 21, 24], (1, 4)),
...     ]
>>> staff = abjad.Staff(chords)
>>> show(staff) 
>>> for chord in abjad.analyze(staff[:]).analyze_chords():
...     chord
...
AMinorTriadInRootPosition
AMinorTriadInFirstInversion
AMinorTriadInSecondInversion

The four inversions of a C dominant seventh chord:

>>> chords = [
...     abjad.Chord([0, 4, 7, 10], (1, 4)),
...     abjad.Chord([4, 7, 10, 12], (1, 4)),
...     abjad.Chord([7, 10, 12, 16], (1, 4)),
...     abjad.Chord([10, 12, 16, 19], (1, 4)),
...     ]
>>> staff = abjad.Staff(chords)
>>> show(staff) 
>>> for chord in abjad.analyze(staff[:]).analyze_chords():
...     chord
...
CDominantSeventhInRootPosition
CDominantSeventhInFirstInversion
CDominantSeventhInSecondInversion
CDominantSeventhInThirdInversion

The five inversions of a C dominant ninth chord:

>>> chords = [
...     abjad.Chord([0, 4, 7, 10, 14], (1, 4)),
...     abjad.Chord([4, 7, 10, 12, 14], (1, 4)),
...     abjad.Chord([7, 10, 12, 14, 16], (1, 4)),
...     abjad.Chord([10, 12, 14, 16, 19], (1, 4)),
...     abjad.Chord([2, 10, 12, 16, 19], (1, 4)),
...     ]
>>> staff = abjad.Staff(chords)
>>> show(staff) 
>>> for chord in abjad.analyze(staff[:]).analyze_chords():
...     chord
...
CDominantNinthInRootPosition
CDominantNinthInFirstInversion
CDominantNinthInSecondInversion
CDominantNinthInThirdInversion
CDominantNinthInFourthInversion

Returns none when no tonal chord is understood.

Returns list with elements each equal to chord class or none.

TonalAnalysisAgent.analyze_incomplete_chords()

Analyzes incomplete chords.

>>> chord = abjad.Chord("<g' b'>4")
>>> abjad.analyze(chord).analyze_incomplete_chords()
[GMajorTriadInRootPosition]
>>> chord = abjad.Chord("<g' bf'>4")
>>> abjad.analyze(chord).analyze_incomplete_chords()
[GMinorTriadInRootPosition]
>>> chord = abjad.Chord("<f g b>4")
>>> abjad.analyze(chord).analyze_incomplete_chords()
[GDominantSeventhInSecondInversion]
>>> chord = abjad.Chord("<fs g b>4")
>>> abjad.analyze(chord).analyze_incomplete_chords()
[GMajorSeventhInSecondInversion]

Raises tonal harmony error when chord in client can not analyze.

Returns list with elements each equal to chord class or none.

TonalAnalysisAgent.analyze_incomplete_tonal_functions(key_signature)

Analyzes incomplete tonal functions of chords in client according to key_signature.

>>> chord = abjad.Chord("<c' e'>4")
>>> key_signature = abjad.KeySignature('g', 'major')
>>> agent = abjad.analyze(chord)
>>> agent.analyze_incomplete_tonal_functions(key_signature)
[RomanNumeral('IV')]
>>> chord = abjad.Chord("<g' b'>4")
>>> key_signature = abjad.KeySignature('c', 'major')
>>> agent = abjad.analyze(chord)
>>> agent.analyze_incomplete_tonal_functions(key_signature)
[RomanNumeral('V')]
>>> chord = abjad.Chord("<g' bf'>4")
>>> agent = abjad.analyze(chord)
>>> agent.analyze_incomplete_tonal_functions(key_signature)
[RomanNumeral('v')]
>>> key_signature = abjad.KeySignature('c', 'major')
>>> chord = abjad.Chord("<f g b>4")
>>> agent = abjad.analyze(chord)
>>> agent.analyze_incomplete_tonal_functions(key_signature)
[RomanNumeral('V4/3')]
>>> chord = abjad.Chord("<fs g b>4")
>>> agent = abjad.analyze(chord)
>>> agent.analyze_incomplete_tonal_functions(key_signature)
[RomanNumeral('VM4/3')]

Raises tonal harmony error when chord in client can not analyze.

Returns list with elements each equal to tonal function or none.

TonalAnalysisAgent.analyze_neighbor_notes()

Is true when note in client is preceeded by a stepwise interval in one direction and followed by a stepwise interval in the other direction. Otherwise false.

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> show(staff) 
>>> agent = abjad.analyze(staff[:])
>>> agent.analyze_neighbor_notes()
[False, False, False, False]

Returns list of boolean values.

TonalAnalysisAgent.analyze_passing_tones()

Is true when note in client is both preceeded and followed by scalewise notes. Otherwise false.

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> show(staff) 
>>> agent = abjad.analyze(staff[:])
>>> agent.analyze_passing_tones()
[False, True, True, False]

Returns list of boolean values.

TonalAnalysisAgent.analyze_tonal_functions(key_signature)

Analyzes tonal function of chords in client according to key_signature.

>>> chord = abjad.Chord('<ef g bf>4')
>>> key_signature = abjad.KeySignature('c', 'major')
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('bIII')]
>>> key_signature = abjad.KeySignature('c', 'major')
>>> chord = abjad.Chord('<c e g>4')
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('I')]
>>> chord = abjad.Chord(['e', 'g', "c'"], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('I6')]
>>> chord = abjad.Chord(['g', "c'", "e'"], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('I6/4')]
>>> key_signature = abjad.KeySignature('c', 'major')
>>> chord = abjad.Chord(['c', 'ef', 'g'], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('i')]
>>> chord = abjad.Chord(['ef', 'g', "c'"], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('i6')]
>>> chord = abjad.Chord(['g', "c'", "ef'"], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('i6/4')]
>>> key_signature = abjad.KeySignature('c', 'major')
>>> chord = abjad.Chord(['c', 'e', 'g', 'bf'], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('I7')]
>>> chord = abjad.Chord(['e', 'g', 'bf', "c'"], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('I6/5')]
>>> chord = abjad.Chord(['g', 'bf', "c'", "e'"], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('I4/3')]
>>> chord = abjad.Chord(['bf', "c'", "e'", "g'"], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[RomanNumeral('I4/2')]
>>> key_signature = abjad.KeySignature('c', 'major')
>>> chord = abjad.Chord(['c', 'cs', 'd'], (1, 4))
>>> agent = abjad.analyze(chord)
>>> agent.analyze_tonal_functions(key_signature)
[None]

Returns none when no tonal function is understood.

Returns list with elements each equal to tonal function or none.

TonalAnalysisAgent.are_scalar_notes()

Is true when notes in client are scalar. Otherwise false

>>> staff = abjad.Staff("c'4 cs'")
>>> abjad.analyze(staff[:]).are_scalar_notes()
True
>>> staff = abjad.Staff("c'4 d'")
>>> abjad.analyze(staff[:]).are_scalar_notes()
True
>>> staff = abjad.Staff("c'4 ds'")
>>> abjad.analyze(staff[:]).are_scalar_notes()
True
>>> staff = abjad.Staff("c'4 b")
>>> abjad.analyze(staff[:]).are_scalar_notes()
True
>>> staff = abjad.Staff("c'4 c'")
>>> abjad.analyze(staff[:]).are_scalar_notes()
False
>>> staff = abjad.Staff("c'4 e'")
>>> abjad.analyze(staff[:]).are_scalar_notes()
False

Returns true or false.

TonalAnalysisAgent.are_stepwise_ascending_notes()

Is true when notes in client are stepwise ascending. Otherwise false.

>>> staff = abjad.Staff("c'4 cs'")
>>> abjad.analyze(staff[:]).are_stepwise_ascending_notes()
False
>>> staff = abjad.Staff("c'4 d'")
>>> abjad.analyze(staff[:]).are_stepwise_ascending_notes()
True
>>> staff = abjad.Staff("c'4 ds'")
>>> abjad.analyze(staff[:]).are_stepwise_ascending_notes()
True
>>> staff = abjad.Staff("c'4 b")
>>> abjad.analyze(staff[:]).are_stepwise_ascending_notes()
False
>>> staff = abjad.Staff("c'4 c'")
>>> abjad.analyze(staff[:]).are_stepwise_ascending_notes()
False
>>> staff = abjad.Staff("c'4 e'")
>>> abjad.analyze(staff[:]).are_stepwise_ascending_notes()
False

Returns true or false.

TonalAnalysisAgent.are_stepwise_descending_notes()

Is true when notes in client are stepwise descending. Otherwise false.

>>> staff = abjad.Staff("c'4 cs'")
>>> abjad.analyze(staff[:]).are_stepwise_descending_notes()
False
>>> staff = abjad.Staff("c'4 d'")
>>> abjad.analyze(staff[:]).are_stepwise_descending_notes()
False
>>> staff = abjad.Staff("c'4 ds'")
>>> abjad.analyze(staff[:]).are_stepwise_descending_notes()
False
>>> staff = abjad.Staff("c'4 b")
>>> abjad.analyze(staff[:]).are_stepwise_descending_notes()
True
>>> staff = abjad.Staff("c'4 c'")
>>> abjad.analyze(staff[:]).are_stepwise_descending_notes()
False
>>> staff = abjad.Staff("c'4 e'")
>>> abjad.analyze(staff[:]).are_stepwise_descending_notes()
False

Returns true or false.

TonalAnalysisAgent.are_stepwise_notes()

Is true when notes in client are stepwise. Otherwise false.

>>> staff = abjad.Staff("c'4 cs'")
>>> abjad.analyze(staff[:]).are_stepwise_notes()
True
>>> staff = abjad.Staff("c'4 d'")
>>> abjad.analyze(staff[:]).are_stepwise_notes()
True
>>> staff = abjad.Staff("c'4 ds'")
>>> abjad.analyze(staff[:]).are_stepwise_notes()
True
>>> staff = abjad.Staff("c'4 b")
>>> abjad.analyze(staff[:]).are_stepwise_notes()
True
>>> staff = abjad.Staff("c'4 c'")
>>> abjad.analyze(staff[:]).are_stepwise_notes()
False
>>> staff = abjad.Staff("c'4 e'")
>>> abjad.analyze(staff[:]).are_stepwise_notes()
False

Returns true or false.

Special methods

(AbjadObject).__eq__(argument)

Is true when ID of argument equals ID of Abjad object. 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.

(AbjadObject).__hash__()

Hashes Abjad object.

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

Returns integer.

(AbjadObject).__ne__(argument)

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

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.