Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
Loading...
Searching...
No Matches
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

Member Function Documentation

◆ enableParser()

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.

◆ getParser()

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.

◆ setParserCallback()

void Midi::setParserCallback ( void(* callback )(MidiChannelMessage, void *),
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.

◆ readFrom()

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
Communication/MIDI/render.cpp.

◆ writeTo()

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

◆ getInput()

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

◆ writeOutput() [1/2]

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

◆ writeOutput() [2/2]

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

◆ getMidiParser()

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

◆ createAllPorts()

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()

◆ destroyPorts()

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

Closes a vector of ports.


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