Mercurial > hg > beaglert
changeset 225:444f6028d6b1 mergingClockSync
Added documentation for Midi and MidiParser
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 08 Mar 2016 16:03:14 +0000 |
parents | 97faaf985164 |
children | af1e662400fc |
files | include/Midi.h |
diffstat | 1 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/include/Midi.h Tue Mar 08 15:49:42 2016 +0000 +++ b/include/Midi.h Tue Mar 08 16:03:14 2016 +0000 @@ -138,6 +138,20 @@ */ int parse(midi_byte_t* input, unsigned int length); + /** + * Sets the callback to call when a new MidiChannelMessage is available + * from the input port. + * + * In order to deactivate the callback, call this method with NULL as an + * 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. + * + * @param newCallback the callback function. This function + * should takes one argument: the MidiChannelMessage . + * + */ void setCallback(void (*newCallback)(MidiChannelMessage)){ messageReadyCallback = newCallback; if(newCallback != NULL){ @@ -147,10 +161,21 @@ } }; + /** + * Checks whether there is a callback currently set to be called + * every time a new input MidiChannelMessage is available from the + * input port. + */ bool isCallbackEnabled(){ return callbackEnabled; }; + /** + * Returns the number of unread MidiChannelMessage available from the + * input port. + * + */ + int numAvailableMessages(){ int num = (writePointer - readPointer + messages.size() ) % messages.size(); if(num > 0){ @@ -159,12 +184,15 @@ } return num; } + /** * 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. + * * @param type the type of the message to retrieve + * * @return a copy of the oldest message of the give type in the buffer */ MidiChannelMessage getNextChannelMessage(/*MidiMessageType type*/){ @@ -217,6 +245,15 @@ */ MidiParser* getParser(); + /** + * Sets the callback to call when a new MidiChannelMessage is available + * from the input port. + * + * Internally, it calls enableParser() and the MidiParser::setCallback(); + * + * @param newCallback the callback function. This function + * should takes one argument: the MidiChannelMessage . + */ void setParserCallback(void (*callback)(MidiChannelMessage)){ // if callback is not NULL, also enable the parser enableParser(callback != NULL); //this needs to be first, as it deletes the parser(if exists)