7static constexpr uint8_t MIDI_MSG_SYSEX = 0xF0;
8static constexpr uint8_t MIDI_MSG_SYSEX_END = 0xF7;
9static constexpr uint8_t MIDI_MSG_RESET = 0xFF;
13[[nodiscard]]
static constexpr size_t midiMessageLength(uint8_t status)
18 }
else if (status < 0xC0) {
20 }
else if (status < 0xE0) {
22 }
else if (status < 0xF0) {
29 case MIDI_MSG_SYSEX_END:
63 if (value == MIDI_MSG_SYSEX_END) {
65 buffer.push_back(value);
72 }
else if (value >= 0xF8) {
74 std::vector<uint8_t> realtimeMessage = { value };
76 if (value == MIDI_MSG_RESET) {
84 }
else if (buffer.size() >= 2) {
86 std::cerr <<
"Discarding incomplete MIDI message with status "
87 "0x" << std::hex << int(buffer[0]) << std::dec <<
88 ", at " << buffer.size() <<
" of " <<
89 midiMessageLength(buffer[0]) <<
" bytes\n";
93 isSysEx = value == MIDI_MSG_SYSEX;
96 if (buffer.empty() && !isSysEx) {
99 buffer.push_back(value);
104 if (!buffer.empty()) {
105 uint8_t status = isSysEx ? MIDI_MSG_SYSEX : buffer[0];
106 size_t len = midiMessageLength(status);
107 if (buffer.size() >= len) {
109 if (status >= 0xF0 && status < 0xF8) {
120 const std::vector<uint8_t>& , EmuTime::param )
void clearBuffer()
Discard any buffered partial MIDI message.
virtual void recvMessage(const std::vector< uint8_t > &message, EmuTime::param time)
Called when a full MIDI message is ready to be sent.
static constexpr size_t MAX_MESSAGE_SIZE
The limit for the amount of data we'll put into one MIDI message.
void setParityBit(bool enable, Parity parity) override
void setStopBits(StopBits bits) override
std::string_view getClass() const final
A pluggable belongs to a certain class.
void setDataBits(DataBits bits) override
void recvByte(byte value, EmuTime::param time) override
This file implemented 3 utility functions: