| AAX SDK 2.8.0 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-2024 Avid Technology, Inc.
4 * All rights reserved.
5 *
6 * This file is part of the Avid AAX SDK.
7 *
8 * The AAX SDK is subject to commercial or open-source licensing.
9 *
10 * By using the AAX SDK, you agree to the terms of both the Avid AAX SDK License
11 * Agreement and Avid Privacy Policy.
12 *
13 * AAX SDK License: https://developer.avid.com/aax
14 * Privacy Policy: https://www.avid.com/legal/privacy-policy-statement
15 *
16 * Or: You may also use this code under the terms of the GPL v3 (see
17 * www.gnu.org/licenses).
18 *
19 * THE AAX SDK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 * EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 * DISCLAIMED.
22 */
23
30/*================================================================================================*/
32#ifndef AAX_MIDIUtilities_h
33#define AAX_MIDIUtilities_h
35
36// AAX Includes
37#include "AAX.h"
38
39 namespace AAX
40{
41 //
42 // Some MIDI defines
43 //
44
46 enum EStatusNibble
47 {
48 eStatusNibble_NoteOff = 0x80
49 ,eStatusNibble_NoteOn = 0x90
50 ,eStatusNibble_KeyPressure = 0xA0
51 ,eStatusNibble_ControlChange = 0xB0
52 ,eStatusNibble_ChannelMode = 0xB0
53 ,eStatusNibble_ProgramChange = 0xC0
54 ,eStatusNibble_ChannelPressure = 0xD0
55 ,eStatusNibble_PitchBend = 0xE0
56 ,eStatusNibble_SystemCommon = 0xF0
57 ,eStatusNibble_SystemRealTime = 0xF0
58 };
59
61 enum EStatusByte
62 {
63 eStatusByte_SysExBegin = 0xF0
64 ,eStatusByte_MTCQuarterFrame = 0xF1
65 ,eStatusByte_SongPosition = 0xF2
66 ,eStatusByte_SongSelect = 0xF3
67 ,eStatusByte_TuneRequest = 0xF6
68 ,eStatusByte_SysExEnd = 0xF7
69 ,eStatusByte_TimingClock = 0xF8
70 ,eStatusByte_Start = 0xFA
71 ,eStatusByte_Continue = 0xFB
72 ,eStatusByte_Stop = 0xFC
73 ,eStatusByte_ActiveSensing = 0xFE
74 ,eStatusByte_Reset = 0xFF
75 };
76
78 enum EChannelModeData
79 {
80 eChannelModeData_AllSoundOff = 120
81 ,eChannelModeData_ResetControllers = 121
82 ,eChannelModeData_LocalControl = 122
83 ,eChannelModeData_AllNotesOff = 123
84 ,eChannelModeData_OmniOff = 124
85 ,eChannelModeData_OmniOn = 125
86 ,eChannelModeData_PolyOff = 126
87 ,eChannelModeData_PolyOn = 127
88 };
89
91 enum ESpecialData
92 {
93 eSpecialData_AccentedClick = 0x00
94 ,eSpecialData_UnaccentedClick = 0x01
95 };
96
97
98 //
99 // Basic MIDI utility functions
100 //
101
103 inline bool IsNoteOn(const AAX_CMidiPacket* inPacket)
104 {
105 if (!inPacket) { return false; }
106 const uint8_t sn = (inPacket->mData[0] & 0xF0); // status nibble
107 const uint8_t data2 = inPacket->mData[2];
108 return ((eStatusNibble_NoteOn == sn) &&
109 (0x00 != data2));
110 }
111
113 inline bool IsNoteOff(const AAX_CMidiPacket* inPacket)
114 {
115 if (!inPacket) { return false; }
116 const uint8_t sn = (inPacket->mData[0] & 0xF0); // status nibble
117 const uint8_t data2 = inPacket->mData[2];
118 return ((eStatusNibble_NoteOff == sn) || ((eStatusNibble_NoteOn == sn) && (0x00 == data2)));
119 }
120
122 inline bool IsAllNotesOff(const AAX_CMidiPacket* inPacket)
123 {
124 if (!inPacket) { return false; }
125 const uint8_t sn = (inPacket->mData[0] & 0xF0); // status nibble
126 const uint8_t data1 = inPacket->mData[1];
127 const uint8_t data2 = inPacket->mData[2];
128 if (eStatusNibble_ChannelMode == sn)
129 {
130 if (eChannelModeData_PolyOff == data1)
131 {
132 return true;
133 }
134 else if ((eChannelModeData_AllSoundOff == data1) ||
135 (eChannelModeData_AllNotesOff == data1) ||
136 (eChannelModeData_OmniOff == data1) ||
137 (eChannelModeData_OmniOn == data1) ||
138 (eChannelModeData_PolyOn == data1))
139 {
140 return (0x00 == data2);
141 }
142 }
143
144 return false;
145 }
146
148 inline bool IsAccentedClick(const AAX_CMidiPacket* inPacket)
149 {
150 return ((inPacket) &&
151 (eStatusNibble_NoteOn == (inPacket->mData[0] & 0xF0)) &&
152 (0x00 == (inPacket->mData[0] & 0x0F)) &&
153 (eSpecialData_AccentedClick == inPacket->mData[1]));
154 }
155
157 inline bool IsUnaccentedClick(const AAX_CMidiPacket* inPacket)
158 {
159 return ((inPacket) &&
160 (eStatusNibble_NoteOn == (inPacket->mData[0] & 0xF0)) &&
161 (0x00 == (inPacket->mData[0] & 0x0F)) &&
162 (eSpecialData_UnaccentedClick == inPacket->mData[1]));
163 }
164
166 inline bool IsClick(const AAX_CMidiPacket* inPacket)
167 {
168 return (IsAccentedClick(inPacket) || IsUnaccentedClick(inPacket));
169 }
170} // namespace AAX
171
173#endif // AAX_MIDIUtilities_h
AAX.h
Various utility definitions for AAX.
AAX
Definition: AAX_EnvironmentUtilities.h:72
AAX::EStatusByte
EStatusByte
Values for the status byte in a MIDI packet.
Definition: AAX_MIDIUtilities.h:62
AAX::eStatusByte_MTCQuarterFrame
@ eStatusByte_MTCQuarterFrame
Definition: AAX_MIDIUtilities.h:64
AAX::eStatusByte_Continue
@ eStatusByte_Continue
Definition: AAX_MIDIUtilities.h:71
AAX::eStatusByte_TuneRequest
@ eStatusByte_TuneRequest
Definition: AAX_MIDIUtilities.h:67
AAX::eStatusByte_ActiveSensing
@ eStatusByte_ActiveSensing
Definition: AAX_MIDIUtilities.h:73
AAX::eStatusByte_SongSelect
@ eStatusByte_SongSelect
Definition: AAX_MIDIUtilities.h:66
AAX::eStatusByte_Stop
@ eStatusByte_Stop
Definition: AAX_MIDIUtilities.h:72
AAX::eStatusByte_SongPosition
@ eStatusByte_SongPosition
Definition: AAX_MIDIUtilities.h:65
AAX::eStatusByte_TimingClock
@ eStatusByte_TimingClock
Definition: AAX_MIDIUtilities.h:69
AAX::eStatusByte_Reset
@ eStatusByte_Reset
Definition: AAX_MIDIUtilities.h:74
AAX::eStatusByte_SysExEnd
@ eStatusByte_SysExEnd
Definition: AAX_MIDIUtilities.h:68
AAX::eStatusByte_Start
@ eStatusByte_Start
Definition: AAX_MIDIUtilities.h:70
AAX::eStatusByte_SysExBegin
@ eStatusByte_SysExBegin
Definition: AAX_MIDIUtilities.h:63
AAX::EStatusNibble
EStatusNibble
Values for the status nibble in a MIDI packet.
Definition: AAX_MIDIUtilities.h:47
AAX::eStatusNibble_SystemCommon
@ eStatusNibble_SystemCommon
Definition: AAX_MIDIUtilities.h:56
AAX::eStatusNibble_ChannelPressure
@ eStatusNibble_ChannelPressure
Definition: AAX_MIDIUtilities.h:54
AAX::eStatusNibble_PitchBend
@ eStatusNibble_PitchBend
Definition: AAX_MIDIUtilities.h:55
AAX::eStatusNibble_NoteOff
@ eStatusNibble_NoteOff
Definition: AAX_MIDIUtilities.h:48
AAX::eStatusNibble_ControlChange
@ eStatusNibble_ControlChange
Definition: AAX_MIDIUtilities.h:51
AAX::eStatusNibble_SystemRealTime
@ eStatusNibble_SystemRealTime
Definition: AAX_MIDIUtilities.h:57
AAX::eStatusNibble_NoteOn
@ eStatusNibble_NoteOn
Definition: AAX_MIDIUtilities.h:49
AAX::eStatusNibble_KeyPressure
@ eStatusNibble_KeyPressure
Definition: AAX_MIDIUtilities.h:50
AAX::eStatusNibble_ChannelMode
@ eStatusNibble_ChannelMode
Definition: AAX_MIDIUtilities.h:52
AAX::eStatusNibble_ProgramChange
@ eStatusNibble_ProgramChange
Definition: AAX_MIDIUtilities.h:53
AAX::IsNoteOn
bool IsNoteOn(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a Note On message.
Definition: AAX_MIDIUtilities.h:103
AAX::IsUnaccentedClick
bool IsUnaccentedClick(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a special Pro Tools unaccented click message.
Definition: AAX_MIDIUtilities.h:157
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:122
AAX::EChannelModeData
EChannelModeData
Values for the first data byte in a Channel Mode Message MIDI packet.
Definition: AAX_MIDIUtilities.h:79
AAX::eChannelModeData_OmniOn
@ eChannelModeData_OmniOn
Definition: AAX_MIDIUtilities.h:85
AAX::eChannelModeData_ResetControllers
@ eChannelModeData_ResetControllers
Definition: AAX_MIDIUtilities.h:81
AAX::eChannelModeData_OmniOff
@ eChannelModeData_OmniOff
Definition: AAX_MIDIUtilities.h:84
AAX::eChannelModeData_AllSoundOff
@ eChannelModeData_AllSoundOff
Definition: AAX_MIDIUtilities.h:80
AAX::eChannelModeData_PolyOff
@ eChannelModeData_PolyOff
Definition: AAX_MIDIUtilities.h:86
AAX::eChannelModeData_PolyOn
@ eChannelModeData_PolyOn
Definition: AAX_MIDIUtilities.h:87
AAX::eChannelModeData_LocalControl
@ eChannelModeData_LocalControl
Definition: AAX_MIDIUtilities.h:82
AAX::eChannelModeData_AllNotesOff
@ eChannelModeData_AllNotesOff
Definition: AAX_MIDIUtilities.h:83
AAX::ESpecialData
ESpecialData
Special message data for the first data byte in a message.
Definition: AAX_MIDIUtilities.h:92
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:94
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:93
AAX::IsClick
bool IsClick(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a special Pro Tools click message.
Definition: AAX_MIDIUtilities.h:166
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:113
AAX::IsAccentedClick
bool IsAccentedClick(const AAX_CMidiPacket *inPacket)
Returns true if inPacket is a special Pro Tools accented click message.
Definition: AAX_MIDIUtilities.h:148
AAX_CMidiPacket
Packet structure for MIDI data.
Definition: AAX.h:649
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:652