Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Public Member Functions | List of all members
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 ()
 
void setSysexCallback (void(*newCallback)(midi_byte_t, void *), void *arg=nullptr)
 
bool isSysexCallbackEnabled ()
 
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.
Examples:
MIDI/render.cpp.
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.

void MidiParser::setSysexCallback ( void(*)(midi_byte_t, void *)  newCallback,
void *  arg = nullptr 
)
inline

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

The callback will be called with two arguments: callback(midi_byte_t byte, void* arg)

To signal the end of a sysex transmission, byte 0xF0 will be passed to the callback. In order to deactivate the callback, call this method with nullptr as the first argument.

Parameters
newCallbackthe callback function.
argthe third argument to be passed to the callback function.
Examples:
MIDI/render.cpp.
bool MidiParser::isSysexCallbackEnabled ( )
inline

Checks whether there is a callback currently set to be called every time a new sysex byte 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.

Returns
a copy of the oldest message in the buffer

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