Skip to main content

Module mts

Module mts 

Source
Expand description

MIDI Tuning Standard (MTS) — clean-room from the open MMA spec.

Two concerns, both native and heap-free on the hot path:

  1. Tuning table. build_tuning_table combines a Scala SclScale and KbmMapping into a fixed [f64; 128] of key→frequency. note_frequency is an allocation-free, panic-free lookup into that table. Tuning is fully PARAMETERISED — the table is a function of the supplied scale + mapping; 12-TET is just one possible input, never hardcoded.

  2. Single Note Tuning Change SysEx (MTS sub-ID 0x02) — encode_single_note_tuning / decode_single_note_tuning. Frequency is carried as the MTS 3-byte value: a nearest equal-tempered semitone (MIDI note, 8.175799 Hz = note 0) plus a 14-bit fraction of 100 cents.

Structs§

SingleNoteTuning
A decoded single-note tuning change.

Constants§

SNTC_LEN
Byte length of a one-change Single Note Tuning Change SysEx.

Functions§

build_tuning_table
Build the 128-key frequency table from a scale + keyboard mapping, per MTS.
decode_single_note_tuning
Decode a one-change Single Note Tuning Change SysEx produced by encode_single_note_tuning.
encode_single_note_tuning
Encode a single-note tuning change as a 12-byte real-time SysEx: F0 7F <dev> 08 02 <program> 01 <note> <xx yy zz> F7.
note_frequency
Allocation-free, panic-free key→frequency lookup. note is masked into 0..128, so any u8 is valid; an unmapped key returns 0.0.