5template <
bool ThreeBytes>
27 buffer.push_back(timestampLSB);
39 buffer.push_back(timestampLSB);
55 ERROR(F(
"capacity less than 5 bytes"), 0x2005);
62 constexpr bool ThreeBytes =
true;
63 return addImpl<ThreeBytes>(header, data1, data2, timestamp);
68 constexpr bool ThreeBytes =
false;
69 return addImpl<ThreeBytes>(header, data1, 0, timestamp);
86 uint8_t data1, uint8_t data2,
94 buffer.push_back(timestampLSB);
106 uint16_t timestamp) {
126 buffer.push_back(timestampLSB);
138 uint16_t timestamp) {
149 while (length-- > 1 &&
buffer.size() <
buffer.capacity())
150 buffer.push_back(*data++);
#define BEGIN_CS_NAMESPACE
std::vector< uint8_t > buffer
void setCapacity(uint16_t capacity)
Set the maximum capacity of the buffer.
void continueSysEx(const uint8_t *&data, size_t &length, uint16_t timestamp)
Add a SysEx continuation to the packet.
static constexpr const uint8_t SysExEnd
bool addSysEx(const uint8_t *&data, size_t &length, uint16_t timestamp)
Try adding (part of) a SysEx message to the packet.
bool hasSpaceFor(size_t bytes) const
Check if the buffer has space left.
static constexpr uint8_t getTimestampLSB(uint16_t timestamp)
Timestamp[1]: 0b1lll llll.
bool add2B(uint8_t header, uint8_t data1, uint16_t timestamp)
Try adding a 2-byte MIDI channel voice message to the packet.
bool addSysCommon(uint8_t num_data, uint8_t header, uint8_t data1, uint8_t data2, uint16_t timestamp)
Try adding a MIDI system common message to the packet.
bool addRealTime(uint8_t rt, uint16_t timestamp)
Try adding a MIDI real-time message to the packet.
static constexpr const uint8_t SysExStart
void reset()
Reset the builder to start a new packet.
bool addImpl(uint8_t header, uint8_t data1, uint8_t data2, uint16_t timestamp)
Try adding a 2-byte or 3-byte MIDI channel voice message to the packet.
bool add3B(uint8_t header, uint8_t data1, uint8_t data2, uint16_t timestamp)
Try adding a 3-byte MIDI channel voice message to the packet.
void initBuffer(uint16_t timestamp)
If this is the first byte/message in the packet, add the header containing the 6 most significant bit...