-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add DAW Display support for Arturia MiniLab 3 and KeyLab 3 Essential
based on https://github.com/PrzemekBarski/arturia-keylab-essential-mk3-programming-guide Tested on a Arturia MiniLab 3 Keylab 3 Essential is not tested
- Loading branch information
1 parent
a4dcd4d
commit 0b55ac6
Showing
11 changed files
with
259 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// | ||
// dawdisplay.cpp | ||
// | ||
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi | ||
// Copyright (C) 2022 The MiniDexed Team | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
#include "dawdisplay.h" | ||
#include "midikeyboard.h" | ||
|
||
#include <circle/string.h> | ||
|
||
CDAWDisplay::CDAWDisplay (CMIDIKeyboard *pMIDIKeyboard) | ||
: m_pMIDIKeyboard (pMIDIKeyboard), | ||
m_DisplayType (Unknown) | ||
{ | ||
} | ||
|
||
void CDAWDisplay::OnConnect () | ||
{ | ||
static const uint8_t inquiry[] = {0xF0, 0x7E, 0x7F, 0x06, 0x01, 0xF7}; | ||
|
||
m_DisplayType = Unknown; | ||
|
||
m_pMIDIKeyboard->Send (inquiry, sizeof inquiry, 0); | ||
} | ||
|
||
void CDAWDisplay::MIDISysexHandler (u8 *pPacket, unsigned nLength, unsigned nCable) | ||
{ | ||
static const uint8_t pInquiryResp[] = {0xF0, 0x7E, 0x7F, 0x06, 0x02}; | ||
static const uint8_t pArturia[] = {0xF0, 0x7E, 0x7F, 0x06, 0x02, 0x00, 0x20, 0x6B}; | ||
static const uint8_t pMiniLab3[] = {0xF0, 0x7E, 0x7F, 0x06, 0x02, 0x00, 0x20, 0x6B, 0x02, 0x00, 0x04, 0x04}; | ||
static const uint8_t pKeyLabEs3_49[] = {0xF0, 0x7E, 0x7F, 0x06, 0x02, 0x00, 0x20, 0x6B, 0x02, 0x00, 0x05, 0x72}; | ||
static const uint8_t pKeyLabEs3_61[] = {0xF0, 0x7E, 0x7F, 0x06, 0x02, 0x00, 0x20, 0x6B, 0x02, 0x00, 0x05, 0x74}; | ||
static const uint8_t pKeyLabEs3_88[] = {0xF0, 0x7E, 0x7F, 0x06, 0x02, 0x00, 0x20, 0x6B, 0x02, 0x00, 0x05, 0x78}; | ||
|
||
static const uint8_t pArturiaDAWInit[] = {0xF0, 0x00, 0x20, 0x6B, 0x7F, 0x42, 0x02, 0x00, 0x40, 0x6A, 0x21, 0xF7}; | ||
|
||
if (nLength > sizeof pInquiryResp && memcmp (pPacket, pInquiryResp, sizeof pInquiryResp) != 0) | ||
return; | ||
|
||
if (nLength > sizeof pArturia && memcmp (pPacket, pArturia, sizeof pArturia) == 0) | ||
{ | ||
m_pMIDIKeyboard->Send (pArturiaDAWInit, sizeof pArturiaDAWInit, 0); | ||
|
||
if (nLength > sizeof pMiniLab3 && memcmp (pPacket, pMiniLab3, sizeof pMiniLab3) == 0) | ||
{ | ||
m_DisplayType = MiniLab3; | ||
DisplayWrite ("MiniDexed", "", "On MiniLab 3", 0, 0); | ||
} | ||
|
||
if (nLength > sizeof pKeyLabEs3_49 && ( | ||
memcmp (pPacket, pKeyLabEs3_49, sizeof pKeyLabEs3_49) == 0 || | ||
memcmp (pPacket, pKeyLabEs3_61, sizeof pKeyLabEs3_61) == 0 || | ||
memcmp (pPacket, pKeyLabEs3_88, sizeof pKeyLabEs3_88) == 0)) | ||
{ | ||
m_DisplayType = KeyLabEs3; | ||
DisplayWrite ("MiniDexed", "", "On KeyLab 3 Essential", 0, 0); | ||
} | ||
} | ||
} | ||
|
||
void CDAWDisplay::ArturiaDisplayWrite (const u8 *pHdr, const unsigned nHdrSize, const char *pMenu, const char *pParam, const char *pValue) | ||
{ | ||
static unsigned L1MaxLen = 18; | ||
|
||
CString line1 (pParam); | ||
CString line2 (pValue); | ||
|
||
size_t nLen = strlen (pParam) + strlen (pMenu); | ||
if (nLen < L1MaxLen) | ||
{ | ||
for (unsigned i = L1MaxLen - nLen; i > 0; i--) | ||
{ | ||
line1.Append (" "); | ||
} | ||
} | ||
|
||
line1.Append (pMenu); | ||
|
||
int nLine1Len = strlen (line1); | ||
int nLine2Len = strlen (line2); | ||
int nOffset = 0; | ||
|
||
uint8_t pLines[nHdrSize + nLine1Len + 2 + nLine2Len + 2]; | ||
|
||
memcpy (pLines, pHdr, nHdrSize); | ||
nOffset += nHdrSize; | ||
|
||
memcpy (&pLines[nOffset], line1, nLine1Len + 1); | ||
nOffset += nLine1Len + 1; | ||
|
||
pLines[nOffset] = 0x02; | ||
nOffset += 1; | ||
|
||
memcpy (&pLines[nOffset], line2, nLine2Len + 1); | ||
nOffset += nLine2Len + 1; | ||
|
||
pLines[nOffset] = 0xf7; | ||
nOffset += 1; | ||
|
||
m_pMIDIKeyboard->Send (pLines, nOffset, 0); | ||
} | ||
|
||
void CDAWDisplay::DisplayWrite (const char *pMenu, const char *pParam, const char *pValue, | ||
bool bArrowDown, bool bArrowUp) | ||
{ | ||
static const uint8_t pMiniLab3Hdr[] = {0xF0, 0x00, 0x20, 0x6B, 0x7F, 0x42, 0x04, 0x02, 0x60, 0x12, 0x01}; | ||
static const uint8_t pKeyLabEs3Hdr[] = {0xF0, 0x00, 0x20, 0x6B, 0x7F, 0x42, 0x04, 0x01, 0x60, 0x12, 0x01}; | ||
|
||
switch (m_DisplayType) | ||
{ | ||
case MiniLab3: | ||
ArturiaDisplayWrite (pMiniLab3Hdr, sizeof pMiniLab3Hdr, pMenu, pParam, pValue); | ||
break; | ||
case KeyLabEs3: | ||
ArturiaDisplayWrite (pKeyLabEs3Hdr, sizeof pKeyLabEs3Hdr, pMenu, pParam, pValue); | ||
break; | ||
default: | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// dawdisplay.h | ||
// | ||
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi | ||
// Copyright (C) 2022 The MiniDexed Team | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
#ifndef _dawdisplay_h | ||
#define _dawdisplay_h | ||
|
||
#include <circle/types.h> | ||
|
||
class CMIDIKeyboard; | ||
|
||
class CDAWDisplay | ||
{ | ||
public: | ||
CDAWDisplay (CMIDIKeyboard *pKeyboard); | ||
|
||
void OnConnect (); | ||
void MIDISysexHandler (u8 *pPacket, unsigned nLength, unsigned nCable); | ||
|
||
void DisplayWrite (const char *pMenu, const char *pParam, const char *pValue, | ||
bool bArrowDown, bool bArrowUp); | ||
|
||
private: | ||
void ArturiaDisplayWrite (const u8 *pHdr, const unsigned nHdrSize, const char *pMenu, const char *pParam, const char *pValue); | ||
|
||
enum TDisplayType | ||
{ | ||
Unknown, | ||
MiniLab3, | ||
KeyLabEs3, | ||
}; | ||
|
||
CMIDIKeyboard *m_pMIDIKeyboard; | ||
|
||
TDisplayType m_DisplayType; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.