Wohlstand / libADLMIDI

A Software MIDI Synthesizer library with OPL3 (YMF262) emulator
GNU Lesser General Public License v3.0
174 stars 17 forks source link

Add MIDI Tuning Standard (MTS) support #282

Open OpenSourceAnarchist opened 1 month ago

OpenSourceAnarchist commented 1 month ago

Timidity++ already supports MTS, but I was really hoping it could be added to SCC (edmidi), opnmidi, and adlmidi. Technically for my purposes I only need real-time single note change (bank/no bank). See https://sourceforge.net/p/timidity/git/ci/master/tree/doc/C/README.mts and https://sourceforge.net/p/timidity/git/ci/master/tree/timidity/playmidi.c#l8138 for their implementation, along with the tuning table here: https://sourceforge.net/p/timidity/git/ci/master/tree/timidity/tables.c#l58.

This allows for fine-grain control of individual note frequencies, and then channel-level effects take precedence after. This is extremely useful for microtonal midi files.

As an extreme case, attached is a midi file where "it selects bank 0, prog 0 (piano) to channel 0 and then proceeds to play a number of chords with four notes in each of them. Each chord is played via the MIDI notes 124, 125, 126 and 127. And before each chord is played, there is a SysEx message that uses MTS to assign new frequencies (in the lower, audible range) to those four MIDI note values via tuning bank 0, tuning prog 0 (from now on abbreviated as tuning 0/0)." (from https://github.com/FluidSynth/fluidsynth/issues/102#issuecomment-801508582)

mts.zip

Wohlstand commented 1 month ago

Looks interesting, I need to learn this deeper.