How Synths Use Scala Files to Remap MIDI Pitch
Modern software synthesizers utilize Scala files to break free from
the traditional 12-tone equal temperament (12-TET) system, enabling
microtonal and alternative tunings. By reading the mathematical pitch
definitions stored within a .scl file—often paired with a
keyboard mapping .kbm file—the synthesizer intercepts
incoming standard MIDI note numbers and dynamically recalculates the
fundamental frequency assigned to each key before passing it to the
audio generation engine.
Structure of a Scala File
A Scala (.scl) file is a plain-text document defining an
arbitrary musical scale. Its structure consists of:
- A short text description of the scale.
- The number of notes per scale period (often an octave, though it can be any interval).
- A list of pitch values defined either in cents
(represented as floating-point decimals, such as
1200.0for an octave or701.955for a pure fifth) or ratios (represented as fractions, such as2/1or3/2).
The Role of Keyboard Mapping (.kbm)
While a .scl file defines the interval relationships of
a scale, it does not specify where those intervals fall on a physical
MIDI keyboard. For this, synthesizers look for an accompanying Keyboard
Mapping (.kbm) file. The .kbm file
provides:
- The Root MIDI Note: The reference key (e.g., MIDI note 69 / A4).
- The Base Frequency: The exact tuning frequency for that reference note in Hertz (e.g., 440.0 Hz).
- Key Assignments: Explicit routing of specific MIDI note numbers to scale degrees, allowing scales with fewer or more than 12 notes per octave to be mapped linearly, grouped to white keys only, or configured cyclically across standard 88-key controllers.
If no .kbm file is loaded, the software defaults to an
internal mapping—typically anchoring note 60 (Middle C) or note 69
(A440) as the root and mapping scale steps sequentially upward and
downward across adjacent MIDI keys.
The Real-Time Pitch Conversion Pipeline
When a user plays a key on a MIDI controller, the software synthesizer processes the tuning change through a deterministic digital signal processing (DSP) pipeline:
- Event Interception: The synthesizer receives a
standard MIDI
Note-Onevent carrying an integer note number from 0 to 127. - Table Lookup: Instead of applying the standard 12-TET mathematical formula (\(f = 440 \times 2^{(m - 69)/12}\)), the synth’s tuning engine queries the internal lookup table generated from the loaded Scala file.
- Period and Degree Calculation: The engine calculates which scale step the MIDI note corresponds to and how many scale periods (octaves or non-octave cycle lengths) away from the base reference key it lies.
- Frequency Synthesis: The synth computes the exact target frequency using the accumulated ratio or cent offsets. If an interval is specified in cents, the frequency conversion uses \(f = f_{\text{ref}} \times 2^{(\text{cents} / 1200)}\). If specified as a rational fraction (\(a/b\)), the synthesizer directly multiplies the base frequency by \((a/b)\).
- Oscillator Frequency Assignment: The resulting frequency value is delivered directly to the digital oscillator’s phase accumulator for that voice.
Unlike legacy hardware workarounds that relied on sending global MIDI Pitch Bend messages—which constrained polyphonic performance by bending all notes simultaneously—modern software instruments perform this pitch remapping at the internal per-voice DSP level, allowing fully polyphonic microtonal playback.