Skip to main content

Module scala_kbm

Module scala_kbm 

Source
Expand description

Scala keyboard mapping (.kbm) parsing — clean-room from the open Scala format spec.

A .kbm maps MIDI key numbers onto scale degrees and anchors the whole tuning to a reference key/frequency. Grammar (comment lines begin with !; each field is the first token of its own non-comment line):

<map size>        number of keyboard-map entries; the pattern repeats every this many keys
<first MIDI>      first MIDI note to retune (0..127)
<last MIDI>       last MIDI note to retune (0..127)
<middle note>     the key that scale degree 0 (1/1) is mapped to
<reference note>  the key whose frequency is given below
<reference freq>  frequency (Hz) to tune the reference note to
<octave degree>   scale degree treated as the formal octave (usually the scale size)
<map 0>           `mapsize` lines follow, each a scale degree or `x` (key not mapped)
...

Cold path; the produced KbmMapping is fixed-size and Copy so it can feed the allocation-free tuning-table build.

Structs§

KbmMapping
A parsed Scala keyboard mapping. Fixed-size, Copy, heap-free.

Constants§

KBM_UNMAPPED
Sentinel in KbmMapping::mapping for a key that is not mapped to any scale degree (x).
MAX_KBM_ENTRIES
Upper bound on keyboard-map entries (a map cannot usefully exceed the 128 MIDI keys).

Functions§

parse_kbm
Parse Scala .kbm text into a fixed-size KbmMapping.