olofson / audiality2

A realtime scripted modular audio engine for video games and musical applications.
http://audiality.org/
zlib License
80 stars 5 forks source link

Standardized MIDI handler program #317

Open olofson opened 7 years ago

olofson commented 7 years ago

The "interface" of the miditest*.a2s examples currently looks like this:

export Song(P V=1 L=0)
{
    [...]
    // MIDI handler entry point
    7(Msg Ch Arg1 Arg2) {
        [...]
        if Msg == MIDI.NOTEOFF {
            [...]
        } else if Msg == MIDI.NOTEON {
            [...]
        } else if Msg == MIDI.CONTROLCHANGE {
            [...]
        } else [...]
            [...]
    }
}

The use of message 7 for MIDI is currently hardwired in the MIDI driver, and there's no API for changing it. However, there's no standardized arguments for the MIDI handler program!

The L (loop) argument is of course irrelevant for MIDI handlers, but the P and V arguments (similar to what's used for the "sort of" standardized instruments) make a lot of sense; transpose and volume, obviously.

It might make sense to also recommend that MIDI handlers implement some other message handlers:

Finally, it would be nice if there was a standard name for the "main" MIDI handler programs in an .a2s file, similar to the Song program for songs, so that a2play can autodetect it, instead of requiring the -M switch.