objc2-core-midi 0.3.2

Bindings to the CoreMIDI framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midimessagetype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIMessageType(pub c_uint);
impl MIDIMessageType {
    #[doc(alias = "kMIDIMessageTypeUtility")]
    pub const Utility: Self = Self(0x0);
    #[doc(alias = "kMIDIMessageTypeSystem")]
    pub const System: Self = Self(0x1);
    #[doc(alias = "kMIDIMessageTypeChannelVoice1")]
    pub const ChannelVoice1: Self = Self(0x2);
    #[doc(alias = "kMIDIMessageTypeSysEx")]
    pub const SysEx: Self = Self(0x3);
    #[doc(alias = "kMIDIMessageTypeChannelVoice2")]
    pub const ChannelVoice2: Self = Self(0x4);
    #[doc(alias = "kMIDIMessageTypeData128")]
    pub const Data128: Self = Self(0x5);
    #[doc(alias = "kMIDIMessageTypeFlexData")]
    pub const FlexData: Self = Self(0xD);
    #[doc(alias = "kMIDIMessageTypeUnknownF")]
    pub const UnknownF: Self = Self(0xF);
    #[doc(alias = "kMIDIMessageTypeStream")]
    pub const Stream: Self = Self(0xF);
    #[doc(alias = "kMIDIMessageTypeInvalid")]
    pub const Invalid: Self = Self(0xFF);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIMessageType {
    const ENCODING: Encoding = c_uint::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIMessageType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midicvstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDICVStatus(pub c_uint);
impl MIDICVStatus {
    #[doc(alias = "kMIDICVStatusNoteOff")]
    pub const NoteOff: Self = Self(0x8);
    #[doc(alias = "kMIDICVStatusNoteOn")]
    pub const NoteOn: Self = Self(0x9);
    #[doc(alias = "kMIDICVStatusPolyPressure")]
    pub const PolyPressure: Self = Self(0xA);
    #[doc(alias = "kMIDICVStatusControlChange")]
    pub const ControlChange: Self = Self(0xB);
    #[doc(alias = "kMIDICVStatusProgramChange")]
    pub const ProgramChange: Self = Self(0xC);
    #[doc(alias = "kMIDICVStatusChannelPressure")]
    pub const ChannelPressure: Self = Self(0xD);
    #[doc(alias = "kMIDICVStatusPitchBend")]
    pub const PitchBend: Self = Self(0xE);
    #[doc(alias = "kMIDICVStatusRegisteredPNC")]
    pub const RegisteredPNC: Self = Self(0x0);
    #[doc(alias = "kMIDICVStatusAssignablePNC")]
    pub const AssignablePNC: Self = Self(0x1);
    #[doc(alias = "kMIDICVStatusRegisteredControl")]
    pub const RegisteredControl: Self = Self(0x2);
    #[doc(alias = "kMIDICVStatusAssignableControl")]
    pub const AssignableControl: Self = Self(0x3);
    #[doc(alias = "kMIDICVStatusRelRegisteredControl")]
    pub const RelRegisteredControl: Self = Self(0x4);
    #[doc(alias = "kMIDICVStatusRelAssignableControl")]
    pub const RelAssignableControl: Self = Self(0x5);
    #[doc(alias = "kMIDICVStatusPerNotePitchBend")]
    pub const PerNotePitchBend: Self = Self(0x6);
    #[doc(alias = "kMIDICVStatusPerNoteMgmt")]
    pub const PerNoteMgmt: Self = Self(0xF);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDICVStatus {
    const ENCODING: Encoding = c_uint::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDICVStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midisystemstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDISystemStatus(pub c_uint);
impl MIDISystemStatus {
    #[doc(alias = "kMIDIStatusStartOfExclusive")]
    pub const StatusStartOfExclusive: Self = Self(0xF0);
    #[doc(alias = "kMIDIStatusEndOfExclusive")]
    pub const StatusEndOfExclusive: Self = Self(0xF7);
    #[doc(alias = "kMIDIStatusMTC")]
    pub const StatusMTC: Self = Self(0xF1);
    #[doc(alias = "kMIDIStatusSongPosPointer")]
    pub const StatusSongPosPointer: Self = Self(0xF2);
    #[doc(alias = "kMIDIStatusSongSelect")]
    pub const StatusSongSelect: Self = Self(0xF3);
    #[doc(alias = "kMIDIStatusTuneRequest")]
    pub const StatusTuneRequest: Self = Self(0xF6);
    #[doc(alias = "kMIDIStatusTimingClock")]
    pub const StatusTimingClock: Self = Self(0xF8);
    #[doc(alias = "kMIDIStatusStart")]
    pub const StatusStart: Self = Self(0xFA);
    #[doc(alias = "kMIDIStatusContinue")]
    pub const StatusContinue: Self = Self(0xFB);
    #[doc(alias = "kMIDIStatusStop")]
    pub const StatusStop: Self = Self(0xFC);
    #[doc(alias = "kMIDIStatusActiveSending")]
    pub const StatusActiveSending: Self = Self(0xFE);
    #[doc(alias = "kMIDIStatusActiveSensing")]
    pub const StatusActiveSensing: Self = Self(MIDISystemStatus::StatusActiveSending.0);
    #[doc(alias = "kMIDIStatusSystemReset")]
    pub const StatusSystemReset: Self = Self(0xFF);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDISystemStatus {
    const ENCODING: Encoding = c_uint::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDISystemStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midisysexstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDISysExStatus(pub c_uint);
impl MIDISysExStatus {
    #[doc(alias = "kMIDISysExStatusComplete")]
    pub const Complete: Self = Self(0x0);
    #[doc(alias = "kMIDISysExStatusStart")]
    pub const Start: Self = Self(0x1);
    #[doc(alias = "kMIDISysExStatusContinue")]
    pub const Continue: Self = Self(0x2);
    #[doc(alias = "kMIDISysExStatusEnd")]
    pub const End: Self = Self(0x3);
    #[doc(alias = "kMIDISysExStatusMixedDataSetHeader")]
    pub const MixedDataSetHeader: Self = Self(0x8);
    #[doc(alias = "kMIDISysExStatusMixedDataSetPayload")]
    pub const MixedDataSetPayload: Self = Self(0x9);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDISysExStatus {
    const ENCODING: Encoding = c_uint::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDISysExStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiutilitystatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIUtilityStatus(pub c_uint);
impl MIDIUtilityStatus {
    #[doc(alias = "kMIDIUtilityStatusNOOP")]
    pub const NOOP: Self = Self(0x0);
    #[doc(alias = "kMIDIUtilityStatusJitterReductionClock")]
    pub const JitterReductionClock: Self = Self(0x1);
    #[doc(alias = "kMIDIUtilityStatusJitterReductionTimestamp")]
    pub const JitterReductionTimestamp: Self = Self(0x2);
    #[doc(alias = "kMIDIUtilityStatusDeltaClockstampTicksPerQuarterNote")]
    pub const DeltaClockstampTicksPerQuarterNote: Self = Self(0x3);
    #[doc(alias = "kMIDIUtilityStatusTicksSinceLastEvent")]
    pub const TicksSinceLastEvent: Self = Self(0x4);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIUtilityStatus {
    const ENCODING: Encoding = c_uint::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIUtilityStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/umpstreammessagestatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UMPStreamMessageStatus(pub c_uint);
impl UMPStreamMessageStatus {
    #[doc(alias = "kUMPStreamMessageStatusEndpointDiscovery")]
    pub const EndpointDiscovery: Self = Self(0x00);
    #[doc(alias = "kUMPStreamMessageStatusEndpointInfoNotification")]
    pub const EndpointInfoNotification: Self = Self(0x01);
    #[doc(alias = "kUMPStreamMessageStatusDeviceIdentityNotification")]
    pub const DeviceIdentityNotification: Self = Self(0x02);
    #[doc(alias = "kUMPStreamMessageStatusEndpointNameNotification")]
    pub const EndpointNameNotification: Self = Self(0x03);
    #[doc(alias = "kUMPStreamMessageStatusProductInstanceIDNotification")]
    pub const ProductInstanceIDNotification: Self = Self(0x04);
    #[doc(alias = "kUMPStreamMessageStatusStreamConfigurationRequest")]
    pub const StreamConfigurationRequest: Self = Self(0x05);
    #[doc(alias = "kUMPStreamMessageStatusStreamConfigurationNotification")]
    pub const StreamConfigurationNotification: Self = Self(0x06);
    #[doc(alias = "kUMPStreamMessageStatusFunctionBlockDiscovery")]
    pub const FunctionBlockDiscovery: Self = Self(0x10);
    #[doc(alias = "kUMPStreamMessageStatusFunctionBlockInfoNotification")]
    pub const FunctionBlockInfoNotification: Self = Self(0x11);
    #[doc(alias = "kUMPStreamMessageStatusFunctionBlockNameNotification")]
    pub const FunctionBlockNameNotification: Self = Self(0x12);
    #[doc(alias = "kUMPStreamMessageStatusStartOfClip")]
    pub const StartOfClip: Self = Self(0x20);
    #[doc(alias = "kUMPStreamMessageStatusEndOfClip")]
    pub const EndOfClip: Self = Self(0x21);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for UMPStreamMessageStatus {
    const ENCODING: Encoding = c_uint::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for UMPStreamMessageStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midinoteattribute?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDINoteAttribute(pub u8);
impl MIDINoteAttribute {
    #[doc(alias = "kMIDINoteAttributeNone")]
    pub const None: Self = Self(0x0);
    #[doc(alias = "kMIDINoteAttributeManufacturerSpecific")]
    pub const ManufacturerSpecific: Self = Self(0x1);
    #[doc(alias = "kMIDINoteAttributeProfileSpecific")]
    pub const ProfileSpecific: Self = Self(0x2);
    #[doc(alias = "kMIDINoteAttributePitch")]
    pub const Pitch: Self = Self(0x3);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDINoteAttribute {
    const ENCODING: Encoding = u8::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDINoteAttribute {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiprogramchangeoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIProgramChangeOptions(pub u8);
bitflags::bitflags! {
    impl MIDIProgramChangeOptions: u8 {
        #[doc(alias = "kMIDIProgramChangeBankValid")]
        const BankValid = 0x1;
    }
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIProgramChangeOptions {
    const ENCODING: Encoding = u8::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIProgramChangeOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midipernotemanagementoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIPerNoteManagementOptions(pub u8);
bitflags::bitflags! {
    impl MIDIPerNoteManagementOptions: u8 {
        #[doc(alias = "kMIDIPerNoteManagementReset")]
        const Reset = 0x1;
        #[doc(alias = "kMIDIPerNoteManagementDetach")]
        const Detach = 0x2;
    }
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIPerNoteManagementOptions {
    const ENCODING: Encoding = u8::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIPerNoteManagementOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// MIDI 1.0 speed information for Function Blocks
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpfunctionblockmidi1info?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIUMPFunctionBlockMIDI1Info(pub i32);
impl MIDIUMPFunctionBlockMIDI1Info {
    #[doc(alias = "kMIDIUMPFunctionBlockMIDI1InfoNotMIDI1")]
    pub const NotMIDI1: Self = Self(0);
    #[doc(alias = "kMIDIUMPFunctionBlockMIDI1InfoUnrestrictedBandwidth")]
    pub const UnrestrictedBandwidth: Self = Self(1);
    #[doc(alias = "kMIDIUMPFunctionBlockMIDI1InfoRestrictedBandwidth")]
    pub const RestrictedBandwidth: Self = Self(2);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIUMPFunctionBlockMIDI1Info {
    const ENCODING: Encoding = i32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIUMPFunctionBlockMIDI1Info {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// UI hint types for Function Blocks
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpfunctionblockuihint?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIUMPFunctionBlockUIHint(pub i32);
impl MIDIUMPFunctionBlockUIHint {
    #[doc(alias = "kMIDIUMPFunctionBlockUIHintUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "kMIDIUMPFunctionBlockUIHintReceiver")]
    pub const Receiver: Self = Self(1);
    #[doc(alias = "kMIDIUMPFunctionBlockUIHintSender")]
    pub const Sender: Self = Self(2);
    #[doc(alias = "kMIDIUMPFunctionBlockUIHintSenderReceiver")]
    pub const SenderReceiver: Self = Self(3);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIUMPFunctionBlockUIHint {
    const ENCODING: Encoding = i32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIUMPFunctionBlockUIHint {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Function Block direction types
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpfunctionblockdirection?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIUMPFunctionBlockDirection(pub i32);
impl MIDIUMPFunctionBlockDirection {
    #[doc(alias = "kMIDIUMPFunctionBlockDirectionUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "kMIDIUMPFunctionBlockDirectionInput")]
    pub const Input: Self = Self(1);
    #[doc(alias = "kMIDIUMPFunctionBlockDirectionOutput")]
    pub const Output: Self = Self(2);
    #[doc(alias = "kMIDIUMPFunctionBlockDirectionBidirectional")]
    pub const Bidirectional: Self = Self(3);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIUMPFunctionBlockDirection {
    const ENCODING: Encoding = i32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIUMPFunctionBlockDirection {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Stream Message Format
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/umpstreammessageformat?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UMPStreamMessageFormat(pub u8);
impl UMPStreamMessageFormat {
    #[doc(alias = "kUMPStreamMessageFormatComplete")]
    pub const Complete: Self = Self(0x00);
    #[doc(alias = "kUMPStreamMessageFormatStart")]
    pub const Start: Self = Self(0x01);
    #[doc(alias = "kUMPStreamMessageFormatContinuing")]
    pub const Continuing: Self = Self(0x02);
    #[doc(alias = "kUMPStreamMessageFormatEnd")]
    pub const End: Self = Self(0x03);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for UMPStreamMessageFormat {
    const ENCODING: Encoding = u8::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for UMPStreamMessageFormat {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// MIDI unsigned integer types
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiuinteger2?language=objc)
pub type MIDIUInteger2 = u8;

/// 2  bits usable; allowed values 0x0~0x3
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiuinteger4?language=objc)
pub type MIDIUInteger4 = u8;

/// 4  bits usable; allowed values 0x0~0xF
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiuinteger7?language=objc)
pub type MIDIUInteger7 = u8;

/// 7  bits usable; allowed values 0x0~0x7F
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiuinteger14?language=objc)
pub type MIDIUInteger14 = u16;

/// 14 bits usable; allowed values 0x0~0x3FFF;
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiuinteger28?language=objc)
pub type MIDIUInteger28 = u32;

/// 28 bits usable; allowed values 0x0~0xFFFFFFF;
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidiuinteger2max?language=objc)
pub static kMIDIUInteger2Max: MIDIUInteger2 = 0x3;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidiuinteger4max?language=objc)
pub static kMIDIUInteger4Max: MIDIUInteger4 = 0xF;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidiuinteger7max?language=objc)
pub static kMIDIUInteger7Max: MIDIUInteger7 = 0x7F;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidiuinteger14max?language=objc)
pub static kMIDIUInteger14Max: MIDIUInteger14 = 0x3FFF;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidiuinteger28max?language=objc)
pub static kMIDIUInteger28Max: MIDIUInteger28 = 0xFFFFFFF;

/// Type for all UMP Groups
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpgroupnumber?language=objc)
pub type MIDIUMPGroupNumber = MIDIUInteger4;

/// MIDI Channel, 0~15 (channels 1 through 16, respectively).
/// Per the MIDI-CI specification, this is always a single nibble, 0x0~0xF.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midichannelnumber?language=objc)
pub type MIDIChannelNumber = MIDIUInteger4;

/// Some MIDI-CI messages use a CI device ID, which is either a UMP group or a reserved 7-bit value
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midicideviceid?language=objc)
pub type MIDICIDeviceID = MIDIUInteger7;

/// Device ID value used to specify that a message is to/from a UMP group.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidideviceidumpgroup?language=objc)
pub static kMIDIDeviceIDUMPGroup: MIDICIDeviceID = 0x7e;

/// Device ID used for to/from Function Block; also used when Function Blocks are not supported.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidideviceidfunctionblock?language=objc)
pub static kMIDIDeviceIDFunctionBlock: MIDICIDeviceID = 0x7f;

/// The unique MIDI-CI negotiation identifier (MUID) used for a MIDICIResponder connection.
/// Per the MIDI-CI specification, this is a randomly assigned unsigned 28-bit integer.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midicimuid?language=objc)
pub type MIDICIMUID = MIDIUInteger28;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midimessage_32?language=objc)
pub type MIDIMessage_32 = u32;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midimessage_64?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MIDIMessage_64 {
    pub word0: u32,
    pub word1: u32,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIMessage_64 {
    const ENCODING: Encoding =
        Encoding::Struct("MIDIMessage_64", &[<u32>::ENCODING, <u32>::ENCODING]);
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIMessage_64 {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midimessage_96?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MIDIMessage_96 {
    pub word0: u32,
    pub word1: u32,
    pub word2: u32,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIMessage_96 {
    const ENCODING: Encoding = Encoding::Struct(
        "MIDIMessage_96",
        &[<u32>::ENCODING, <u32>::ENCODING, <u32>::ENCODING],
    );
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIMessage_96 {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/midimessage_128?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MIDIMessage_128 {
    pub word0: u32,
    pub word1: u32,
    pub word2: u32,
    pub word3: u32,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIMessage_128 {
    const ENCODING: Encoding = Encoding::Struct(
        "MIDIMessage_128",
        &[
            <u32>::ENCODING,
            <u32>::ENCODING,
            <u32>::ENCODING,
            <u32>::ENCODING,
        ],
    );
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIMessage_128 {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

impl MIDIMessageType {
    // TODO: pub fn MIDIMessageTypeForUPWord(word: u32,) -> MIDIMessageType;
}

// TODO: pub fn MIDI1UPChannelVoiceMessage(group: u8,status: u8,channel: u8,data1: u8,data2: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPNoteOff(group: u8,channel: u8,note_number: u8,velocity: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPNoteOn(group: u8,channel: u8,note_number: u8,velocity: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPPolyPressure(group: u8,channel: u8,note_number: u8,pressure: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPControlChange(group: u8,channel: u8,index: u8,data: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPProgramChange(group: u8,channel: u8,program: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPChannelPressure(group: u8,channel: u8,value: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPPitchBend(group: u8,channel: u8,lsb: u8,msb: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPSystemCommon(group: u8,status: u8,byte1: u8,byte2: u8,) -> MIDIMessage_32;

// TODO: pub fn MIDI1UPSysEx(group: u8,status: u8,bytes_used: u8,byte1: u8,byte2: u8,byte3: u8,byte4: u8,byte5: u8,byte6: u8,) -> MIDIMessage_64;

/// [Apple's documentation](https://developer.apple.com/documentation/coremidi/kmidi1upmaxsysexsize?language=objc)
pub static kMIDI1UPMaxSysexSize: u8 = 6;

// TODO: pub fn MIDI1UPSysExArray(group: u8,status: u8,begin: *const Byte,end: *const Byte,) -> MIDIMessage_64;

// TODO: pub fn MIDI2ChannelVoiceMessage(group: u8,status: u8,channel: u8,index: u16,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2NoteOn(group: u8,channel: u8,note_number: u8,attribute_type: u8,attribute_data: u16,velocity: u16,) -> MIDIMessage_64;

// TODO: pub fn MIDI2NoteOff(group: u8,channel: u8,note_number: u8,attribute_type: u8,attribute_data: u16,velocity: u16,) -> MIDIMessage_64;

// TODO: pub fn MIDI2PolyPressure(group: u8,channel: u8,note_number: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2RegisteredPNC(group: u8,channel: u8,note_number: u8,index: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2AssignablePNC(group: u8,channel: u8,note_number: u8,index: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2PerNoteManagment(group: u8,channel: u8,note_number: u8,detach_pn_cs: bool,reset_pn_cs_to_default: bool,) -> MIDIMessage_64;

// TODO: pub fn MIDI2ControlChange(group: u8,channel: u8,index: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2RegisteredControl(group: u8,channel: u8,bank: u8,index: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2AssignableControl(group: u8,channel: u8,bank: u8,index: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2RelRegisteredControl(group: u8,channel: u8,bank: u8,index: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2RelAssignableControl(group: u8,channel: u8,bank: u8,index: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2ProgramChange(group: u8,channel: u8,bank_is_valid: bool,program: u8,bank_msb: u8,bank_lsb: u8,) -> MIDIMessage_64;

// TODO: pub fn MIDI2ChannelPressure(group: u8,channel: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2PitchBend(group: u8,channel: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2PerNotePitchBend(group: u8,channel: u8,note_number: u8,value: u32,) -> MIDIMessage_64;

// TODO: pub fn MIDI2StreamMessage(format: UMPStreamMessageFormat,status: UMPStreamMessageStatus,data1: u16,data2: u32,data3: u32,data4: u32,) -> MIDIMessage_128;

// TODO: pub fn MIDI2StreamMessageFromData(format: UMPStreamMessageFormat,status: UMPStreamMessageStatus,data: *const Byte,length: usize,) -> MIDIMessage_128;

// TODO: pub fn MIDI2EndpointDiscoveryMessage(version_major: u8,version_minor: u8,endpoint_info_request: bool,device_identity_request: bool,endpoint_name_request: bool,product_instance_id_request: bool,stream_configuration_request: bool,) -> MIDIMessage_128;

// TODO: pub fn MIDI2EndpointInfoNotificationMessage(version_major: u8,version_minor: u8,static_function_blocks: bool,number_of_function_blocks: u8,m1: bool,m2: bool,receive_jr_timestamp: bool,transmit_jr_timestamp: bool,) -> MIDIMessage_128;

// TODO: pub fn MIDI2EndpointDeviceIdentityNotificationMessage(device_manufacturer1: MIDIUInteger7,device_manufacturer2: MIDIUInteger7,device_manufacturer3: MIDIUInteger7,device_family: MIDIUInteger14,device_family_model: MIDIUInteger14,revision_level: MIDIUInteger28,) -> MIDIMessage_128;

// TODO: pub fn MIDI2EndpointNameNotificationMessage(format: UMPStreamMessageFormat,data: *const c_char,length: usize,) -> MIDIMessage_128;

// TODO: pub fn MIDI2EndpointProductInstanceIDNotificationMessage(format: UMPStreamMessageFormat,data: *const c_char,length: usize,) -> MIDIMessage_128;

// TODO: pub fn MIDI2StreamConfigurationRequestMessage(protocol: u8,receive_jr_timestamp: bool,transmit_jr_timestamp: bool,) -> MIDIMessage_128;

// TODO: pub fn MIDI2StreamConfigurationNotificationMessage(protocol: u8,receive_jr_timestamp: bool,transmit_jr_timestamp: bool,) -> MIDIMessage_128;

// TODO: pub fn MIDI2FunctionBlockDiscoveryMessage(function_block_number: u8,info_request: bool,name_request: bool,) -> MIDIMessage_128;

// TODO: pub fn MIDI2FunctionBlockInfoNotificationMessage(active: bool,block_number: MIDIUInteger7,ui_hint: MIDIUMPFunctionBlockUIHint,midi1: MIDIUMPFunctionBlockMIDI1Info,direction: MIDIUMPFunctionBlockDirection,first_group: u8,number_of_groups_spanned: u8,ci_version: u8,max_sysex8_streams: u8,) -> MIDIMessage_128;

// TODO: pub fn MIDI2FunctionBlockNameNotificationMessage(format: UMPStreamMessageFormat,block_number: u8,data: *const c_char,length: usize,) -> MIDIMessage_128;

// TODO: pub fn MIDI2StartOfClipMessage() -> MIDIMessage_128;

// TODO: pub fn MIDI2EndOfClipMessage() -> MIDIMessage_128;

// TODO: pub fn MIDINoOpMessage() -> MIDIMessage_32;

// TODO: pub fn MIDIJitterReductionClockMessage(sender_clock_time: u16,) -> MIDIMessage_32;

// TODO: pub fn MIDIJitterReductionTimestampMessage(sender_clock_timestamp: u16,) -> MIDIMessage_32;

// TODO: pub fn MIDIDeltaClockstampTicksPerQuarterNoteMessage(ticks_per_quarter_note: u16,) -> MIDIMessage_32;

// TODO: pub fn MIDITicksSinceLastEventMessage(ticks_since_last_event: u32,) -> MIDIMessage_32;

// TODO: pub fn MIDI2FlexDataMessage(group: MIDIUInteger4,format: MIDIUInteger2,address: MIDIUInteger2,channel: MIDIUInteger4,status_bank: u8,status: u8,data1: u32,data2: u32,data3: u32,) -> MIDIMessage_128;

/// A representation of all possible messages stored in a Universal MIDI packet.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiuniversalmessage?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MIDIUniversalMessage {
    /// determines which variant in the union is active
    pub r#type: MIDIMessageType,
    /// 4 bit MIDI group
    pub group: u8,
    pub reserved: [u8; 3],
}

#[cfg(feature = "objc2")]
unsafe impl Encode for MIDIUniversalMessage {
    const ENCODING: Encoding = Encoding::Struct(
        "MIDIUniversalMessage",
        &[
            <MIDIMessageType>::ENCODING,
            <u8>::ENCODING,
            <[u8; 3]>::ENCODING,
        ],
    );
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for MIDIUniversalMessage {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// A callback function which receives a single MIDIUniversalMessage.
///
/// This callback function is called by MIDIEventListForEachEvent on every UMP
/// that has been parsed from a MIDIEventList. From the provided `MIDIUniversalMessage`
/// the MIDI information can be accessed, e.g.:
///
/// - Parameters:
/// - context: A context provided by the client via call to MIDIEventListForEachEvent.
/// - timeStamp: The timestamp of the current UMP.
/// - message: A filled MIDIUniversalMessage struct that has been parsed from a single UMP.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midieventvisitor?language=objc)
#[cfg(feature = "MIDIServices")]
pub type MIDIEventVisitor =
    Option<unsafe extern "C-unwind" fn(*mut c_void, MIDITimeStamp, MIDIUniversalMessage)>;

#[cfg(feature = "MIDIServices")]
impl MIDIEventList {
    /// Parses UMPs from a MIDIEventList.
    ///
    /// MIDIEventListForEachEvent iterates over all UMPs in the provided MIDIEventList.
    /// It parses each UMP and fills a MIDIUniversalMessage struct. It calls the provided
    /// visitor on each of these UMPs. In case of an unknown UMP the raw UMP words will be provided.
    ///
    ///
    /// Parameter `evtlist`: The MIDIEventList which is to be parsed.
    ///
    ///
    /// Parameter `visitor`: The visitor that is called on each UMP in evtlist.
    ///
    ///
    /// Parameter `visitorContext`: A context for the visitor that is passed to it when being called.
    ///
    /// # Safety
    ///
    /// - `evtlist` must be a valid pointer.
    /// - `visitor` must be implemented correctly.
    /// - `visitor_context` must be a valid pointer.
    #[doc(alias = "MIDIEventListForEachEvent")]
    #[cfg(feature = "MIDIServices")]
    #[inline]
    pub unsafe fn for_each_event(
        evtlist: *const MIDIEventList,
        visitor: MIDIEventVisitor,
        visitor_context: *mut c_void,
    ) {
        extern "C-unwind" {
            fn MIDIEventListForEachEvent(
                evtlist: *const MIDIEventList,
                visitor: MIDIEventVisitor,
                visitor_context: *mut c_void,
            );
        }
        unsafe { MIDIEventListForEachEvent(evtlist, visitor, visitor_context) }
    }
}

extern "C-unwind" {
    #[cfg(feature = "MIDIServices")]
    #[deprecated = "renamed to `MIDIEventList::for_each_event`"]
    pub fn MIDIEventListForEachEvent(
        evtlist: *const MIDIEventList,
        visitor: MIDIEventVisitor,
        visitor_context: *mut c_void,
    );
}