AbcNotation¶
abc_notation ¶
ABC notation ↔ scientific notation conversions.
The AbcNotation namespace converts between ABC notation
(the music notation language used in folk-music tooling) and the
scientific note names used elsewhere in tonal.
ABC notation rules in brief:
- Uppercase letters (
C,D, ...) are octave 4. - Lowercase letters (
c,d, ...) are octave 5. - Apostrophes (
') raise an octave each. - Commas (
,) lower an octave each. - Underscores (
_) are flats; carets (^) are sharps.
Example
from tonal_py import AbcNotation AbcNotation.abc_to_scientific_notation("c") # lowercase = oct 5 'C5' AbcNotation.abc_to_scientific_notation("_b") # _ = flat 'Bb5' AbcNotation.scientific_to_abc_notation("Bb4") '_B'
Source parity: @tonaljs/abc-notation
tokenize ¶
Split an ABC note into (accidentals, letter, octave_marks).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
An ABC note string. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str, str]
|
|
Example
from tonal_py import AbcNotation AbcNotation.tokenize("b") ('', 'b', '') AbcNotation.tokenize("C,") ('', 'C', ',') AbcNotation.tokenize("garbage") ('', '', '')
Source code in src/tonal_py/abc_notation.py
abc_to_scientific_notation ¶
Convert an ABC note to scientific notation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
ABC notation note (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Scientific notation note name (e.g. |
str
|
Empty string for invalid input. |
Example
from tonal_py import AbcNotation AbcNotation.abc_to_scientific_notation("c") 'C5' AbcNotation.abc_to_scientific_notation("C") 'C4' AbcNotation.abc_to_scientific_notation("_b") 'Bb5' AbcNotation.abc_to_scientific_notation("C,") 'C3' AbcNotation.abc_to_scientific_notation("c'") 'C6'
Source code in src/tonal_py/abc_notation.py
scientific_to_abc_notation ¶
Convert a scientific notation note to ABC notation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
Scientific notation note (must include octave). |
required |
Returns:
| Type | Description |
|---|---|
str
|
ABC notation. Empty string for invalid input or pitch classes |
str
|
without octaves. |
Example
from tonal_py import AbcNotation AbcNotation.scientific_to_abc_notation("C5") 'c' AbcNotation.scientific_to_abc_notation("Bb4") '_B' AbcNotation.scientific_to_abc_notation("C") # no octave ''
Source code in src/tonal_py/abc_notation.py
transpose ¶
Transpose an ABC-notation note by an interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note
|
str
|
ABC notation note. |
required |
interval
|
str
|
Interval string (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Transposed note in ABC notation. |
Example
from tonal_py import AbcNotation AbcNotation.transpose("C", "M3") 'E' AbcNotation.transpose("c", "P5") 'g'
Source code in src/tonal_py/abc_notation.py
distance ¶
Find the interval between two ABC-notation notes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_note
|
str
|
ABC notation note. |
required |
to_note
|
str
|
ABC notation note. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Interval name (e.g. |
Example
from tonal_py import AbcNotation AbcNotation.distance("C", "e") '10M'