File interface for Fluidsynth ============================= MIDI libraries can be a pain. In some cases, a simpler API is better. Device files are a simple way to expose MIDI devices, which is how OSS does it. Playing raw MIDI data with fluidsynth ------------------------------------- If you have a program generating a MIDI stream, you can play it back in Fluidsynth like so: $ ./yourprogram | fluidsynth -is -a alsa \ -o midi.driver=oss \ -o midi.oss.device=/dev/stdin \ /path/to/your/soundfont.sf2 This works because the OSS MIDI API is a device file that simply consumes and produces MIDI bytes as-is. An application using OSS could use another file stream as its source. Instead of stdin, one could read from a named pipe: $ mkfifo /home/you/midipipe $ ./yourprogram | fluidsynth -is -a alsa \ -o midi.driver=oss \ -o midi.oss.device=/home/you/midipipe \ /path/to/your/soundfont.sf2 Reading/writing raw MIDI data as byte streams from/to devices ------------------------------------------------------------- TBD, Alsa OSS emulation, amidi... Quick notes about MIDI ---------------------- - Note on with velocity 0 should be treated as note off. - System real-time messages may at any time interrupt a longer message. - Status bytes only need to be sent once for any sequence of data bytes for that same status. For example, a note-on status byte for a particular channel may be followed by any number of key-velocity data byte pairs. - A status byte should reset any internal parsing state: the receiver should be able to handle an interrupted message. For example, a note-on status followed by only one data byte, then a new status byte is OK and should be handled by the receiver.