feat: extend time signature support to 9 metres (5/4, 7/4, 7/8, 9/8)

Add 5/4, 7/4, 7/8, 9/8 to _VALID_TIMES and VOCAB (TIME_* tokens).
Vocab size grows from 81 to 85 tokens. _parse_metre in the McGill
converter assigns subdivision=8 to 7/8 and 9/8. Spec bumped to v2.2.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 00:37:05 +03:00
parent 4fd8ece170
commit 3cd9c29d9f
5 changed files with 40 additions and 17 deletions
+5 -2
View File
@@ -125,7 +125,10 @@ _FUNCTION_MAP: dict[str, str] = {
"other": "other",
}
_VALID_TIMES: frozenset[str] = frozenset({"4/4", "3/4", "6/8", "2/4", "12/8"})
_VALID_TIMES: frozenset[str] = frozenset({
"4/4", "3/4", "6/8", "2/4", "12/8",
"5/4", "7/4", "7/8", "9/8",
})
_MAJOR_QUALITIES: frozenset[str] = frozenset(
{"maj", "maj7", "6", "add9", "aug", "sus2", "sus4", "7sus4", "aug7"}
@@ -436,7 +439,7 @@ def _parse_metre(metre: str) -> tuple[Optional[str], int]:
"""Parse metre string → (time_sig, subdivision). Returns (None, 0) if unsupported."""
m = metre.strip()
if m in _VALID_TIMES:
sub = 8 if m in ("6/8", "12/8") else 4
sub = 8 if m in ("6/8", "12/8", "7/8", "9/8") else 4
return m, sub
try:
mapping = {4: ("4/4", 4), 3: ("3/4", 4), 2: ("2/4", 4)}
+6 -2
View File
@@ -67,7 +67,10 @@ _FLAT_TO_SHARP: dict[str, str] = {
"Gb": "F#", "Ab": "G#", "Bb": "A#",
}
_VALID_TIMES: frozenset[str] = frozenset({"4/4", "3/4", "6/8", "2/4", "12/8"})
_VALID_TIMES: frozenset[str] = frozenset({
"4/4", "3/4", "6/8", "2/4", "12/8",
"5/4", "7/4", "7/8", "9/8",
})
_VALID_FUNCTIONS: frozenset[str] = frozenset({
"verse", "prechorus", "chorus", "bridge",
"intro", "outro", "interlude", "other",
@@ -83,8 +86,9 @@ VOCAB: list[str] = [
"<BOS>", "<EOS>", "<PAD>", "<UNK>",
# Mode (2)
"MODE_major", "MODE_minor",
# Time signature (5)
# Time signature (9)
"TIME_4/4", "TIME_3/4", "TIME_6/8", "TIME_2/4", "TIME_12/8",
"TIME_5/4", "TIME_7/4", "TIME_7/8", "TIME_9/8",
# Subdivision (2)
"SUB_4", "SUB_8",
# Style (5)