ChordType¶
chord_type ¶
The chord type dictionary — 106 chord definitions.
The ChordType namespace exposes an in-memory dictionary of 106 chord
types, each indexed by:
- Full name (e.g.
"major seventh") - Aliases (e.g.
"maj7","Δ","M7") - Set number (a decimal int 0-4095)
- Chroma string (12-bit binary)
So ChordType.get("maj7"), ChordType.get("Δ"), ChordType.get(2193),
and ChordType.get("100010010001") all return the same ChordType.
The dictionary is mutable: add extends it,
remove_all clears it. Useful for
project-specific chord vocabularies.
Example
from tonal_py import ChordType len(ChordType.all()) 106 ChordType.get("maj7").intervals ('1P', '3M', '5P', '7M') ChordType.get("maj7").quality 'Major'
Source parity: @tonaljs/chord-type
get ¶
Look up a chord type by name, alias, set number, or chroma string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
Any
|
A lookup key. May be a full name, alias, integer set number, or 12-bit chroma string. |
required |
Returns:
| Type | Description |
|---|---|
ChordType
|
A |
Example
from tonal_py import ChordType ChordType.get("maj7").intervals ('1P', '3M', '5P', '7M') ChordType.get("M7").intervals # alias resolves to same chord ('1P', '3M', '5P', '7M') ChordType.get("nonexistent").empty True
Source code in src/tonal_py/chord_type.py
names ¶
Get the full names of every named chord type.
Filters out entries that have only aliases (no full name set).
Example
from tonal_py import ChordType "major seventh" in ChordType.names() True
Source code in src/tonal_py/chord_type.py
symbols ¶
Get the primary symbol (first alias) of every chord type with one.
Example
from tonal_py import ChordType "maj7" in ChordType.symbols() True
Source code in src/tonal_py/chord_type.py
keys ¶
Return every key in the lookup index (names, aliases, set nums, chromas).
Useful for debugging or sanity-checking the dictionary.
all ¶
Return all 106 chord types as a fresh list.
Example
from tonal_py import ChordType len(ChordType.all()) 106
remove_all ¶
Clear the entire chord dictionary.
After calling this, all get lookups return NO_CHORD_TYPE until
add is called or _seed() repopulates from the original CHORDS
table. Useful when defining a project-specific custom vocabulary.
Mutates module-level state
This affects everything that uses ChordType lookups, including
Chord.get. Tests that mutate should restore via _seed().
Source code in src/tonal_py/chord_type.py
add ¶
Add a chord type to the dictionary.
The new chord is indexed by its full name (if provided), set number, chroma, and every alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intervals
|
list[str]
|
List of interval names (e.g. |
required |
aliases
|
list[str]
|
Symbol aliases (e.g. |
required |
full_name
|
str | None
|
Optional canonical full name. |
None
|
Example
from tonal_py import ChordType ChordType.add(["1P", "3M", "5P", "7M"], ["mytest"], "test major7") ChordType.get("mytest").quality 'Major'
Cleanup so doctest doesn't leave state behind¶
ChordType.remove_all() from tonal_py.chord_type import _seed _seed()
Source code in src/tonal_py/chord_type.py
add_alias ¶
Index chord under an additional alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chord
|
ChordType
|
An existing |
required |
alias
|
str
|
A new alias string to register. |
required |