48 template <
typename PacketCallback>
51 const auto firstWord = v[0];
52 const auto messageType = Utils::getMessageType (firstWord);
54 if (messageType != 0x2)
60 const HelperValues helperValues
62 std::byte ((0x4 << 0x4) | Utils::getGroup (firstWord)),
63 std::byte ((firstWord >> 0x10) & 0xff),
64 std::byte ((firstWord >> 0x08) & 0x7f),
65 std::byte ((firstWord >> 0x00) & 0x7f),
68 switch (Utils::getStatus (firstWord))
73 const auto packet = processNoteOnOrOff (helperValues);
74 callback (
View (packet.data()));
80 const auto packet = processPolyPressure (helperValues);
81 callback (
View (packet.data()));
89 if (processControlChange (helperValues, packet))
90 callback (
View (packet.data()));
97 const auto packet = processProgramChange (helperValues);
98 callback (
View (packet.data()));
104 const auto packet = processChannelPressure (helperValues);
105 callback (
View (packet.data()));
111 const auto packet = processPitchBend (helperValues);
112 callback (
View (packet.data()));
120 groupAccumulators = {};
125 enum class PnKind { nrpn, rpn };
129 std::byte typeAndGroup;
135 static PacketX2 processNoteOnOrOff (HelperValues helpers);
136 static PacketX2 processPolyPressure (HelperValues helpers);
138 bool processControlChange (HelperValues helpers, PacketX2& packet);
140 PacketX2 processProgramChange (HelperValues helpers)
const;
142 static PacketX2 processChannelPressure (HelperValues helpers);
143 static PacketX2 processPitchBend (HelperValues helpers);
148 bool addByte (uint8_t cc, std::byte
byte);
150 const std::array<std::byte, 4>& getBytes() const noexcept {
return bytes; }
151 PnKind getKind() const noexcept {
return kind; }
154 std::array<std::byte, 4> bytes;
156 PnKind kind = PnKind::nrpn;
162 bool isValid() const noexcept {
return ! (msb & 0x80); }
164 uint8_t getMsb() const noexcept {
return msb & 0x7f; }
165 uint8_t getLsb() const noexcept {
return lsb & 0x7f; }
167 void setMsb (uint8_t i)
noexcept { msb = i & 0x7f; }
168 void setLsb (uint8_t i)
noexcept { msb &= 0x7f; lsb = i & 0x7f; }
179 using ChannelAccumulators = std::array<PnAccumulator, 16>;
180 std::array<ChannelAccumulators, 16> groupAccumulators;
182 using ChannelBanks = std::array<Bank, 16>;
183 std::array<ChannelBanks, 16> groupBanks;