25namespace juce::universal_midi_packets
37 Midi1ToMidi2DefaultTranslator() =
default;
48 template <
typename PacketCallback>
49 void dispatch (
const View& v, PacketCallback&& callback)
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)),
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 };
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);
151 PnKind getKind() const noexcept {
return kind; }
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; }
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...