Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
You are viewing an older revision! See the latest version
Homepage
Using MIDI over Bluetooth LE¶
This class enables sending and receiving MIDI packets.
Set up an "BLEMIDI" class instance¶
Create an instance, and set up to start using it.
Initialization
#include "mbed.h"
#include "BLEDevice.h"
#include "BLEMIDI.h"
BLEDevice device;
BLEMIDI bleMidi(&device);
void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) {
bleMidi.onBleDisconnection(handle, reason);
}
void connectionCallback(Gap::Handle_t handle, Gap::addr_type_t type, const Gap::address_t addr, const Gap::ConnectionParams_t *params) {
bleMidi.onBleConnection(handle, type, addr, params);
}
int main(void) {
device.onConnection(connectionCallback);
device.onDisconnection(disconnectionCallback);
for (;;) {
device.waitForEvent();
}
}
Sending MIDI events¶
For example, send a note on event:
send a note on event
bleMidi.sendNoteOn(0, 63, 127);
For other events, see the BLEMIDI Class Reference.
Receiving MIDI events¶
For example, receive note on events:
receive note on events
void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity) {
// do something...
}
bleMidi.attachNoteOn(onNoteOn);
For other events, see the BLEMIDI Class Reference.