Voicing¶
voicing ¶
Concrete pitch realizations of chords (voicings).
The Voicing namespace finds specific arrangements of chord notes within
a given pitch range, drawing from a VoicingDictionary
(jazz lefthand voicings, basic triad inversions, or your own).
Three main entry points:
search— find every voicing that fits.get— find one good voicing (optionally voice-led from a previous voicing).sequence— chain voicings across a progression with smooth voice leading.
Different defaults for get and search
Voicing.get defaults to the all dictionary (triads + lefthand);
Voicing.search defaults to triads only. This matches tonal.js.
Example
from tonal_py import Voicing Voicing.get("Dm7", ["C3", "C5"]) ['F3', 'A3', 'C4', 'E4']
Source parity: @tonaljs/voicing
get ¶
get(chord_name: str, note_range: list[str] | None = None, dictionary: dict[str, list[str]] | None = None, voice_leading: VoiceLeadingFunction | None = None, last_voicing: list[str] | None = None) -> list[str] | None
Get a single voicing of a chord within a range.
If last_voicing is provided, picks the candidate that minimizes
voice-leading delta from it (using the supplied or default
voice_leading strategy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chord_name
|
str
|
A chord name (e.g. |
required |
note_range
|
list[str] | None
|
|
None
|
dictionary
|
dict[str, list[str]] | None
|
Voicing dictionary. Defaults to
|
None
|
voice_leading
|
VoiceLeadingFunction | None
|
Strategy for picking among candidates. Defaults to
|
None
|
last_voicing
|
list[str] | None
|
Previous voicing to lead voices smoothly from. |
None
|
Returns:
| Type | Description |
|---|---|
list[str] | None
|
A list of note names, or |
Example
from tonal_py import Voicing Voicing.get("Dm7", ["C3", "C5"]) ['F3', 'A3', 'C4', 'E4'] Voicing.get("Cmaj7", ["C3", "C5"]) ['E3', 'G3', 'B3', 'D4']
Source code in src/tonal_py/voicing.py
search ¶
search(chord_name: str, note_range: list[str] | None = None, dictionary: dict[str, list[str]] | None = None) -> list[list[str]]
Find every concrete voicing of a chord within a note range.
Returns all dictionary voicings for the chord type (or its aliases) placed at every starting position that fits within the range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chord_name
|
str
|
A chord name. |
required |
note_range
|
list[str] | None
|
|
None
|
dictionary
|
dict[str, list[str]] | None
|
Voicing dictionary. Defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
list[list[str]]
|
A list of voicings (each a list of note names). Empty list if |
list[list[str]]
|
the chord has no entry in the dictionary. |
Example
from tonal_py import Voicing
Default search uses triads dictionary; m7 isn't in triads¶
Voicing.search("Dm7", ["C3", "C5"]) []
Major triad inversions in C3-C5 range¶
len(Voicing.search("C", ["C3", "C5"])) > 0 True
Source code in src/tonal_py/voicing.py
sequence ¶
sequence(chords: list[str], note_range: list[str] | None = None, dictionary: dict[str, list[str]] | None = None, voice_leading: VoiceLeadingFunction | None = None, last_voicing: list[str] | None = None) -> list[list[str]]
Voice an entire chord progression with smooth voice leading.
Each chord's voicing is chosen to minimize movement from the previous voicing (using the supplied or default voice-leading strategy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chords
|
list[str]
|
A list of chord names. |
required |
note_range
|
list[str] | None
|
|
None
|
dictionary
|
dict[str, list[str]] | None
|
Voicing dictionary. |
None
|
voice_leading
|
VoiceLeadingFunction | None
|
Strategy for choosing successive voicings. |
None
|
last_voicing
|
list[str] | None
|
Optional starting voicing to lead from. |
None
|
Returns:
| Type | Description |
|---|---|
list[list[str]]
|
A list of voicings, one per input chord. Chords with no fit |
list[list[str]]
|
are silently skipped. |
Example
from tonal_py import Voicing seq = Voicing.sequence(["Dm7", "G7", "Cmaj7"], ["C3", "C5"]) len(seq) 3 seq[0]['F3', 'A3', 'C4', 'E4']