MidiParser Class Reference

Public Member Functions

int parse (midi_byte_t *input, unsigned int length)
 
void setCallback (void(*newCallback)(MidiChannelMessage, void *), void *arg=NULL)
 
bool isCallbackEnabled ()
 
int numAvailableMessages ()
 
MidiChannelMessage getNextChannelMessage ()
 

Member Function Documentation

int MidiParser::parse ( midi_byte_t *  input,
unsigned int  length 
)

Parses some midi messages.

Parameters
inputthe array to read from
lengththe maximum number of values available at the array
Returns
the number of bytes parsed
void MidiParser::setCallback ( void(*)(MidiChannelMessage, void *)  newCallback,
void *  arg = NULL 
)
inline

Sets the callback to call when a new MidiChannelMessage is available from the input port.

The callback will be called with two arguments: callback(MidiChannelMessage newMessage, void* arg)

In order to deactivate the callback, call this method with NULL as the first argument. While the callback is enabled, calling numAvailableMessages() and getNextChannelMessage() is still possible, but it will probably always return 0 as the callback is called as soon as a new message is available.

Parameters
newCallbackthe callback function.
argthe second argument to be passed to the callback function.
bool MidiParser::isCallbackEnabled ( )
inline

Checks whether there is a callback currently set to be called every time a new input MidiChannelMessage is available from the input port.

int MidiParser::numAvailableMessages ( )
inline

Returns the number of unread MidiChannelMessage available from the input port.

MidiChannelMessage MidiParser::getNextChannelMessage ( )
inline

Get the oldest channel message in the buffer.

If this method is called when numAvailableMessages()==0, then a message with all fields set to zero is returned.

Parameters
typethe type of the message to retrieve
Returns
a copy of the oldest message of the give type in the buffer

The documentation for this class was generated from the following file: