@@ -81,6 +81,157 @@ namespace mackieControl {
8181 this ->isChannelPressure ();
8282 }
8383
84+ std::tuple<SysExMessage> Message::getSysExData () const {
85+ if (this ->message .getSysExDataSize () < 5 ) { return { static_cast <SysExMessage>(-1 ) }; }
86+ return { static_cast <SysExMessage>(this ->message .getSysExData ()[4 ]) };
87+ }
88+
89+ std::tuple<std::array<uint8_t , 7 >, uint32_t > Message::getHostConnectionQueryData () const {
90+ if (this ->message .getSysExDataSize () <
91+ 5 + sizeof (std::array<uint8_t , 7 >) + sizeof (uint32_t )) { return std::tuple<std::array<uint8_t , 7 >, uint32_t >{}; }
92+
93+ std::array<uint8_t , 7 > bytes;
94+ std::memcpy (bytes.data (), &(this ->message .getSysExData ()[5 ]), sizeof (bytes));
95+
96+ return { bytes, static_cast <uint32_t >(this ->message .getSysExData ()[5 + sizeof (bytes)]) };
97+ }
98+
99+ std::tuple<std::array<uint8_t , 7 >, uint32_t > Message::getHostConnectionReplyData () const {
100+ if (this ->message .getSysExDataSize () <
101+ 5 + sizeof (std::array<uint8_t , 7 >) + sizeof (uint32_t )) {
102+ return std::tuple<std::array<uint8_t , 7 >, uint32_t >{};
103+ }
104+
105+ std::array<uint8_t , 7 > bytes;
106+ std::memcpy (bytes.data (), &(this ->message .getSysExData ()[5 ]), sizeof (bytes));
107+
108+ return { bytes, static_cast <uint32_t >(this ->message .getSysExData ()[5 + sizeof (bytes)]) };
109+ }
110+
111+ std::tuple<std::array<uint8_t , 7 >> Message::getHostConnectionConfirmationData () const {
112+ if (this ->message .getSysExDataSize () < 5 + sizeof (std::array<uint8_t , 7 >)) {
113+ return std::tuple<std::array<uint8_t , 7 >>{};
114+ }
115+
116+ std::array<uint8_t , 7 > bytes;
117+ std::memcpy (bytes.data (), &(this ->message .getSysExData ()[5 ]), sizeof (bytes));
118+
119+ return { bytes };
120+ }
121+
122+ std::tuple<std::array<uint8_t , 7 >> Message::getHostConnectionErrorData () const {
123+ if (this ->message .getSysExDataSize () < 5 + sizeof (std::array<uint8_t , 7 >)) {
124+ return std::tuple<std::array<uint8_t , 7 >>{};
125+ }
126+
127+ std::array<uint8_t , 7 > bytes;
128+ std::memcpy (bytes.data (), &(this ->message .getSysExData ()[5 ]), sizeof (bytes));
129+
130+ return { bytes };
131+ }
132+
133+ std::tuple<uint8_t , uint8_t > Message::getLCDBackLightSaverData () const {
134+ if (this ->message .getSysExDataSize () < 5 + 1 ) {
135+ return std::tuple<uint8_t , uint8_t >{};
136+ }
137+
138+ return { static_cast <uint8_t >(this ->message .getSysExData ()[5 ]),
139+ (this ->message .getSysExDataSize () >= 7 ) ? static_cast <uint8_t >(this ->message .getSysExData ()[6 ]) : 0 };
140+ }
141+
142+ std::tuple<uint8_t > Message::getTouchlessMovableFadersData () const {
143+ if (this ->message .getSysExDataSize () < 5 + 1 ) {
144+ return std::tuple<uint8_t >{};
145+ }
146+
147+ return { static_cast <uint8_t >(this ->message .getSysExData ()[5 ]) };
148+ }
149+
150+ std::tuple<uint8_t , uint8_t > Message::getFaderTouchSensitivityData () const {
151+ if (this ->message .getSysExDataSize () < 5 + 2 ) {
152+ return std::tuple<uint8_t , uint8_t >{};
153+ }
154+
155+ return { static_cast <uint8_t >(this ->message .getSysExData ()[5 ]),
156+ static_cast <uint8_t >(this ->message .getSysExData ()[6 ]) };
157+ }
158+
159+ std::tuple<const uint8_t *, int > Message::getTimeCodeBBTDisplayData () const {
160+ if (this ->message .getSysExDataSize () < 5 + 1 + 1 + 1 ) {
161+ return std::tuple<uint8_t *, int >{};
162+ }
163+
164+ return { &(this ->message .getSysExData ()[6 ]),
165+ this ->message .getSysExDataSize () - 1 - 6 };
166+ }
167+
168+ std::tuple<std::array<uint8_t , 2 >> Message::getAssignment7SegmentDisplayData () const {
169+ if (this ->message .getSysExDataSize () < 5 + 1 + sizeof (std::array<uint8_t , 2 >)) {
170+ return std::tuple<std::array<uint8_t , 2 >>{};
171+ }
172+
173+ std::array<uint8_t , 2 > bytes;
174+ std::memcpy (bytes.data (), &(this ->message .getSysExData ()[6 ]), sizeof (bytes));
175+
176+ return { bytes };
177+ }
178+
179+ std::tuple<uint8_t , const char *, int > Message::getLCDData () const {
180+ if (this ->message .getSysExDataSize () < 5 + 1 + 1 ) {
181+ return std::tuple<uint8_t , char *, int >{};
182+ }
183+
184+ return { static_cast <uint8_t >(this ->message .getSysExData ()[5 ]),
185+ reinterpret_cast <const char *>(&(this ->message .getSysExData ()[6 ])) ,
186+ this ->message .getSysExDataSize () - 6 };
187+ }
188+
189+ std::tuple<const char *, int > Message::getVersionReplyData () const {
190+ if (this ->message .getSysExDataSize () < 5 + 1 + 1 ) {
191+ return std::tuple<char *, int >{};
192+ }
193+
194+ return { reinterpret_cast <const char *>(&(this ->message .getSysExData ()[6 ])) ,
195+ this ->message .getSysExDataSize () - 6 };
196+ }
197+
198+ std::tuple<uint8_t , uint8_t > Message::getChannelMeterModeData () const {
199+ if (this ->message .getSysExDataSize () < 5 + 2 ) {
200+ return std::tuple<uint8_t , uint8_t >{};
201+ }
202+
203+ return { static_cast <uint8_t >(this ->message .getSysExData ()[5 ]),
204+ static_cast <uint8_t >(this ->message .getSysExData ()[6 ]) };
205+ }
206+
207+ std::tuple<uint8_t > Message::getGlobalLCDMeterModeData () const {
208+ if (this ->message .getSysExDataSize () < 5 + 1 ) {
209+ return std::tuple<uint8_t >{};
210+ }
211+
212+ return { static_cast <uint8_t >(this ->message .getSysExData ()[5 ]) };
213+ }
214+
215+ std::tuple<NoteMessage, VelocityMessage> Message::getNoteData () const {
216+ return { static_cast <NoteMessage>(this ->message .getNoteNumber ()),
217+ static_cast <VelocityMessage>(this ->message .getVelocity ()) };
218+ }
219+
220+ std::tuple<CCMessage, int > Message::getCCData () const {
221+ return { static_cast <CCMessage>(this ->message .getControllerNumber ()),
222+ this ->message .getControllerValue () };
223+ }
224+
225+ std::tuple<int , int > Message::getPitchWheelData () const {
226+ return { this ->message .getChannel (),
227+ this ->message .getPitchWheelValue () };
228+ }
229+
230+ std::tuple<int , int > Message::getChannelPressureData () const {
231+ int value = this ->message .getChannelPressureValue ();
232+ return { value / 16 + 1 ,value % 16 };
233+ }
234+
84235 Message Message::fromMidi (const juce::MidiMessage& message) {
85236 return Message{ message };
86237 }
@@ -96,36 +247,36 @@ namespace mackieControl {
96247 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
97248 }
98249
99- Message Message::createHostConnectionQuery (uint8_t serialNum[ 7 ] , uint32_t challengeCode) {
100- uint8_t bytes[5 + 7 + sizeof (challengeCode)] = {};
250+ Message Message::createHostConnectionQuery (const std::array< uint8_t , 7 >& serialNum , uint32_t challengeCode) {
251+ uint8_t bytes[5 + sizeof (serialNum) + sizeof (challengeCode)] = {};
101252 bytes[4 ] = static_cast <uint8_t >(SysExMessage::HostConnectionQuery);
102- std::memcpy (&bytes[5 ], serialNum, 7 );
103- std::memcpy (&bytes[5 + 7 ], &challengeCode, sizeof (challengeCode));
253+ std::memcpy (&bytes[5 ], serialNum. data (), sizeof (serialNum) );
254+ std::memcpy (&bytes[5 + sizeof (serialNum) ], &challengeCode, sizeof (challengeCode));
104255
105256 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
106257 }
107258
108- Message Message::createHostConnectionReply (uint8_t serialNum[ 7 ] , uint32_t responseCode) {
109- uint8_t bytes[5 + 7 + sizeof (responseCode)] = {};
259+ Message Message::createHostConnectionReply (const std::array< uint8_t , 7 >& serialNum , uint32_t responseCode) {
260+ uint8_t bytes[5 + sizeof (serialNum) + sizeof (responseCode)] = {};
110261 bytes[4 ] = static_cast <uint8_t >(SysExMessage::HostConnectionReply);
111- std::memcpy (&bytes[5 ], serialNum, 7 );
112- std::memcpy (&bytes[5 + 7 ], &responseCode, sizeof (responseCode));
262+ std::memcpy (&bytes[5 ], serialNum. data (), sizeof (serialNum) );
263+ std::memcpy (&bytes[5 + sizeof (serialNum) ], &responseCode, sizeof (responseCode));
113264
114265 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
115266 }
116267
117- Message Message::createHostConnectionConfirmation (uint8_t serialNum[ 7 ] ) {
118- uint8_t bytes[5 + 7 ] = {};
268+ Message Message::createHostConnectionConfirmation (const std::array< uint8_t , 7 >& serialNum ) {
269+ uint8_t bytes[5 + sizeof (serialNum) ] = {};
119270 bytes[4 ] = static_cast <uint8_t >(SysExMessage::HostConnectionConfirmation);
120- std::memcpy (&bytes[5 ], serialNum, 7 );
271+ std::memcpy (&bytes[5 ], serialNum. data (), sizeof (serialNum) );
121272
122273 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
123274 }
124275
125- Message Message::createHostConnectionError (uint8_t serialNum[ 7 ] ) {
126- uint8_t bytes[5 + 7 ] = {};
276+ Message Message::createHostConnectionError (const std::array< uint8_t , 7 >& serialNum ) {
277+ uint8_t bytes[5 + sizeof (serialNum) ] = {};
127278 bytes[4 ] = static_cast <uint8_t >(SysExMessage::HostConnectionError);
128- std::memcpy (&bytes[5 ], serialNum, 7 );
279+ std::memcpy (&bytes[5 ], serialNum. data (), sizeof (serialNum) );
129280
130281 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
131282 }
@@ -171,7 +322,7 @@ namespace mackieControl {
171322 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
172323 }
173324
174- Message Message::createTimeCodeBBTDisplay (uint8_t * data, int size) {
325+ Message Message::createTimeCodeBBTDisplay (const uint8_t * data, int size) {
175326 int byteSize = 5 + 1 + size + 1 ;
176327 auto bytes = std::unique_ptr<uint8_t []>(new uint8_t [byteSize]());
177328
@@ -181,15 +332,15 @@ namespace mackieControl {
181332 return Message{ juce::MidiMessage::createSysExMessage (bytes.get (), byteSize) };
182333 }
183334
184- Message Message::createAssignment7SegmentDisplay (uint8_t data[ 2 ] ) {
185- uint8_t bytes[5 + 1 + 2 ] = {};
335+ Message Message::createAssignment7SegmentDisplay (const std::array< uint8_t , 2 >& data ) {
336+ uint8_t bytes[5 + 1 + sizeof (data) ] = {};
186337 bytes[4 ] = static_cast <uint8_t >(SysExMessage::Assignment7SegmentDisplay);
187- std::memcpy (&bytes[6 ], data, 2 );
338+ std::memcpy (&bytes[6 ], data. data (), sizeof (data) );
188339
189340 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
190341 }
191342
192- Message Message::createLCD (uint8_t place, char * data, int size) {
343+ Message Message::createLCD (uint8_t place, const char * data, int size) {
193344 int byteSize = 5 + 1 + size;
194345 auto bytes = std::unique_ptr<uint8_t []>(new uint8_t [byteSize]());
195346
@@ -207,7 +358,7 @@ namespace mackieControl {
207358 return Message{ juce::MidiMessage::createSysExMessage (bytes, sizeof (bytes)) };
208359 }
209360
210- Message Message::createVersionReply (char * data, int size) {
361+ Message Message::createVersionReply (const char * data, int size) {
211362 int byteSize = 5 + 1 + size;
212363 auto bytes = std::unique_ptr<uint8_t []>(new uint8_t [byteSize]());
213364
@@ -272,11 +423,18 @@ namespace mackieControl {
272423 }
273424
274425 uint8_t Message::charToMackie (char c) {
275- if (c >= ' a' && c <= ' z' ) { return static_cast < uint8_t >(( c - ' a' ) + 1 ) ; }
276- else if (c >= ' A' && c <= ' Z' ) { return static_cast < uint8_t >(( c - ' A' ) + 1 ) ; }
277- else if (c >= ' 0' && c <= ' 9' ) { return static_cast < uint8_t >((c - ' 0 ' ) + 0x30 ) ; }
426+ if (c >= ' a' && c <= ' z' ) { return ( c - ' a' ) + 1 ; }
427+ else if (c >= ' A' && c <= ' Z' ) { return ( c - ' A' ) + 1 ; }
428+ else if (c >= ' 0' && c <= ' 9' ) { return c ; }
278429
279- return 0x20 ;
430+ return ' ' ;
431+ }
432+
433+ char Message::mackieToChar (uint8_t c) {
434+ if ((c - 1 ) >= 0 && (c - 1 ) <= ' Z' - ' A' ) { return ' A' + (c - 1 ); }
435+ else if (c >= ' 0' && c <= ' 9' ) { return c; }
436+
437+ return ' ' ;
280438 }
281439
282440 uint8_t Message::toLCDPlace (bool lowerLine, uint8_t index) {
@@ -303,4 +461,26 @@ namespace mackieControl {
303461 int Message::toJogWheelValue (WheelType type, int ticks) {
304462 return static_cast <int >(type) * 64 + ticks;
305463 }
464+
465+ std::tuple<bool , uint8_t > Message::convertLCDPlace (uint8_t place) {
466+ return { place >= 56 , (place >= 56 ) ? (place - 56Ui8) : place };
467+ }
468+
469+ std::tuple<bool , bool , bool > Message::convertChannelMeterMode (uint8_t mode) {
470+ return { mode & (1 << 0 ),
471+ mode & (1 << 1 ),
472+ mode & (1 << 2 ) };
473+ }
474+
475+ std::tuple<WheelType, int > Message::convertVPotValue (int value) {
476+ return { static_cast <WheelType>(value / 64 ), value % 64 };
477+ }
478+
479+ std::tuple<bool , VPotLEDRingMode, int > Message::convertVPotLEDRingValue (int value) {
480+ return { static_cast <bool >(value / 64 ), static_cast <VPotLEDRingMode>((value % 64 ) / 16 ), value % 16 };
481+ }
482+
483+ std::tuple<WheelType, int > Message::convertJogWheelValue (int value) {
484+ return { static_cast <WheelType>(value / 64 ), value % 64 };
485+ }
306486}
0 commit comments