Utility class for MIDI over Bluetooth LE

Dependencies:   BLE_API mbed nRF51822

Embed: (wiki syntax)

« Back to documentation index

BLEMIDI Class Reference

BLEMIDI Class Reference

A class to communicate a BLE MIDI device. More...

#include <BLEMIDI.h>

Public Member Functions

 BLEMIDI (BLEDevice *device)
 Constructor.
 BLEMIDI (BLEDevice *dev, char *deviceName)
 Constructor with device name.
bool connected ()
 Check if a BLE MIDI device is connected.
void attachTuneRequest (void(*fn)())
 Attach a callback called when the `Tune Request` event is received.
void attachTimingClock (void(*fn)())
 Attach a callback called when the `Timing Clock` event is received.
void attachStart (void(*fn)())
 Attach a callback called when the `Start` event is received.
void attachContinue (void(*fn)())
 Attach a callback called when the `Continue` event is received.
void attachStop (void(*fn)())
 Attach a callback called when the `Stop` event is received.
void attachActiveSensing (void(*fn)())
 Attach a callback called when the `Active Sensing` event is received.
void attachReset (void(*fn)())
 Attach a callback called when the `Reset` event is received.
void attachnProgramChange (void(*fn)(uint8_t, uint8_t))
 Attach a callback called when the `Program Change` event is received.
void attachChannelAftertouch (void(*fn)(uint8_t, uint8_t))
 Attach a callback called when the `Channel Aftertouch` event is received.
void attachTimeCodeQuarterFrame (void(*fn)(uint8_t))
 Attach a callback called when the `Time Code Quarter Frame` event is received.
void attachSongSelect (void(*fn)(uint8_t))
 Attach a callback called when the `Song Select` event is received.
void attachNoteOff (void(*fn)(uint8_t, uint8_t, uint8_t))
 Attach a callback called when the `Note Off` event is received.
void attachNoteOn (void(*fn)(uint8_t, uint8_t, uint8_t))
 Attach a callback called when the `Note On` event is received.
void attachPolyphonicAftertouch (void(*fn)(uint8_t, uint8_t, uint8_t))
 Attach a callback called when the `Polyphonic Aftertouch` event is received.
void attachControlChange (void(*fn)(uint8_t, uint8_t, uint8_t))
 Attach a callback called when the `Control Change` event is received.
void attachPitchWheel (void(*fn)(uint8_t, uint16_t))
 Attach a callback called when the `Pitch Wheel` event is received.
void attachSongPositionPointer (void(*fn)(uint16_t))
 Attach a callback called when the `Song Position Pointer` event is received.
void attachSystemExclusive (void(*fn)(uint8_t *, uint16_t, bool))
 Attach a callback called when the `System Exclusive` event is received.
void sendTuneRequest ()
 Send a `Tune Request` event.
void sendTimingClock ()
 Send a `Timing Clock` event.
void sendStart ()
 Send a `Start` event.
void sendContinue ()
 Send a `Continue` event.
void sendStop ()
 Send a `Stop` event.
void sendActiveSensing ()
 Send a `Active Sensing` event.
void sendReset ()
 Send a `Reset` event.
void sendProgramChange (uint8_t channel, uint8_t program)
 Send a `Program Change` event.
void sendChannelAftertouch (uint8_t channel, uint8_t pressure)
 Send a `Channel Aftertouch` event.
void sendTimeCodeQuarterFrame (uint8_t timing)
 Send a `Time Code Quarter Frame` event.
void sendSongSelect (uint8_t song)
 Send a `Song Select` event.
void sendNoteOff (uint8_t channel, uint8_t note, uint8_t velocity)
 Send a `Note Off` event.
void sendNoteOn (uint8_t channel, uint8_t note, uint8_t velocity)
 Send a `Note On` event.
void sendPolyphonicAftertouch (uint8_t channel, uint8_t note, uint8_t pressure)
 Send a `Polyphonic Aftertouch` event.
void sendControlChange (uint8_t channel, uint8_t function, uint8_t value)
 Send a `Control Change` event.
void sendPitchWheel (uint8_t channel, uint16_t amount)
 Send a `Pitch Wheel` event.
void sendSongPositionPointer (uint16_t position)
 Send a `Song Position Pointer` event.
void sendSystemExclusive (uint8_t *sysex, uint16_t length)
 Send a `System Exclusive` event.
void onBleDisconnection (Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 Notifies BLE disconnection to this BLE MIDI instance.
void onBleConnection (Gap::Handle_t handle, Gap::addr_type_t type, const Gap::address_t addr, const Gap::ConnectionParams_t *params)
 Notifies BLE connection to this BLE MIDI instance.

Detailed Description

A class to communicate a BLE MIDI device.

Definition at line 27 of file BLEMIDI.h.


Constructor & Destructor Documentation

BLEMIDI ( BLEDevice *  device )

Constructor.

Definition at line 267 of file BLEMIDI.cpp.

BLEMIDI ( BLEDevice *  dev,
char *  deviceName 
)

Constructor with device name.

Definition at line 271 of file BLEMIDI.cpp.


Member Function Documentation

void attachActiveSensing ( void(*)()  fn )

Attach a callback called when the `Active Sensing` event is received.

Parameters:
ptrfunction pointer prototype: void onActiveSensing();

Definition at line 102 of file BLEMIDI.h.

void attachChannelAftertouch ( void(*)(uint8_t, uint8_t)  fn )

Attach a callback called when the `Channel Aftertouch` event is received.

Parameters:
ptrfunction pointer prototype: void onChannelAftertouch(uint8_t channel, uint8_t pressure);

Definition at line 132 of file BLEMIDI.h.

void attachContinue ( void(*)()  fn )

Attach a callback called when the `Continue` event is received.

Parameters:
ptrfunction pointer prototype: void onContinue();

Definition at line 82 of file BLEMIDI.h.

void attachControlChange ( void(*)(uint8_t, uint8_t, uint8_t)  fn )

Attach a callback called when the `Control Change` event is received.

Parameters:
ptrfunction pointer prototype: void onControlChange(uint8_t channel, uint8_t function, uint8_t value);

Definition at line 192 of file BLEMIDI.h.

void attachNoteOff ( void(*)(uint8_t, uint8_t, uint8_t)  fn )

Attach a callback called when the `Note Off` event is received.

Parameters:
ptrfunction pointer prototype: void onNoteOff(uint8_t channel, uint8_t note, uint8_t velocity);

Definition at line 162 of file BLEMIDI.h.

void attachNoteOn ( void(*)(uint8_t, uint8_t, uint8_t)  fn )

Attach a callback called when the `Note On` event is received.

Parameters:
ptrfunction pointer prototype: void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity);

Definition at line 172 of file BLEMIDI.h.

void attachnProgramChange ( void(*)(uint8_t, uint8_t)  fn )

Attach a callback called when the `Program Change` event is received.

Parameters:
ptrfunction pointer prototype: void onProgramChange(uint8_t channel, uint8_t program);

Definition at line 122 of file BLEMIDI.h.

void attachPitchWheel ( void(*)(uint8_t, uint16_t)  fn )

Attach a callback called when the `Pitch Wheel` event is received.

Parameters:
ptrfunction pointer prototype: void onPitchWheel(uint8_t channel, uint16_t amount);

Definition at line 202 of file BLEMIDI.h.

void attachPolyphonicAftertouch ( void(*)(uint8_t, uint8_t, uint8_t)  fn )

Attach a callback called when the `Polyphonic Aftertouch` event is received.

Parameters:
ptrfunction pointer prototype: void onPolyphonicAftertouch(uint8_t channel, uint8_t note, uint8_t pressure);

Definition at line 182 of file BLEMIDI.h.

void attachReset ( void(*)()  fn )

Attach a callback called when the `Reset` event is received.

Parameters:
ptrfunction pointer prototype: void onReset();

Definition at line 112 of file BLEMIDI.h.

void attachSongPositionPointer ( void(*)(uint16_t)  fn )

Attach a callback called when the `Song Position Pointer` event is received.

Parameters:
ptrfunction pointer prototype: void onSongPositionPointer(uint16_t position);

Definition at line 212 of file BLEMIDI.h.

void attachSongSelect ( void(*)(uint8_t)  fn )

Attach a callback called when the `Song Select` event is received.

Parameters:
ptrfunction pointer prototype: void onSongSelect(uint8_t song);

Definition at line 152 of file BLEMIDI.h.

void attachStart ( void(*)()  fn )

Attach a callback called when the `Start` event is received.

Parameters:
ptrfunction pointer prototype: void onStart();

Definition at line 72 of file BLEMIDI.h.

void attachStop ( void(*)()  fn )

Attach a callback called when the `Stop` event is received.

Parameters:
ptrfunction pointer prototype: void onStop();

Definition at line 92 of file BLEMIDI.h.

void attachSystemExclusive ( void(*)(uint8_t *, uint16_t, bool)  fn )

Attach a callback called when the `System Exclusive` event is received.

Parameters:
ptrfunction pointer prototype: void onSystemExclusive(uint8_t *sysex, uint16_t length, bool hasNextData);

Definition at line 222 of file BLEMIDI.h.

void attachTimeCodeQuarterFrame ( void(*)(uint8_t)  fn )

Attach a callback called when the `Time Code Quarter Frame` event is received.

Parameters:
ptrfunction pointer prototype: void onTimeCodeQuarterFrame(uint8_t timing);

Definition at line 142 of file BLEMIDI.h.

void attachTimingClock ( void(*)()  fn )

Attach a callback called when the `Timing Clock` event is received.

Parameters:
ptrfunction pointer prototype: void onTimingClock();

Definition at line 62 of file BLEMIDI.h.

void attachTuneRequest ( void(*)()  fn )

Attach a callback called when the `Tune Request` event is received.

Parameters:
ptrfunction pointer prototype: void onTuneRequest();

Definition at line 52 of file BLEMIDI.h.

bool connected (  )

Check if a BLE MIDI device is connected.

Returns:
true if a midi device is connected

Definition at line 322 of file BLEMIDI.cpp.

void onBleConnection ( Gap::Handle_t  handle,
Gap::addr_type_t  type,
const Gap::address_t  addr,
const Gap::ConnectionParams_t *  params 
)

Notifies BLE connection to this BLE MIDI instance.

Definition at line 27 of file BLEMIDI.cpp.

void onBleDisconnection ( Gap::Handle_t  handle,
Gap::DisconnectionReason_t  reason 
)

Notifies BLE disconnection to this BLE MIDI instance.

Definition at line 22 of file BLEMIDI.cpp.

void sendActiveSensing (  )

Send a `Active Sensing` event.

Definition at line 377 of file BLEMIDI.cpp.

void sendChannelAftertouch ( uint8_t  channel,
uint8_t  pressure 
)

Send a `Channel Aftertouch` event.

Parameters:
channel0-15
pressure0-127

Definition at line 386 of file BLEMIDI.cpp.

void sendContinue (  )

Send a `Continue` event.

Definition at line 371 of file BLEMIDI.cpp.

void sendControlChange ( uint8_t  channel,
uint8_t  function,
uint8_t  value 
)

Send a `Control Change` event.

Parameters:
channel0-15
function0-127
value0-127

Definition at line 404 of file BLEMIDI.cpp.

void sendNoteOff ( uint8_t  channel,
uint8_t  note,
uint8_t  velocity 
)

Send a `Note Off` event.

Parameters:
channel0-15
note0-127
velocity0-127

Definition at line 395 of file BLEMIDI.cpp.

void sendNoteOn ( uint8_t  channel,
uint8_t  note,
uint8_t  velocity 
)

Send a `Note On` event.

Parameters:
channel0-15
note0-127
velocity0-127

Definition at line 398 of file BLEMIDI.cpp.

void sendPitchWheel ( uint8_t  channel,
uint16_t  amount 
)

Send a `Pitch Wheel` event.

Parameters:
channel0-15
amount0-8192(center)-16383

Definition at line 407 of file BLEMIDI.cpp.

void sendPolyphonicAftertouch ( uint8_t  channel,
uint8_t  note,
uint8_t  pressure 
)

Send a `Polyphonic Aftertouch` event.

Parameters:
channel0-15
note0-127
pressure0-127

Definition at line 401 of file BLEMIDI.cpp.

void sendProgramChange ( uint8_t  channel,
uint8_t  program 
)

Send a `Program Change` event.

Parameters:
channel0-15
program0-127

Definition at line 383 of file BLEMIDI.cpp.

void sendReset (  )

Send a `Reset` event.

Definition at line 380 of file BLEMIDI.cpp.

void sendSongPositionPointer ( uint16_t  position )

Send a `Song Position Pointer` event.

Parameters:
position0-16383

Definition at line 410 of file BLEMIDI.cpp.

void sendSongSelect ( uint8_t  song )

Send a `Song Select` event.

Parameters:
song0-127

Definition at line 392 of file BLEMIDI.cpp.

void sendStart (  )

Send a `Start` event.

Definition at line 368 of file BLEMIDI.cpp.

void sendStop (  )

Send a `Stop` event.

Definition at line 374 of file BLEMIDI.cpp.

void sendSystemExclusive ( uint8_t *  sysex,
uint16_t  length 
)

Send a `System Exclusive` event.

Parameters:
sysexthe data starts with `0xf0` and ends with `0xf7`
length

Definition at line 413 of file BLEMIDI.cpp.

void sendTimeCodeQuarterFrame ( uint8_t  timing )

Send a `Time Code Quarter Frame` event.

Parameters:
timing0-127

Definition at line 389 of file BLEMIDI.cpp.

void sendTimingClock (  )

Send a `Timing Clock` event.

Definition at line 365 of file BLEMIDI.cpp.

void sendTuneRequest (  )

Send a `Tune Request` event.

Definition at line 362 of file BLEMIDI.cpp.