46 const std::byte* data)
48 jassert (numBytes <= 6);
50 std::array<uint8_t, 8> bytes{{}};
51 bytes[0] = (0x3 << 0x4) | group;
52 bytes[1] = (
uint8_t) (status << 0x4) | numBytes;
54 std::memcpy (bytes.data() + 2, data, numBytes);
56 std::array<uint32_t, 2>
words;
58 for (
const auto [index,
word] : enumerate (
words))
72 std::array<uint8_t, 16> bytes{{}};
73 bytes[0] = (0x5 << 0x4) | group;
74 bytes[1] = (
uint8_t) (status << 0x4) | numBytes;
76 std::memcpy (bytes.data() +
dataStart, data, numBytes);
78 std::array<uint32_t, 4>
words;
80 for (
const auto [index,
word] : enumerate (
words))
94 return PacketX1 { time }.withStatus (1).withGroup (group);
97 static PacketX1 makeJRTimestamp (uint8_t group, uint16_t time)
99 return PacketX1 { time }.withStatus (2).withGroup (group);
102 static PacketX1 makeTimeCode (uint8_t group, uint8_t code)
104 return Detail::makeSystem().withGroup (group)
106 .withU8<2> (code & 0x7f);
109 static PacketX1 makeSongPositionPointer (uint8_t group, uint16_t pos)
111 return Detail::makeSystem().withGroup (group)
113 .withU8<2> (pos & 0x7f)
114 .withU8<3> ((pos >> 7) & 0x7f);
117 static PacketX1 makeSongSelect (uint8_t group, uint8_t song)
119 return Detail::makeSystem().withGroup (group)
121 .withU8<2> (song & 0x7f);
124 static PacketX1 makeTuneRequest (uint8_t group)
126 return Detail::makeSystem().withGroup (group)
130 static PacketX1 makeTimingClock (uint8_t group)
132 return Detail::makeSystem().withGroup (group)
136 static PacketX1 makeStart (uint8_t group)
138 return Detail::makeSystem().withGroup (group)
142 static PacketX1 makeContinue (uint8_t group)
144 return Detail::makeSystem().withGroup (group)
148 static PacketX1 makeStop (uint8_t group)
150 return Detail::makeSystem().withGroup (group)
154 static PacketX1 makeActiveSensing (uint8_t group)
156 return Detail::makeSystem().withGroup (group)
160 static PacketX1 makeReset (uint8_t group)
162 return Detail::makeSystem().withGroup (group)
166 static PacketX1 makeNoteOffV1 (uint8_t group,
171 return Detail::makeV1().withGroup (group)
173 .withChannel (channel)
174 .withU8<2> (note & 0x7f)
175 .withU8<3> (velocity & 0x7f);
178 static PacketX1 makeNoteOnV1 (uint8_t group,
183 return Detail::makeV1().withGroup (group)
185 .withChannel (channel)
186 .withU8<2> (note & 0x7f)
187 .withU8<3> (velocity & 0x7f);
190 static PacketX1 makePolyPressureV1 (uint8_t group,
195 return Detail::makeV1().withGroup (group)
197 .withChannel (channel)
198 .withU8<2> (note & 0x7f)
199 .withU8<3> (pressure & 0x7f);
202 static PacketX1 makeControlChangeV1 (uint8_t group,
207 return Detail::makeV1().withGroup (group)
209 .withChannel (channel)
210 .withU8<2> (controller & 0x7f)
211 .withU8<3> (value & 0x7f);
214 static PacketX1 makeProgramChangeV1 (uint8_t group,
218 return Detail::makeV1().withGroup (group)
220 .withChannel (channel)
221 .withU8<2> (program & 0x7f);
224 static PacketX1 makeChannelPressureV1 (uint8_t group,
228 return Detail::makeV1().withGroup (group)
230 .withChannel (channel)
231 .withU8<2> (pressure & 0x7f);
234 static PacketX1 makePitchBend (uint8_t group,
238 return Detail::makeV1().withGroup (group)
240 .withChannel (channel)
241 .withU8<2> (pitchbend & 0x7f)
242 .withU8<3> ((pitchbend >> 7) & 0x7f);
245 static PacketX2 makeSysExIn1Packet (uint8_t group,
247 const std::byte* data)
249 return Detail::makeSysEx (group, 0x0, numBytes, data);
252 static PacketX2 makeSysExStart (uint8_t group,
254 const std::byte* data)
256 return Detail::makeSysEx (group, 0x1, numBytes, data);
259 static PacketX2 makeSysExContinue (uint8_t group,
261 const std::byte* data)
263 return Detail::makeSysEx (group, 0x2, numBytes, data);
266 static PacketX2 makeSysExEnd (uint8_t group,
268 const std::byte* data)
270 return Detail::makeSysEx (group, 0x3, numBytes, data);
273 static PacketX2 makeRegisteredPerNoteControllerV2 (uint8_t group,
279 return Detail::makeV2().withGroup (group)
281 .withChannel (channel)
282 .withU8<2> (note & 0x7f)
283 .withU8<3> (controller & 0x7f)
287 static PacketX2 makeAssignablePerNoteControllerV2 (uint8_t group,
293 return Detail::makeV2().withGroup (group)
295 .withChannel (channel)
296 .withU8<2> (note & 0x7f)
297 .withU8<3> (controller & 0x7f)
301 static PacketX2 makeRegisteredControllerV2 (uint8_t group,
307 return Detail::makeV2().withGroup (group)
309 .withChannel (channel)
310 .withU8<2> (bank & 0x7f)
311 .withU8<3> (index & 0x7f)
315 static PacketX2 makeAssignableControllerV2 (uint8_t group,
321 return Detail::makeV2().withGroup (group)
323 .withChannel (channel)
324 .withU8<2> (bank & 0x7f)
325 .withU8<3> (index & 0x7f)
329 static PacketX2 makeRelativeRegisteredControllerV2 (uint8_t group,
335 return Detail::makeV2().withGroup (group)
337 .withChannel (channel)
338 .withU8<2> (bank & 0x7f)
339 .withU8<3> (index & 0x7f)
343 static PacketX2 makeRelativeAssignableControllerV2 (uint8_t group,
349 return Detail::makeV2().withGroup (group)
351 .withChannel (channel)
352 .withU8<2> (bank & 0x7f)
353 .withU8<3> (index & 0x7f)
357 static PacketX2 makePerNotePitchBendV2 (uint8_t group,
362 return Detail::makeV2().withGroup (group)
364 .withChannel (channel)
365 .withU8<2> (note & 0x7f)
369 enum class NoteAttributeKind : uint8_t
377 static PacketX2 makeNoteOffV2 (uint8_t group,
380 NoteAttributeKind attribute,
382 uint16_t attributeValue)
384 return Detail::makeV2().withGroup (group)
386 .withChannel (channel)
387 .withU8<2> (note & 0x7f)
388 .withU8<3> ((uint8_t) attribute)
389 .withU16<2> (velocity)
390 .withU16<3> (attributeValue);
393 static PacketX2 makeNoteOnV2 (uint8_t group,
396 NoteAttributeKind attribute,
398 uint16_t attributeValue)
400 return Detail::makeV2().withGroup (group)
402 .withChannel (channel)
403 .withU8<2> (note & 0x7f)
404 .withU8<3> ((uint8_t) attribute)
405 .withU16<2> (velocity)
406 .withU16<3> (attributeValue);
409 static PacketX2 makePolyPressureV2 (uint8_t group,
414 return Detail::makeV2().withGroup (group)
416 .withChannel (channel)
417 .withU8<2> (note & 0x7f)
421 static PacketX2 makeControlChangeV2 (uint8_t group,
426 return Detail::makeV2().withGroup (group)
428 .withChannel (channel)
429 .withU8<2> (controller & 0x7f)
433 static PacketX2 makeProgramChangeV2 (uint8_t group,
440 return Detail::makeV2().withGroup (group)
442 .withChannel (channel)
443 .withU8<3> (optionFlags)
446 .withU8<7> (bankLsb);
449 static PacketX2 makeChannelPressureV2 (uint8_t group,
453 return Detail::makeV2().withGroup (group)
455 .withChannel (channel)
459 static PacketX2 makePitchBendV2 (uint8_t group,
463 return Detail::makeV2().withGroup (group)
465 .withChannel (channel)
469 static PacketX2 makePerNoteManagementV2 (uint8_t group,
474 return Detail::makeV2().withGroup (group)
476 .withChannel (channel)
478 .withU8<3> (optionFlags);
482 static PacketX4 makeSysEx8in1Packet (uint8_t group,
487 return Detail::makeSysEx8 (group, 0x0, numBytes, 3, data).withU8<2> (streamId);
490 static PacketX4 makeSysEx8Start (uint8_t group,
495 return Detail::makeSysEx8 (group, 0x1, numBytes, 3, data).withU8<2> (streamId);
498 static PacketX4 makeSysEx8Continue (uint8_t group,
503 return Detail::makeSysEx8 (group, 0x2, numBytes, 3, data).withU8<2> (streamId);
506 static PacketX4 makeSysEx8End (uint8_t group,
511 return Detail::makeSysEx8 (group, 0x3, numBytes, 3, data).withU8<2> (streamId);
514 static PacketX4 makeMixedDataSetHeader (uint8_t group,
518 return Detail::makeSysEx8 (group, 0x8, 14, 2, data).withChannel (dataSetId);
521 static PacketX4 makeDataSetPayload (uint8_t group,
525 return Detail::makeSysEx8 (group, 0x9, 14, 2, data).withChannel (dataSetId);