jMax documentation
Main Page   Modules   File List  

MIDI port

The MIDI port abstraction (fts_midiport_t). More...

The FTS MIDI port structure

Initializing a MIDI port

Initialization of classes and objects implementing a MIDI port.

Handling incoming MIDI events

Functions to call the associated MIDI port listeners on incoming events.

Typedefs


Detailed Description

The MIDI port abstraction (fts_midiport_t).

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.


Typedef Documentation

fts_midiport_output_functions_t
 

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 sysex_byte function is adding a byte to an internal buffer. If a sysex block is completed the buffer is flushed and sent out with the exact time tag by sysex_flush.

   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;
   };

fts_midiport_t
 

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 fts_midiport_init() and fts_midiport_delete() in the objects init and delete Methods.


Function Documentation

void fts_midiport_class_init ( fts_class_t * cl )
 

Initialize a class implementing an FTS MIDI port.

Parameters:
cl   FTS class

void fts_midiport_delete ( fts_midiport_t * port )
 

Free a MIDI port structures temporary buffers.

Parameters:
port   the MIDI port
Warning:
This function doesn't free the MIDI port structure itself.

void fts_midiport_init ( fts_midiport_t * port )
 

Initialize a MIDI port structure.

Parameters:
port   the MIDI port

void fts_midiport_input_channel_pressure ( fts_midiport_t * port,
int channel,
int value,
double time )
 

Call channel pressure change event listeners of the MIDI port.

See also:
fts_midiport_input_note()

void fts_midiport_input_control_change ( fts_midiport_t * port,
int channel,
int number,
int value,
double time )
 

Call controller change event listeners of the MIDI port.

See also:
fts_midiport_input_note()

void fts_midiport_input_note ( fts_midiport_t * port,
int channel,
int number,
int value,
double time )
 

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.

Parameters:
port   the MIDI port itself
channel   the MIDI channel of the incoming event
number   the MIDI note or controller number of the incoming event
value   the velocity, pressure, controller, program or pitch bend value of the incoming event
time   an offset time of the incoming MIDI event (in msec) regarding the current logical (tick) time

void fts_midiport_input_pitch_bend ( fts_midiport_t * port,
int channel,
int value,
double time )
 

Call system exclusive data event listeners of the MIDI port.

See also:
fts_midiport_input_note()

void fts_midiport_input_poly_pressure ( fts_midiport_t * port,
int channel,
int number,
int value,
double time )
 

Call poly pressure change event listeners of the MIDI port.

See also:
fts_midiport_input_note()

void fts_midiport_input_program_change ( fts_midiport_t * port,
int channel,
int value,
double time )
 

Call program change event listeners of the MIDI port.

See also:
fts_midiport_input_note()

void fts_midiport_input_system_exclusive_byte ( fts_midiport_t * port,
int value )
 

Add byte to the MIDI port's internal sysex buffer.

See also:
fts_midiport_input_system_exclusive_call()

void fts_midiport_input_system_exclusive_call ( fts_midiport_t * port,
double time )
 

Call system exclusive data event listeners of the MIDI port with the data of the internal buffer.

See also:
fts_midiport_input_system_exclusive_byte()

void fts_midiport_set_input ( fts_midiport_t * port )
 

Declare initialized MIDI port as input.

Parameters:
port   the MIDI port

void fts_midiport_set_output ( fts_midiport_t * port,
fts_midiport_output_functions_t * functions )
 

Declare an initialized MIDI port as output and assign it's output functions.

Parameters:
port   the MIDI port
functions   structure of implemented output functions


jMax server kernel documentation (FTS 2.5)
Generated 4 Jul 2001 Wed Jul 4 13:07:06 2001 by Doxygen 1.2.3 written by Dimitri van Heesch.