LMMS
Loading...
Searching...
No Matches
juce_UMPFactory.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23#ifndef DOXYGEN
24
25namespace juce
26{
28{
29
36struct Factory
37{
39 struct Detail
40 {
41 static PacketX1 makeSystem() { return PacketX1{}.withMessageType (1); }
42 static PacketX1 makeV1() { return PacketX1{}.withMessageType (2); }
43 static PacketX2 makeV2() { return PacketX2{}.withMessageType (4); }
44
45 static PacketX2 makeSysEx (uint8_t group,
46 uint8_t status,
47 uint8_t numBytes,
48 const uint8_t* data)
49 {
50 jassert (numBytes <= 6);
51
52 std::array<uint8_t, 8> bytes{{}};
53 bytes[0] = (0x3 << 0x4) | group;
54 bytes[1] = (uint8_t) (status << 0x4) | numBytes;
55
56 std::memcpy (bytes.data() + 2, data, numBytes);
57
58 std::array<uint32_t, 2> words;
59
60 size_t index = 0;
61
62 for (auto& word : words)
63 word = ByteOrder::bigEndianInt (bytes.data() + 4 * index++);
64
65 return PacketX2 { words };
66 }
67
69 uint8_t status,
70 uint8_t numBytes,
71 uint8_t dataStart,
72 const uint8_t* data)
73 {
74 jassert (numBytes <= 16 - dataStart);
75
76 std::array<uint8_t, 16> bytes{{}};
77 bytes[0] = (0x5 << 0x4) | group;
78 bytes[1] = (uint8_t) (status << 0x4) | numBytes;
79
80 std::memcpy (bytes.data() + dataStart, data, numBytes);
81
82 std::array<uint32_t, 4> words;
83
84 size_t index = 0;
85
86 for (auto& word : words)
87 word = ByteOrder::bigEndianInt (bytes.data() + 4 * index++);
88
89 return PacketX4 { words };
90 }
91 };
92
93 static PacketX1 makeNoop (uint8_t group)
94 {
95 return PacketX1{}.withGroup (group);
96 }
97
98 static PacketX1 makeJRClock (uint8_t group, uint16_t time)
99 {
100 return PacketX1 { time }.withStatus (1).withGroup (group);
101 }
102
104 {
105 return PacketX1 { time }.withStatus (2).withGroup (group);
106 }
107
109 {
110 return Detail::makeSystem().withGroup (group)
111 .withU8<1> (0xf1)
112 .withU8<2> (code & 0x7f);
113 }
114
116 {
117 return Detail::makeSystem().withGroup (group)
118 .withU8<1> (0xf2)
119 .withU8<2> (pos & 0x7f)
120 .withU8<3> ((pos >> 7) & 0x7f);
121 }
122
124 {
125 return Detail::makeSystem().withGroup (group)
126 .withU8<1> (0xf3)
127 .withU8<2> (song & 0x7f);
128 }
129
131 {
132 return Detail::makeSystem().withGroup (group)
133 .withU8<1> (0xf6);
134 }
135
137 {
138 return Detail::makeSystem().withGroup (group)
139 .withU8<1> (0xf8);
140 }
141
143 {
144 return Detail::makeSystem().withGroup (group)
145 .withU8<1> (0xfa);
146 }
147
149 {
150 return Detail::makeSystem().withGroup (group)
151 .withU8<1> (0xfb);
152 }
153
154 static PacketX1 makeStop (uint8_t group)
155 {
156 return Detail::makeSystem().withGroup (group)
157 .withU8<1> (0xfc);
158 }
159
161 {
162 return Detail::makeSystem().withGroup (group)
163 .withU8<1> (0xfe);
164 }
165
167 {
168 return Detail::makeSystem().withGroup (group)
169 .withU8<1> (0xff);
170 }
171
173 uint8_t channel,
174 uint8_t note,
175 uint8_t velocity)
176 {
177 return Detail::makeV1().withGroup (group)
178 .withStatus (0x8)
179 .withChannel (channel)
180 .withU8<2> (note & 0x7f)
181 .withU8<3> (velocity & 0x7f);
182 }
183
185 uint8_t channel,
186 uint8_t note,
187 uint8_t velocity)
188 {
189 return Detail::makeV1().withGroup (group)
190 .withStatus (0x9)
191 .withChannel (channel)
192 .withU8<2> (note & 0x7f)
193 .withU8<3> (velocity & 0x7f);
194 }
195
197 uint8_t channel,
198 uint8_t note,
199 uint8_t pressure)
200 {
201 return Detail::makeV1().withGroup (group)
202 .withStatus (0xa)
203 .withChannel (channel)
204 .withU8<2> (note & 0x7f)
205 .withU8<3> (pressure & 0x7f);
206 }
207
209 uint8_t channel,
212 {
213 return Detail::makeV1().withGroup (group)
214 .withStatus (0xb)
215 .withChannel (channel)
216 .withU8<2> (controller & 0x7f)
217 .withU8<3> (value & 0x7f);
218 }
219
221 uint8_t channel,
222 uint8_t program)
223 {
224 return Detail::makeV1().withGroup (group)
225 .withStatus (0xc)
226 .withChannel (channel)
227 .withU8<2> (program & 0x7f);
228 }
229
231 uint8_t channel,
232 uint8_t pressure)
233 {
234 return Detail::makeV1().withGroup (group)
235 .withStatus (0xd)
236 .withChannel (channel)
237 .withU8<2> (pressure & 0x7f);
238 }
239
241 uint8_t channel,
242 uint16_t pitchbend)
243 {
244 return Detail::makeV1().withGroup (group)
245 .withStatus (0xe)
246 .withChannel (channel)
247 .withU8<2> (pitchbend & 0x7f)
248 .withU8<3> ((pitchbend >> 7) & 0x7f);
249 }
250
252 uint8_t numBytes,
253 const uint8_t* data)
254 {
255 return Detail::makeSysEx (group, 0x0, numBytes, data);
256 }
257
259 uint8_t numBytes,
260 const uint8_t* data)
261 {
262 return Detail::makeSysEx (group, 0x1, numBytes, data);
263 }
264
266 uint8_t numBytes,
267 const uint8_t* data)
268 {
269 return Detail::makeSysEx (group, 0x2, numBytes, data);
270 }
271
273 uint8_t numBytes,
274 const uint8_t* data)
275 {
276 return Detail::makeSysEx (group, 0x3, numBytes, data);
277 }
278
280 uint8_t channel,
281 uint8_t note,
284 {
285 return Detail::makeV2().withGroup (group)
286 .withStatus (0x0)
287 .withChannel (channel)
288 .withU8<2> (note & 0x7f)
289 .withU8<3> (controller & 0x7f)
290 .withU32<1> (data);
291 }
292
294 uint8_t channel,
295 uint8_t note,
298 {
299 return Detail::makeV2().withGroup (group)
300 .withStatus (0x1)
301 .withChannel (channel)
302 .withU8<2> (note & 0x7f)
303 .withU8<3> (controller & 0x7f)
304 .withU32<1> (data);
305 }
306
308 uint8_t channel,
309 uint8_t bank,
310 uint8_t index,
312 {
313 return Detail::makeV2().withGroup (group)
314 .withStatus (0x2)
315 .withChannel (channel)
316 .withU8<2> (bank & 0x7f)
317 .withU8<3> (index & 0x7f)
318 .withU32<1> (data);
319 }
320
322 uint8_t channel,
323 uint8_t bank,
324 uint8_t index,
326 {
327 return Detail::makeV2().withGroup (group)
328 .withStatus (0x3)
329 .withChannel (channel)
330 .withU8<2> (bank & 0x7f)
331 .withU8<3> (index & 0x7f)
332 .withU32<1> (data);
333 }
334
336 uint8_t channel,
337 uint8_t bank,
338 uint8_t index,
340 {
341 return Detail::makeV2().withGroup (group)
342 .withStatus (0x4)
343 .withChannel (channel)
344 .withU8<2> (bank & 0x7f)
345 .withU8<3> (index & 0x7f)
346 .withU32<1> (data);
347 }
348
350 uint8_t channel,
351 uint8_t bank,
352 uint8_t index,
354 {
355 return Detail::makeV2().withGroup (group)
356 .withStatus (0x5)
357 .withChannel (channel)
358 .withU8<2> (bank & 0x7f)
359 .withU8<3> (index & 0x7f)
360 .withU32<1> (data);
361 }
362
364 uint8_t channel,
365 uint8_t note,
367 {
368 return Detail::makeV2().withGroup (group)
369 .withStatus (0x6)
370 .withChannel (channel)
371 .withU8<2> (note & 0x7f)
372 .withU32<1> (data);
373 }
374
376 {
377 none = 0x00,
378 manufacturer = 0x01,
379 profile = 0x02,
380 pitch7_9 = 0x03
381 };
382
384 uint8_t channel,
385 uint8_t note,
386 NoteAttributeKind attribute,
387 uint16_t velocity,
388 uint16_t attributeValue)
389 {
390 return Detail::makeV2().withGroup (group)
391 .withStatus (0x8)
392 .withChannel (channel)
393 .withU8<2> (note & 0x7f)
394 .withU8<3> ((uint8_t) attribute)
395 .withU16<2> (velocity)
396 .withU16<3> (attributeValue);
397 }
398
400 uint8_t channel,
401 uint8_t note,
402 NoteAttributeKind attribute,
403 uint16_t velocity,
404 uint16_t attributeValue)
405 {
406 return Detail::makeV2().withGroup (group)
407 .withStatus (0x9)
408 .withChannel (channel)
409 .withU8<2> (note & 0x7f)
410 .withU8<3> ((uint8_t) attribute)
411 .withU16<2> (velocity)
412 .withU16<3> (attributeValue);
413 }
414
416 uint8_t channel,
417 uint8_t note,
419 {
420 return Detail::makeV2().withGroup (group)
421 .withStatus (0xa)
422 .withChannel (channel)
423 .withU8<2> (note & 0x7f)
424 .withU32<1> (data);
425 }
426
428 uint8_t channel,
431 {
432 return Detail::makeV2().withGroup (group)
433 .withStatus (0xb)
434 .withChannel (channel)
435 .withU8<2> (controller & 0x7f)
436 .withU32<1> (data);
437 }
438
440 uint8_t channel,
441 uint8_t optionFlags,
442 uint8_t program,
443 uint8_t bankMsb,
444 uint8_t bankLsb)
445 {
446 return Detail::makeV2().withGroup (group)
447 .withStatus (0xc)
448 .withChannel (channel)
449 .withU8<3> (optionFlags)
450 .withU8<4> (program)
451 .withU8<6> (bankMsb)
452 .withU8<7> (bankLsb);
453 }
454
456 uint8_t channel,
458 {
459 return Detail::makeV2().withGroup (group)
460 .withStatus (0xd)
461 .withChannel (channel)
462 .withU32<1> (data);
463 }
464
466 uint8_t channel,
468 {
469 return Detail::makeV2().withGroup (group)
470 .withStatus (0xe)
471 .withChannel (channel)
472 .withU32<1> (data);
473 }
474
476 uint8_t channel,
477 uint8_t note,
478 uint8_t optionFlags)
479 {
480 return Detail::makeV2().withGroup (group)
481 .withStatus (0xf)
482 .withChannel (channel)
483 .withU8<2> (note)
484 .withU8<3> (optionFlags);
485 }
486
487
489 uint8_t numBytes,
490 uint8_t streamId,
491 const uint8_t* data)
492 {
493 return Detail::makeSysEx8 (group, 0x0, numBytes, 3, data).withU8<2> (streamId);
494 }
495
497 uint8_t numBytes,
498 uint8_t streamId,
499 const uint8_t* data)
500 {
501 return Detail::makeSysEx8 (group, 0x1, numBytes, 3, data).withU8<2> (streamId);
502 }
503
505 uint8_t numBytes,
506 uint8_t streamId,
507 const uint8_t* data)
508 {
509 return Detail::makeSysEx8 (group, 0x2, numBytes, 3, data).withU8<2> (streamId);
510 }
511
513 uint8_t numBytes,
514 uint8_t streamId,
515 const uint8_t* data)
516 {
517 return Detail::makeSysEx8 (group, 0x3, numBytes, 3, data).withU8<2> (streamId);
518 }
519
521 uint8_t dataSetId,
522 const uint8_t* data)
523 {
524 return Detail::makeSysEx8 (group, 0x8, 14, 2, data).withChannel (dataSetId);
525 }
526
528 uint8_t dataSetId,
529 const uint8_t* data)
530 {
531 return Detail::makeSysEx8 (group, 0x9, 14, 2, data).withChannel (dataSetId);
532 }
533};
534
535}
536}
537
538#endif
Controller controller
Definition main.C:5
static uint32 bigEndianInt(const void *bytes) noexcept
Definition ByteOrder.h:239
static PuglViewHint int value
Definition pugl.h:1708
JSAMPIMAGE data
Definition jpeglib.h:945
#define jassert(expression)
unsigned short uint16_t
Definition mid.cpp:99
unsigned int uint32_t
Definition mid.cpp:100
unsigned char uint8_t
Definition mid.cpp:98
Definition juce_UMP_test.cpp:26
Packet< 4 > PacketX4
Definition juce_UMPacket.h:188
Packet< 1 > PacketX1
Definition juce_UMPacket.h:185
Packet< 2 > PacketX2
Definition juce_UMPacket.h:186
Definition carla_juce.cpp:31
@ group
Definition juce_AccessibilityRole.h:61
short word
Definition private.h:22
Definition inftrees.h:27
Definition juce_UMPFactory.h:40
static PacketX2 makeSysEx(uint8_t group, uint8_t status, uint8_t numBytes, const uint8_t *data)
Definition juce_UMPFactory.h:45
static PacketX1 makeV1()
Definition juce_UMPFactory.h:42
static PacketX4 makeSysEx8(uint8_t group, uint8_t status, uint8_t numBytes, uint8_t dataStart, const uint8_t *data)
Definition juce_UMPFactory.h:68
static PacketX1 makeSystem()
Definition juce_UMPFactory.h:41
static PacketX2 makeV2()
Definition juce_UMPFactory.h:43
Definition juce_UMPFactory.h:37
static PacketX2 makeRelativeRegisteredControllerV2(uint8_t group, uint8_t channel, uint8_t bank, uint8_t index, uint32_t data)
Definition juce_UMPFactory.h:335
static PacketX1 makeStart(uint8_t group)
Definition juce_UMPFactory.h:142
static PacketX2 makeChannelPressureV2(uint8_t group, uint8_t channel, uint32_t data)
Definition juce_UMPFactory.h:455
static PacketX4 makeSysEx8Start(uint8_t group, uint8_t numBytes, uint8_t streamId, const uint8_t *data)
Definition juce_UMPFactory.h:496
static PacketX2 makeSysExIn1Packet(uint8_t group, uint8_t numBytes, const uint8_t *data)
Definition juce_UMPFactory.h:251
static PacketX1 makeActiveSensing(uint8_t group)
Definition juce_UMPFactory.h:160
static PacketX2 makeRegisteredControllerV2(uint8_t group, uint8_t channel, uint8_t bank, uint8_t index, uint32_t data)
Definition juce_UMPFactory.h:307
static PacketX1 makeJRClock(uint8_t group, uint16_t time)
Definition juce_UMPFactory.h:98
static PacketX2 makeNoteOffV2(uint8_t group, uint8_t channel, uint8_t note, NoteAttributeKind attribute, uint16_t velocity, uint16_t attributeValue)
Definition juce_UMPFactory.h:383
static PacketX2 makeControlChangeV2(uint8_t group, uint8_t channel, uint8_t controller, uint32_t data)
Definition juce_UMPFactory.h:427
static PacketX1 makeNoteOnV1(uint8_t group, uint8_t channel, uint8_t note, uint8_t velocity)
Definition juce_UMPFactory.h:184
static PacketX1 makeNoteOffV1(uint8_t group, uint8_t channel, uint8_t note, uint8_t velocity)
Definition juce_UMPFactory.h:172
static PacketX2 makeProgramChangeV2(uint8_t group, uint8_t channel, uint8_t optionFlags, uint8_t program, uint8_t bankMsb, uint8_t bankLsb)
Definition juce_UMPFactory.h:439
static PacketX1 makePolyPressureV1(uint8_t group, uint8_t channel, uint8_t note, uint8_t pressure)
Definition juce_UMPFactory.h:196
static PacketX2 makeNoteOnV2(uint8_t group, uint8_t channel, uint8_t note, NoteAttributeKind attribute, uint16_t velocity, uint16_t attributeValue)
Definition juce_UMPFactory.h:399
static PacketX1 makeTimeCode(uint8_t group, uint8_t code)
Definition juce_UMPFactory.h:108
static PacketX2 makeRelativeAssignableControllerV2(uint8_t group, uint8_t channel, uint8_t bank, uint8_t index, uint32_t data)
Definition juce_UMPFactory.h:349
static PacketX1 makeProgramChangeV1(uint8_t group, uint8_t channel, uint8_t program)
Definition juce_UMPFactory.h:220
static PacketX1 makeTimingClock(uint8_t group)
Definition juce_UMPFactory.h:136
static PacketX4 makeMixedDataSetHeader(uint8_t group, uint8_t dataSetId, const uint8_t *data)
Definition juce_UMPFactory.h:520
static PacketX2 makeRegisteredPerNoteControllerV2(uint8_t group, uint8_t channel, uint8_t note, uint8_t controller, uint32_t data)
Definition juce_UMPFactory.h:279
static PacketX1 makeNoop(uint8_t group)
Definition juce_UMPFactory.h:93
static PacketX1 makePitchBend(uint8_t group, uint8_t channel, uint16_t pitchbend)
Definition juce_UMPFactory.h:240
static PacketX1 makeJRTimestamp(uint8_t group, uint16_t time)
Definition juce_UMPFactory.h:103
NoteAttributeKind
Definition juce_UMPFactory.h:376
static PacketX2 makePitchBendV2(uint8_t group, uint8_t channel, uint32_t data)
Definition juce_UMPFactory.h:465
static PacketX1 makeContinue(uint8_t group)
Definition juce_UMPFactory.h:148
static PacketX2 makeSysExContinue(uint8_t group, uint8_t numBytes, const uint8_t *data)
Definition juce_UMPFactory.h:265
static PacketX1 makeControlChangeV1(uint8_t group, uint8_t channel, uint8_t controller, uint8_t value)
Definition juce_UMPFactory.h:208
static PacketX2 makeSysExEnd(uint8_t group, uint8_t numBytes, const uint8_t *data)
Definition juce_UMPFactory.h:272
static PacketX4 makeSysEx8End(uint8_t group, uint8_t numBytes, uint8_t streamId, const uint8_t *data)
Definition juce_UMPFactory.h:512
static PacketX2 makePerNoteManagementV2(uint8_t group, uint8_t channel, uint8_t note, uint8_t optionFlags)
Definition juce_UMPFactory.h:475
static PacketX1 makeSongPositionPointer(uint8_t group, uint16_t pos)
Definition juce_UMPFactory.h:115
static PacketX2 makeAssignableControllerV2(uint8_t group, uint8_t channel, uint8_t bank, uint8_t index, uint32_t data)
Definition juce_UMPFactory.h:321
static PacketX2 makePerNotePitchBendV2(uint8_t group, uint8_t channel, uint8_t note, uint32_t data)
Definition juce_UMPFactory.h:363
static PacketX4 makeSysEx8Continue(uint8_t group, uint8_t numBytes, uint8_t streamId, const uint8_t *data)
Definition juce_UMPFactory.h:504
static PacketX1 makeReset(uint8_t group)
Definition juce_UMPFactory.h:166
static PacketX4 makeDataSetPayload(uint8_t group, uint8_t dataSetId, const uint8_t *data)
Definition juce_UMPFactory.h:527
static PacketX2 makeAssignablePerNoteControllerV2(uint8_t group, uint8_t channel, uint8_t note, uint8_t controller, uint32_t data)
Definition juce_UMPFactory.h:293
static PacketX4 makeSysEx8in1Packet(uint8_t group, uint8_t numBytes, uint8_t streamId, const uint8_t *data)
Definition juce_UMPFactory.h:488
static PacketX2 makePolyPressureV2(uint8_t group, uint8_t channel, uint8_t note, uint32_t data)
Definition juce_UMPFactory.h:415
static PacketX1 makeTuneRequest(uint8_t group)
Definition juce_UMPFactory.h:130
static PacketX1 makeSongSelect(uint8_t group, uint8_t song)
Definition juce_UMPFactory.h:123
static PacketX1 makeChannelPressureV1(uint8_t group, uint8_t channel, uint8_t pressure)
Definition juce_UMPFactory.h:230
static PacketX1 makeStop(uint8_t group)
Definition juce_UMPFactory.h:154
static PacketX2 makeSysExStart(uint8_t group, uint8_t numBytes, const uint8_t *data)
Definition juce_UMPFactory.h:258