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 | Static Public Member Functions | List of all members
Midi Class Reference

Public Member Functions

void setup ()
 
void cleanup ()
 
void enableParser (bool enable)
 
MidiParsergetParser ()
 
void setParserCallback (void(*callback)(MidiChannelMessage, void *), void *arg=NULL)
 
int readFrom (const char *port)
 
int writeTo (const char *port)
 
int getInput ()
 
int writeOutput (midi_byte_t byte)
 
int writeOutput (midi_byte_t *bytes, unsigned int length)
 
int writeMessage (midi_byte_t statusCode, midi_byte_t channel, midi_byte_t dataByte)
 
int writeMessage (midi_byte_t statusCode, midi_byte_t channel, midi_byte_t dataByte1, midi_byte_t dataByte2)
 
int writeMessage (const MidiChannelMessage &msg)
 
int writeNoteOff (midi_byte_t channel, midi_byte_t pitch, midi_byte_t velocity)
 
int writeNoteOn (midi_byte_t channel, midi_byte_t pitch, midi_byte_t velocity)
 
int writePolyphonicKeyPressure (midi_byte_t channel, midi_byte_t pitch, midi_byte_t pressure)
 
int writeControlChange (midi_byte_t channel, midi_byte_t controller, midi_byte_t value)
 
int writeProgramChange (midi_byte_t channel, midi_byte_t program)
 
int writeChannelPressure (midi_byte_t channel, midi_byte_t pressure)
 
int writePitchBend (midi_byte_t channel, uint16_t bend)
 
MidiParsergetMidiParser ()
 
bool isInputEnabled ()
 
bool isOutputEnabled ()
 

Static Public Member Functions

static midi_byte_t makeStatusByte (midi_byte_t statusCode, midi_byte_t dataByte)
 
static void createAllPorts (std::vector< Midi * > &ports, bool useParser=false)
 
static void destroyPorts (std::vector< Midi * > &ports)
 

Detailed Description

Examples:
Audio/FFT-phase-vocoder/render.cpp, and Communication/MIDI/render.cpp.

Member Function Documentation

void Midi::enableParser ( bool  enable)

Enable the input MidiParser.

If the parser is enabled, getInput() will return an error code. Midi messages should instead be retrieved via, e.g.: getMidiParser()->getNextChannelMessage();

Parameters
enabletrue to enable the input MidiParser, false to disable it.
Examples:
Communication/MIDI/render.cpp.
MidiParser * Midi::getParser ( )

Get access to the input parser in use, if any.

Returns
a pointer to the instance of MidiParser, if currently enabled, zero otherwise.
Examples:
Communication/MIDI/render.cpp.
void Midi::setParserCallback ( void(*)(MidiChannelMessage, void *)  callback,
void *  arg = NULL 
)
inline

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

Internally, it calls enableParser() and the MidiParser::setCallback();

Parameters
callbackthe callback function.
argthe second argument to be passed to the callback function.
Examples:
Audio/FFT-phase-vocoder/render.cpp.
int Midi::readFrom ( const char *  port)

Open the specified input Midi port and start reading from it.

Parameters
portMidi port to open
Returns
1 on success, -1 on failure
Examples:
Audio/FFT-phase-vocoder/render.cpp, and Communication/MIDI/render.cpp.
int Midi::writeTo ( const char *  port)

Open the specified output Midi port and prepares to write to it.

Parameters
portMidi port to open
Returns
1 on success, -1 on failure
Examples:
Communication/MIDI/render.cpp.
int Midi::getInput ( )

Get received midi bytes, one at a time.

Returns
-1 if no new byte is available, -2 on error, the oldest not yet retrieved midi byte otherwise
int Midi::writeOutput ( midi_byte_t  byte)

Writes a Midi byte to the output port

Parameters
bytethe Midi byte to write
Returns
1 on success, 0 if output is not enabled, -1 on error
Examples:
Communication/MIDI/render.cpp.
int Midi::writeOutput ( midi_byte_t *  bytes,
unsigned int  length 
)

Writes Midi bytes to the output port

Parameters
bytesan array of bytes to be written
lengthnumber of bytes to write
Returns
1 on success, 0 if output is not enabled, -1 on error
MidiParser* Midi::getMidiParser ( )

Gives access to the midi parser, if it has been activated.

Returns
a pointer to the midi parser if active, zero otherwise
void Midi::createAllPorts ( std::vector< Midi * > &  ports,
bool  useParser = false 
)
static

Opens all the existing MIDI ports, in the same order returned by the filesystem or Alsa. Ports open with this method should be closed with destroyPorts()

static void Midi::destroyPorts ( std::vector< Midi * > &  ports)
static

Closes a vector of ports.


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