1 module midi2.types.enums;
2 
3 /**
4  * midi2 - MIDI 2.0 implementation.
5  *
6  * midi2.types.enums:
7  *
8  * Contains enumerators and other constants of various MIDI 2.0 commands, etc.
9  */
10 
11 /**
12  * Message Type allocation.
13  * 
14  * The first four bits of every messabe contain the Message Type. It is used to classify message functions as well
15  * as the sizes of given UMPs (see array `UMPSizes`).
16  *
17  * Currently only range 0x0 - 0x5 is defined. UMP sizes for those packets are included, but using them as of now
18  * for custom commands might break compatibility.
19  */
20 enum MessageType : ubyte {
21 	Utility		=	0x0,	///Utility messages
22 	SysCommMsg	=	0x1,	///System Real Time and System Common Messages (except System Exclusive)
23 	MIDI1		=	0x2,	///MIDI 1.0 Channel Voice Messages
24 	Data64		=	0x3,	///Data Messages (including System Exclusive)
25 	MIDI2		=	0x4,	///MIDI 2.0 Channel Voice Messages
26 	Data128		=	0x5,	///Data Messages
27 }
28 /**
29  * MIDI 1.0 command codes.
30  *
31  * Mainly to provide backwards compatibility with older devices.
32  */
33 enum MIDI1_0Cmd : ubyte {
34 	NoteOff		=	0x8,
35 	NoteOn		=	0x9,
36 	PolyAftrTch	=	0xA,	///Polyphonic aftertouch
37 	CtrlCh		=	0xB,	///Controller change
38 	PrgCh		=	0xC,	///Program change
39 	ChAftrTch	=	0xD,	///Channel aftertouch
40 	PitchBend	=	0xE,
41 	SysEx		=	0xF,	///System exclusive (not included in MIDI 2.0 specs, but added here for e.g. conversions)
42 }
43 /**
44  * System Exclusive Message status values
45  */
46 enum SysExSt : ubyte {
47 	Complete	=	0x0,	///Complete system exclusive message in one UMP.
48 	Start		=	0x1,	///Start of system exclusive message.
49 	Cont		=	0x2,	///Continuation of system exclusive message.
50 	End			=	0x3,	///End of system exclusive message.
51 }
52 /**
53  * MIDI 2.0 command codes.
54  */
55 enum MIDI2_0Cmd : ubyte {
56 	NoteOff		=	0x8,
57 	NoteOn		=	0x9,
58 	PolyAftrTch	=	0xA,	///Polyphonic aftertouch
59 	PolyCtrlChR	=	0x0,	///Per-note controller change (registered)
60 	PolyCtrlCh	=	0x1,	///Per-note controller change (assignable)
61 	NoteManaMsg	=	0xF,	///Per-note management message
62 	CtrlChOld	=	0xB,	///Controller change (for MIDI 1.0 compatibility)
63 	CtrlChR		=	0x2,	///Registered controller change with banks
64 	CtrlCh		=	0x3,	///Assignable controller change with banks
65 	RelCtrlChR	=	0x4,	///Registered, relative controller change with banks
66 	RelCtrlCh	=	0x5,	///Assignable, relative controller change with banks
67 	PrgCh		=	0xC,	///Program change
68 	ChAftrTch	=	0xD,	///Channel aftertouch
69 	PitchBend	=	0xE,	///Pitch bend (monophonic)
70 	PolyPitchBend=	0x6,	///Polyphonic pitch bend
71 }
72 /**
73  * MIDI 2.0 note attribute types.
74  */
75 enum MIDI2_0NoteAttrTyp : ubyte {
76 	None		=	0x0,
77 	MfgrSpec	=	0x1,	///Manufacturer specific
78 	ProfSpec	=	0x2,	///Profile specific
79 	Pitch		=	0x3,	///Pitch
80 }
81 /**
82  * Utility message status codes.
83  */
84 enum UtilityMsgSt : ubyte {
85 	NoOp		=	0x0,	///No operation
86 	JRClock		=	0x1,	///Jitter reduction clock
87 	JRTimestamp	=	0x2,	///Jitter reduction timestamp
88 }
89 /** 
90  * System common message codes.
91  */
92 enum SysCommMsg : ubyte {
93 	MIDITimeCode		=	0xF1,
94 	SongPosMarker		=	0xF2,	///Song position marker
95 	SongSelect			=	0xF3,
96 	TuneReq				=	0xF6,	///Tune request
97 	TimingClk			=	0xF8,	///Timing clock
98 	Start				=	0xFA,
99 	Continue			=	0xFB,
100 	Stop				=	0xFC,
101 	ActSens				=	0xFE,	///Active sensing
102 	Reset				=	0xFF,
103 }
104 
105 /**
106  * Contains Universal MIDI Packet (UMP) sizes in bits.
107  */
108 immutable uint[16] umpSizes = [32,32,32,64,64,128,32,32,64,64,64,96,96,128,128,128];