| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

Loading...
Searching...
No Matches
AAX_MIDIUtilities.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 * Copyright 2015, 2023 Avid Technology, Inc.
4 * All rights reserved.
5 *
6 * CONFIDENTIAL: this document contains confidential information of Avid. Do
7 * not disclose to any third party. Use of the information contained in this
8 * document is subject to an Avid SDK license.
9 */
10
17/*================================================================================================*/
19#ifndef AAX_MIDIUtilities_h
20#define AAX_MIDIUtilities_h
22
23// AAX Includes
24#include "AAX.h"
25
26 namespace AAX
27{
28 //
29 // Some MIDI defines
30 //
31
33 enum EStatusNibble
34 {
35 eStatusNibble_NoteOff = 0x80
36 ,eStatusNibble_NoteOn = 0x90
37 ,eStatusNibble_KeyPressure = 0xA0
38 ,eStatusNibble_ControlChange = 0xB0
39 ,eStatusNibble_ChannelMode = 0xB0
40 ,eStatusNibble_ProgramChange = 0xC0
41 ,eStatusNibble_ChannelPressure = 0xD0
42 ,eStatusNibble_PitchBend = 0xE0
43 ,eStatusNibble_SystemCommon = 0xF0
44 ,eStatusNibble_SystemRealTime = 0xF0
45 };
46
48 enum EStatusByte
49 {
50 eStatusByte_SysExBegin = 0xF0
51 ,eStatusByte_MTCQuarterFrame = 0xF1
52 ,eStatusByte_SongPosition = 0xF2
53 ,eStatusByte_SongSelect = 0xF3
54 ,eStatusByte_TuneRequest = 0xF6
55 ,eStatusByte_SysExEnd = 0xF7
56 ,eStatusByte_TimingClock = 0xF8
57 ,eStatusByte_Start = 0xFA
58 ,eStatusByte_Continue = 0xFB
59 ,eStatusByte_Stop = 0xFC
60 ,eStatusByte_ActiveSensing = 0xFE
61 ,eStatusByte_Reset = 0xFF
62 };
63
65 enum EChannelModeData
66 {
67 eChannelModeData_AllSoundOff = 120
68 ,eChannelModeData_ResetControllers = 121
69 ,eChannelModeData_LocalControl = 122
70 ,eChannelModeData_AllNotesOff = 123
71 ,eChannelModeData_OmniOff = 124
72 ,eChannelModeData_OmniOn = 125
73 ,eChannelModeData_PolyOff = 126
74 ,eChannelModeData_PolyOn = 127
75 };
76
78 enum ESpecialData
79 {
80 eSpecialData_AccentedClick = 0x00
81 ,eSpecialData_UnaccentedClick = 0x01
82 };
83
84
85 //
86 // Basic MIDI utility functions
87 //
88
90 inline bool IsNoteOn(const AAX_CMidiPacket* inPacket)
91 {
92 if (!inPacket) { return false; }
93 const uint8_t sn = (inPacket->mData[0] & 0xF0); // status nibble
94 const uint8_t data2 = inPacket->mData[2];
95 return ((eStatusNibble_NoteOn == sn) &&
96 (0x00 != data2));
97 }
98
100 inline bool IsNoteOff(const AAX_CMidiPacket* inPacket)
101 {
102 if (!inPacket) { return false; }
103 const uint8_t sn = (inPacket->mData[0] & 0xF0); // status nibble
104 const uint8_t data2 = inPacket->mData[2];
105 return ((eStatusNibble_NoteOff == sn) || ((eStatusNibble_NoteOn == sn) && (0x00 == data2)));
106 }
107
109 inline bool IsAllNotesOff(const AAX_CMidiPacket* inPacket)
110 {
111 if (!inPacket) { return false; }
112 const uint8_t sn = (inPacket->mData[0] & 0xF0); // status nibble
113 const uint8_t data1 = inPacket->mData[1];
114 const uint8_t data2 = inPacket->mData[2];
115 if (eStatusNibble_ChannelMode == sn)
116 {
117 if (eChannelModeData_PolyOff == data1)
118 {
119 return true;
120 }
121 else if ((eChannelModeData_AllSoundOff == data1) ||
122 (eChannelModeData_AllNotesOff == data1) ||
123 (eChannelModeData_OmniOff == data1) ||
124 (eChannelModeData_OmniOn == data1) ||
125 (eChannelModeData_PolyOn == data1))
126 {
127 return (0x00 == data2);
128 }
129 }
130
131 return false;
132 }
133
135 inline bool IsAccentedClick(const AAX_CMidiPacket* inPacket)
136 {
137 return ((inPacket) &&
138 (eStatusNibble_NoteOn == (inPacket->mData[0] & 0xF0)) &&
139 (0x00 == (inPacket->mData[0] & 0x0F)) &&
140 (eSpecialData_AccentedClick == inPacket->mData[1]));
141 }
142
144 inline bool IsUnaccentedClick(const AAX_CMidiPacket* inPacket)
145 {
146 return ((inPacket) &&
147 (eStatusNibble_NoteOn == (inPacket->mData[0] & 0xF0)) &&
148 (0x00 == (inPacket->mData[0] & 0x0F)) &&
149 (eSpecialData_UnaccentedClick == inPacket->mData[1]));
150 }
151
153 inline bool IsClick(const AAX_CMidiPacket* inPacket)
154 {
155 return (IsAccentedClick(inPacket) || IsUnaccentedClick(inPacket));
156 }
157} // namespace AAX
158
160#endif // AAX_MIDIUtilities_h
AAX.h
Various utility definitions for AAX.
AAX
Definition: AAX_EnvironmentUtilities.h:59
AAX::EStatusByte
EStatusByte
Values for the status byte in a MIDI packet.
Definition: AAX_MIDIUtilities.h:49
AAX::eStatusByte_MTCQuarterFrame
@ eStatusByte_MTCQuarterFrame
Definition: AAX_MIDIUtilities.h:51
AAX::eStatusByte_Continue
@ eStatusByte_Continue
Definition: AAX_MIDIUtilities.h:58
AAX::eStatusByte_TuneRequest
@ eStatusByte_TuneRequest
Definition: AAX_MIDIUtilities.h:54
AAX::eStatusByte_ActiveSensing
@ eStatusByte_ActiveSensing
Definition: AAX_MIDIUtilities.h:60
AAX::eStatusByte_SongSelect
@ eStatusByte_SongSelect
Definition: AAX_MIDIUtilities.h:53
AAX::eStatusByte_Stop
@ eStatusByte_Stop
Definition: AAX_MIDIUtilities.h:59
AAX::eStatusByte_SongPosition
@ eStatusByte_SongPosition
Definition: AAX_MIDIUtilities.h:52
AAX::eStatusByte_TimingClock
@ eStatusByte_TimingClock
Definition: AAX_MIDIUtilities.h:56
AAX::eStatusByte_Reset
@ eStatusByte_Reset
Definition: AAX_MIDIUtilities.h:61
AAX::eStatusByte_SysExEnd
@ eStatusByte_SysExEnd
Definition: AAX_MIDIUtilities.h:55
AAX::eStatusByte_Start
@ eStatusByte_Start
Definition: AAX_MIDIUtilities.h:57
AAX::eStatusByte_SysExBegin
@ eStatusByte_SysExBegin
Definition: AAX_MIDIUtilities.h:50
AAX::EStatusNibble
EStatusNibble
Values for the status nibble in a MIDI packet.
Definition: AAX_MIDIUtilities.h:34
AAX::eStatusNibble_SystemCommon
@ eStatusNibble_SystemCommon
Definition: AAX_MIDIUtilities.h:43
AAX::eStatusNibble_ChannelPressure
@ eStatusNibble_ChannelPressure
Definition: AAX_MIDIUtilities.h:41
AAX::eStatusNibble_PitchBend
@ eStatusNibble_PitchBend
Definition: AAX_MIDIUtilities.h:42
AAX::eStatusNibble_NoteOff
@ eStatusNibble_NoteOff
Definition: AAX_MIDIUtilities.h:35
AAX::eStatusNibble_ControlChange
@ eStatusNibble_ControlChange
Definition: AAX_MIDIUtilities.h:38
AAX::eStatusNibble_SystemRealTime
@ eStatusNibble_SystemRealTime
Definition: AAX_MIDIUtilities.h:44
AAX::eStatusNibble_NoteOn
@ eStatusNibble_NoteOn
Definition: AAX_MIDIUtilities.h:36
AAX::eStatusNibble_KeyPressure
@ eStatusNibble_KeyPressure
Definition: AAX_MIDIUtilities.h:37
AAX::eStatusNibble_ChannelMode
@ eStatusNibble_ChannelMode
Definition: AAX_MIDIUtilities.h:39
AAX::eStatusNibble_ProgramChange
@ eStatusNibble_ProgramChange
Definition: AAX_MIDIUtilities.h:40
AAX::IsNoteOn
bool IsNoteOn(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a Note On message.
Definition: AAX_MIDIUtilities.h:90
AAX::IsUnaccentedClick
bool IsUnaccentedClick(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a special Pro Tools unaccented click message.
Definition: AAX_MIDIUtilities.h:144
AAX::IsAllNotesOff
bool IsAllNotesOff(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is an All Sound Off or All Notes Off message.
Definition: AAX_MIDIUtilities.h:109
AAX::EChannelModeData
EChannelModeData
Values for the first data byte in a Channel Mode Message MIDI packet.
Definition: AAX_MIDIUtilities.h:66
AAX::eChannelModeData_OmniOn
@ eChannelModeData_OmniOn
Definition: AAX_MIDIUtilities.h:72
AAX::eChannelModeData_ResetControllers
@ eChannelModeData_ResetControllers
Definition: AAX_MIDIUtilities.h:68
AAX::eChannelModeData_OmniOff
@ eChannelModeData_OmniOff
Definition: AAX_MIDIUtilities.h:71
AAX::eChannelModeData_AllSoundOff
@ eChannelModeData_AllSoundOff
Definition: AAX_MIDIUtilities.h:67
AAX::eChannelModeData_PolyOff
@ eChannelModeData_PolyOff
Definition: AAX_MIDIUtilities.h:73
AAX::eChannelModeData_PolyOn
@ eChannelModeData_PolyOn
Definition: AAX_MIDIUtilities.h:74
AAX::eChannelModeData_LocalControl
@ eChannelModeData_LocalControl
Definition: AAX_MIDIUtilities.h:69
AAX::eChannelModeData_AllNotesOff
@ eChannelModeData_AllNotesOff
Definition: AAX_MIDIUtilities.h:70
AAX::ESpecialData
ESpecialData
Special message data for the first data byte in a message.
Definition: AAX_MIDIUtilities.h:79
AAX::eSpecialData_UnaccentedClick
@ eSpecialData_UnaccentedClick
For use when the high status nibble is eStatusNibble_NoteOn and the low status nibble is zero.
Definition: AAX_MIDIUtilities.h:81
AAX::eSpecialData_AccentedClick
@ eSpecialData_AccentedClick
For use when the high status nibble is eStatusNibble_NoteOn and the low status nibble is zero.
Definition: AAX_MIDIUtilities.h:80
AAX::IsClick
bool IsClick(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a special Pro Tools click message.
Definition: AAX_MIDIUtilities.h:153
AAX::IsNoteOff
bool IsNoteOff(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a Note Off message, or a Note On message with velocity zero.
Definition: AAX_MIDIUtilities.h:100
AAX::IsAccentedClick
bool IsAccentedClick(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a special Pro Tools accented click message.
Definition: AAX_MIDIUtilities.h:135
AAX_CMidiPacket
Packet structure for MIDI data.
Definition: AAX.h:636
AAX_CMidiPacket::mData
unsigned char mData[4]
The MIDI message itself. Each array element is one byte of the message, with the 0th element being th...
Definition: AAX.h:639