arduino-midi
Loading...
Searching...
No Matches
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
midi::MidiBleParser Class Reference

A simple Midi Parser for BLE Midi messages that calls the corresponding events. More...

#include <MidiBleParser.h>

Inheritance diagram for midi::MidiBleParser:
midi::MidiParser

Public Member Functions

 MidiBleParser (MidiAction *MidiAction, int channelFilter=-1)
 Constructor with the MidiAction and an optional channel filter (-1 = all channels)
 
void begin (MidiAction *MidiAction, int filter_channel=-1)
 Assigns the MidiAction, optionally defines a channel filter (-1 = all channels) and resets the parser state.
 
virtual void onChannelPressure (uint8_t channel, uint8_t pressure)
 Channel pressure.
 
virtual void onCommand (uint8_t channel, uint8_t status, uint8_t p1, uint8_t p2)
 Called for each complete channel message: dispatches it to the on...() methods.
 
virtual void onControlChange (uint8_t channel, uint8_t controller, uint8_t value)
 Control change.
 
virtual void onNoteOff (uint8_t channel, uint8_t note, uint8_t velocity)
 Note off or note on with velocity 0.
 
virtual void onNoteOn (uint8_t channel, uint8_t note, uint8_t velocity)
 Note on with velocity > 0.
 
virtual void onPitchBend (uint8_t channel, uint8_t value)
 7 bit pitch bend (0..127): not called by the parser any more, use onPitchBend14()
 
virtual void onPitchBend14 (uint8_t channel, uint16_t value)
 14 bit pitch bend: 0..16383, center is 8192
 
virtual void onPolyPressure (uint8_t channel, uint8_t note, uint8_t pressure)
 Polyphonic key pressure.
 
virtual void onProgramChange (uint8_t channel, uint8_t program)
 Program change.
 
virtual void onRead (BLECharacteristic *pCharacteristic)
 Callback function to support a read request.
 
virtual void onWrite (BLECharacteristic *pCharacteristic)
 Parses the BLE Midi packet which was written to the characteristic.
 
void parse (const uint8_t *msg, int len)
 Parse a standard Midi byte stream (supports running status)
 
void parseBle (const uint8_t *msg, int len)
 Parse a BLE Midi packet (header and timestamp bytes are removed)
 
void parseByte (uint8_t byte)
 Parse a single byte of a standard Midi byte stream.
 
void reset ()
 Resets the parser state (e.g. running status)
 

Static Protected Member Functions

static uint8_t dataLength (uint8_t status)
 Number of data bytes for a channel voice status byte.
 

Protected Attributes

uint8_t data [2] = {0, 0}
 
uint8_t data_count = 0
 
int filter_channel = -1
 
bool in_sysex = false
 
MidiAction * p_MidiAction = nullptr
 
uint8_t running_status = 0
 

Detailed Description

A simple Midi Parser for BLE Midi messages that calls the corresponding events.

In this implementation the handler just passes the noteOn and noteOff to the MidiAction.

http://www.hangar42.nl/wp-content/uploads/2017/10/BLE-MIDI-spec.pdf

by Phil Schatzmann

Member Function Documentation

◆ onRead()

void midi::MidiBleParser::onRead ( BLECharacteristic *  pCharacteristic)
virtual

Callback function to support a read request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.

◆ onWrite()

void midi::MidiBleParser::onWrite ( BLECharacteristic *  pCharacteristic)
virtual

Parses the BLE Midi packet which was written to the characteristic.

Callback function to support a write request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.

◆ parse()

void midi::MidiParser::parse ( const uint8_t *  msg,
int  len 
)
inherited

Parse a standard Midi byte stream (supports running status)

Parse a standard midi byte stream. The state is kept between calls, so messages which are split over multiple calls are supported.

Parameters
[in]msgbyte stream
[in]lenlength of the msg

◆ parseBle()

void midi::MidiParser::parseBle ( const uint8_t *  msg,
int  len 
)
inherited

Parse a BLE Midi packet (header and timestamp bytes are removed)

Parse a BLE midi packet: header, then [timestamp] status data... A timestamp followed by a data byte indicates running status.

Parameters
[in]msgBLE packet
[in]lenlength of the msg

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