The MIDI port is an abstraction of classes representing MIDI in/output devices. A MIDI port represents a single MIDI connection (carrying 16 MIDI channels). For multi-port MIDI sofware systems or devices (as MidiShare) one FTS MIDI port object should represent one (virtual or physical) MIDI port.
MIDI ports are FTS objects.
Various i/o objects can refer to an FTS MIDI port in order to receive MIDI events (listeners) or send events to a virtual or physical MIDI port. MIDI port listeners can be registered for a specific MIDI channel and note or contoller number.
If an i/o object refers to a MIDI port object by a named variable, the same program (patch) can be configured for completely different setups simply by redefining the MIDI port object defining the variable. Different MIDI ports are implemented for different platforms and MIDI i/o APIs as well as for other devices or protocols implementing standard MIDI events.
The API documented by this module permits to implement MIDI port classes. It contains the MIDI port structure itself and the initialization functions for the FTS class implementing an FTS MIDI port: fts_midiport_class_init(), fts_midiport_init() and fts_midiport_delete().
A MIDI port class allowing MIDI input, calls fts_midiport_set_input() in the objects initialization and uses the provided input functions (e.g. fts_midiport_input_note()) in the routines handling incoming MIDI data. These functions propagate the incoming MIDI events to the listening i/o objects refering to the MIDI port.
For the output a MIDI port class must implement an output function for each type of MIDI events. The output functions are bundeled into a structure (fts_midiport_output_functions_t) and declared by fts_midiport_set_output() in the objects initialization.
|
MIDI port output functions.
This is the structure of output functions to be implemented by a MIDI port class. It contains one function for each type of MIDI event. The system exclusive output is handled by two functions: The
struct fts_midiport_output_functions { fts_midiport_poly_fun_t note; fts_midiport_poly_fun_t poly_pressure; fts_midiport_poly_fun_t control_change; fts_midiport_channel_fun_t program_change; fts_midiport_channel_fun_t channel_pressure; fts_midiport_channel_fun_t pitch_bend; fts_midiport_sysex_byte_fun_t sysex_byte; fts_midiport_sysex_flush_fun_t sysex_flush; }; |
|
The FTS MIDI port structure. The FTS MIDI port "inherits" from FTS object. The structure fts_midiport_t itself must be included by a class implementing a MIDI port:
typedef struct my_midiport { fts_midiport_t port; ... } my_midiport_t;
A MIDI port class must call |
|
Initialize a class implementing an FTS MIDI port.
|
|
Free a MIDI port structures temporary buffers.
|
|
Initialize a MIDI port structure.
|
|
Call channel pressure change event listeners of the MIDI port.
|
|
Call controller change event listeners of the MIDI port.
|
|
Call all note event listeners of the MIDI port. For each incoming MIDI event a function is called by the object implementing an MIDI port, which calls all listeners for a given MIDI channel and (if any) note or controller number.
|
|
Call system exclusive data event listeners of the MIDI port.
|
|
Call poly pressure change event listeners of the MIDI port.
|
|
Call program change event listeners of the MIDI port.
|
|
Add byte to the MIDI port's internal sysex buffer.
|
|
Call system exclusive data event listeners of the MIDI port with the data of the internal buffer.
|
|
Declare initialized MIDI port as input.
|
|
Declare an initialized MIDI port as output and assign it's output functions.
|