|
|
|
@ -24,18 +24,31 @@ |
|
|
|
|
#include <circle/devicenameservice.h> |
|
|
|
|
#include <assert.h> |
|
|
|
|
|
|
|
|
|
CMIDIKeyboard *CMIDIKeyboard::s_pThis = 0; |
|
|
|
|
CMIDIKeyboard *CMIDIKeyboard::s_pThis[MaxInstances] = {0}; |
|
|
|
|
|
|
|
|
|
CMIDIKeyboard::CMIDIKeyboard (CMiniDexed *pSynthesizer, CConfig *pConfig) |
|
|
|
|
TMIDIPacketHandler * const CMIDIKeyboard::s_pMIDIPacketHandler[MaxInstances] = |
|
|
|
|
{ |
|
|
|
|
MIDIPacketHandler0, |
|
|
|
|
MIDIPacketHandler1, |
|
|
|
|
MIDIPacketHandler2, |
|
|
|
|
MIDIPacketHandler3 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
CMIDIKeyboard::CMIDIKeyboard (CMiniDexed *pSynthesizer, CConfig *pConfig, unsigned nInstance) |
|
|
|
|
: CMIDIDevice (pSynthesizer, pConfig), |
|
|
|
|
m_nInstance (nInstance), |
|
|
|
|
m_pMIDIDevice (0) |
|
|
|
|
{ |
|
|
|
|
s_pThis = this; |
|
|
|
|
assert (m_nInstance < MaxInstances); |
|
|
|
|
s_pThis[m_nInstance] = this; |
|
|
|
|
|
|
|
|
|
m_DeviceName.Format ("umidi%u", nInstance+1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CMIDIKeyboard::~CMIDIKeyboard (void) |
|
|
|
|
{ |
|
|
|
|
s_pThis = 0; |
|
|
|
|
assert (m_nInstance < MaxInstances); |
|
|
|
|
s_pThis[m_nInstance] = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CMIDIKeyboard::Process (boolean bPlugAndPlayUpdated) |
|
|
|
@ -48,24 +61,45 @@ void CMIDIKeyboard::Process (boolean bPlugAndPlayUpdated) |
|
|
|
|
if (m_pMIDIDevice == 0) |
|
|
|
|
{ |
|
|
|
|
m_pMIDIDevice = |
|
|
|
|
(CUSBMIDIDevice *) CDeviceNameService::Get ()->GetDevice ("umidi1", FALSE); |
|
|
|
|
(CUSBMIDIDevice *) CDeviceNameService::Get ()->GetDevice (m_DeviceName, FALSE); |
|
|
|
|
if (m_pMIDIDevice != 0) |
|
|
|
|
{ |
|
|
|
|
m_pMIDIDevice->RegisterPacketHandler (MIDIPacketHandler); |
|
|
|
|
assert (m_nInstance < MaxInstances); |
|
|
|
|
m_pMIDIDevice->RegisterPacketHandler (s_pMIDIPacketHandler[m_nInstance]); |
|
|
|
|
|
|
|
|
|
m_pMIDIDevice->RegisterRemovedHandler (DeviceRemovedHandler); |
|
|
|
|
m_pMIDIDevice->RegisterRemovedHandler (DeviceRemovedHandler, this); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CMIDIKeyboard::MIDIPacketHandler (unsigned nCable, u8 *pPacket, unsigned nLength) |
|
|
|
|
void CMIDIKeyboard::MIDIPacketHandler0 (unsigned nCable, u8 *pPacket, unsigned nLength) |
|
|
|
|
{ |
|
|
|
|
assert (s_pThis != 0); |
|
|
|
|
s_pThis->MIDIMessageHandler (pPacket, nLength, nCable); |
|
|
|
|
assert (s_pThis[0] != 0); |
|
|
|
|
s_pThis[0]->MIDIMessageHandler (pPacket, nLength, nCable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CMIDIKeyboard::MIDIPacketHandler1 (unsigned nCable, u8 *pPacket, unsigned nLength) |
|
|
|
|
{ |
|
|
|
|
assert (s_pThis[1] != 0); |
|
|
|
|
s_pThis[1]->MIDIMessageHandler (pPacket, nLength, nCable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CMIDIKeyboard::MIDIPacketHandler2 (unsigned nCable, u8 *pPacket, unsigned nLength) |
|
|
|
|
{ |
|
|
|
|
assert (s_pThis[2] != 0); |
|
|
|
|
s_pThis[2]->MIDIMessageHandler (pPacket, nLength, nCable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CMIDIKeyboard::MIDIPacketHandler3 (unsigned nCable, u8 *pPacket, unsigned nLength) |
|
|
|
|
{ |
|
|
|
|
assert (s_pThis[3] != 0); |
|
|
|
|
s_pThis[3]->MIDIMessageHandler (pPacket, nLength, nCable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CMIDIKeyboard::DeviceRemovedHandler (CDevice *pDevice, void *pContext) |
|
|
|
|
{ |
|
|
|
|
assert (s_pThis != 0); |
|
|
|
|
s_pThis->m_pMIDIDevice = 0; |
|
|
|
|
CMIDIKeyboard *pThis = static_cast<CMIDIKeyboard *> (pContext); |
|
|
|
|
assert (pThis != 0); |
|
|
|
|
|
|
|
|
|
pThis->m_pMIDIDevice = 0; |
|
|
|
|
} |
|
|
|
|