FabGL2
2.0.0
Graphics, audio, GUI and retro-computing library for the ESP32 (ESP-IDF)
Toggle main menu visibility
Loading...
Searching...
No Matches
blemidi.h
Go to the documentation of this file.
1
/*
2
Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3
Copyright (c) 2019-2026 Fabrizio Di Vittorio.
4
All rights reserved.
5
6
7
* Please contact fdivitto2013@gmail.com if you need a commercial license.
8
9
10
* This library and related software is available under GPL v3.
11
12
FabGL is free software: you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation, either version 3 of the License, or
15
(at your option) any later version.
16
17
FabGL is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
GNU General Public License for more details.
21
22
You should have received a copy of the GNU General Public License
23
along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24
*/
25
26
27
#pragma once
28
29
35
36
37
#include <stdint.h>
38
#include <stddef.h>
39
40
#include "freertos/FreeRTOS.h"
41
#include "freertos/queue.h"
42
43
#include "
fabutils.h
"
44
45
46
namespace
fabgl {
47
48
54
struct
MIDIMessage
{
55
uint8_t
status
;
56
uint8_t
data1
;
57
uint8_t
data2
;
58
};
59
60
104
class
BLEMIDI {
105
106
public
:
107
108
BLEMIDI();
109
110
~BLEMIDI();
111
118
static
void
releaseClassicBTMemory
();
119
131
bool
begin
(
char
const
* deviceName,
int
queueSize = 64);
132
138
bool
connected
() {
return
m_connected; }
139
149
bool
getMessage
(
MIDIMessage
* msg);
150
156
int
droppedMessages
() {
return
m_dropped; }
157
164
Delegate<>
onMessages
;
165
166
// used by the Bluetooth callbacks
167
void
packetReceived(uint8_t
const
* data,
int
len);
168
void
setConnected(
bool
value);
169
170
private
:
171
172
void
putMessage(uint8_t status, uint8_t data1, uint8_t data2);
173
static
int
dataBytes(uint8_t status);
174
175
QueueHandle_t m_queue;
176
volatile
bool
m_connected;
177
int
m_dropped;
// written only by the Bluetooth host task
178
int
m_putCount;
// written only by the Bluetooth host task
179
180
// decoder state (kept between packets)
181
uint8_t m_runningStatus;
182
bool
m_inSysEx;
183
};
184
185
186
}
// end of namespace
fabgl::BLEMIDI::onMessages
Delegate onMessages
Called after one or more messages have been queued.
Definition
blemidi.h:164
fabgl::BLEMIDI::connected
bool connected()
Determines whether a central is connected.
Definition
blemidi.h:138
fabgl::BLEMIDI::droppedMessages
int droppedMessages()
Number of messages discarded because the queue was full.
Definition
blemidi.h:156
fabgl::BLEMIDI::getMessage
bool getMessage(MIDIMessage *msg)
Gets the next received message (non blocking).
Definition
blemidi.cpp:248
fabgl::BLEMIDI::releaseClassicBTMemory
static void releaseClassicBTMemory()
Releases the internal RAM reserved for classic Bluetooth (BR/EDR), about 15 KB.
Definition
blemidi.cpp:177
fabgl::BLEMIDI::begin
bool begin(char const *deviceName, int queueSize=64)
Starts the Bluetooth stack and advertises the BLE-MIDI service.
Definition
blemidi.cpp:189
fabutils.h
This file contains utility classes and functions.
fabgl::MIDIMessage::data2
uint8_t data2
Definition
blemidi.h:57
fabgl::MIDIMessage::data1
uint8_t data1
Definition
blemidi.h:56
fabgl::MIDIMessage::status
uint8_t status
Definition
blemidi.h:55
fabgl::MIDIMessage
A MIDI message: status byte and up to two data bytes.
Definition
blemidi.h:54
components
fabgl
src
comdrivers
blemidi.h
Generated on
for FabGL2 by
1.18.0