ScaleType¶
scale_type ¶
The scale type dictionary — 92 scale definitions.
The ScaleType namespace exposes an in-memory dictionary of 92 scale
types, each indexed by name, aliases, set number, and chroma. Includes
the seven diatonic modes, jazz scales (melodic minor, harmonic minor,
bebop, diminished, altered), pentatonics, hexatonics, exotic scales
(messiaen modes, ragas, hungarian, persian), and the chromatic scale.
So ScaleType.get("major"), ScaleType.get("ionian"),
ScaleType.get(2773), and ScaleType.get("101011010101") all return
the same ScaleType.
Like ChordType, the dictionary is mutable —
add extends it.
Example
from tonal_py import ScaleType len(ScaleType.all()) 92 ScaleType.get("major").chroma '101011010101' ScaleType.get("aeolian").name # alias resolves to "minor" 'minor'
Source parity: @tonaljs/scale-type
get ¶
Look up a scale type by name, alias, set number, or chroma string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
Any
|
A lookup key. Name, alias, integer set number, or 12-bit chroma string. |
required |
Returns:
| Type | Description |
|---|---|
ScaleType
|
A |
Example
from tonal_py import ScaleType ScaleType.get("major").intervals ('1P', '2M', '3M', '4P', '5P', '6M', '7M') ScaleType.get("ionian").name # alias resolves to "major" 'major' ScaleType.get("garbage").empty True
Source code in src/tonal_py/scale_type.py
names ¶
Return all 92 scale names in dictionary order.
Example
from tonal_py import ScaleType "major" in ScaleType.names() True "lydian" in ScaleType.names() True
Source code in src/tonal_py/scale_type.py
all ¶
Return all 92 scale types as a fresh list.
Example
from tonal_py import ScaleType len(ScaleType.all()) 92
add ¶
Add a scale type to the dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intervals
|
list[str]
|
List of interval names (e.g. |
required |
name
|
str
|
The full name (always required for scales). |
required |
aliases
|
tuple[str, ...] | list[str]
|
Optional alias names. |
()
|
Returns:
| Type | Description |
|---|---|
ScaleType
|
The newly-created |
Example
from tonal_py import ScaleType ScaleType.add(["1P", "3M", "5P"], "test triad scale", ["tts"]) ScaleType(empty=False, name='test triad scale', set_num=2192, ...) ScaleType.get("tts").name 'test triad scale'
Cleanup¶
ScaleType.remove_all() from tonal_py.scale_type import _seed _seed()