Spaces:
Sleeping
Sleeping
File size: 1,759 Bytes
9c7e38e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | """
Global configuration for the classical music grid Transformer.
"""
# =========================
# Grid and tempo constants
# =========================
# Time grid
STEPS_PER_BAR: int = 8
INPUT_BARS: int = 3
INPUT_STEPS: int = INPUT_BARS * STEPS_PER_BAR # 24
# Pitch grid
PITCHES_MELODIC: int = 12 # one octave: 12 pitch classes
PITCHES_PERC: int = 3 # e.g., Kick, Snare, Hi-hat
# Instrument families (for clarity / future use)
N_FAMILIES: int = 4 # Strings, Woodwinds, Brass, Percussion
# Tempo and meter
TEMPO_BPM: int = 120
BEATS_PER_BAR: int = 4 # assuming 4/4 time
# Derived timing values
SECONDS_PER_BEAT: float = 60.0 / TEMPO_BPM
SECONDS_PER_BAR: float = BEATS_PER_BAR * SECONDS_PER_BEAT
SECONDS_PER_STEP: float = SECONDS_PER_BAR / STEPS_PER_BAR
# =========================
# Model hyperparameters
# =========================
# Transformer dimensions
D_MODEL: int = 256 # hidden size
N_LAYERS: int = 3 # number of Transformer encoder layers (2–4 is reasonable)
N_HEADS: int = 4 # attention heads
FFN_DIM: int = 512 # feed-forward inner dimension
DROPOUT: float = 0.1 # dropout rate
# Input feature size per time step:
# Strings (12) + Woodwinds (12) + Brass (12) + Percussion (3) = 39
INPUT_FEATURES: int = (3 * PITCHES_MELODIC) + PITCHES_PERC # 39
# =========================
# Sampling and constraints
# =========================
# Bar-level similarity threshold (0–1); above this, bar is considered "too similar"
BAR_SIMILARITY_THRESHOLD: float = 0.9
# Maximum number of resampling attempts per bar before accepting anyway
MAX_RESAMPLE_ATTEMPTS_PER_BAR: int = 5
# Minimum number of instrument families that must be active (have ≥1 note) per bar
MIN_ACTIVE_FAMILIES_PER_BAR: int = 2 |