preparation for MIDI controller audio fader level support
This commit is contained in:
parent
91642b0c2e
commit
d36cd17815
4 changed files with 69 additions and 4 deletions
|
@ -29,7 +29,8 @@
|
||||||
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
|
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
|
||||||
void* arg,
|
void* arg,
|
||||||
const int iCtrlMIDIChannel ) :
|
const int iCtrlMIDIChannel ) :
|
||||||
CSoundBase ( "CoreAudio", true, fpNewProcessCallback, arg, iCtrlMIDIChannel )
|
CSoundBase ( "CoreAudio", true, fpNewProcessCallback, arg, iCtrlMIDIChannel ),
|
||||||
|
midiInPortRef ( static_cast<MIDIPortRef> ( NULL ) )
|
||||||
{
|
{
|
||||||
// Apple Mailing Lists: Subject: GUI Apps should set kAudioHardwarePropertyRunLoop
|
// Apple Mailing Lists: Subject: GUI Apps should set kAudioHardwarePropertyRunLoop
|
||||||
// in the HAL, From: Jeff Moore, Date: Fri, 6 Dec 2002
|
// in the HAL, From: Jeff Moore, Date: Fri, 6 Dec 2002
|
||||||
|
@ -169,6 +170,25 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, voi
|
||||||
iSelInputRightChannel = 0;
|
iSelInputRightChannel = 0;
|
||||||
iSelOutputLeftChannel = 0;
|
iSelOutputLeftChannel = 0;
|
||||||
iSelOutputRightChannel = 0;
|
iSelOutputRightChannel = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Optional MIDI initialization --------------------------------------------
|
||||||
|
if ( iCtrlMIDIChannel != INVALID_MIDI_CH )
|
||||||
|
{
|
||||||
|
// create client and ports
|
||||||
|
MIDIClientRef midiClient = static_cast<MIDIClientRef> ( NULL );
|
||||||
|
MIDIClientCreate ( CFSTR ( APP_NAME ), NULL, NULL, &midiClient );
|
||||||
|
MIDIInputPortCreate ( midiClient, CFSTR ( "Input port" ), callbackMIDI, this, &midiInPortRef );
|
||||||
|
|
||||||
|
// open connections from all sources
|
||||||
|
const int iNMIDISources = MIDIGetNumberOfSources();
|
||||||
|
|
||||||
|
for ( int i = 0; i < iNMIDISources; i++ )
|
||||||
|
{
|
||||||
|
MIDIEndpointRef src = MIDIGetSource ( i );
|
||||||
|
MIDIPortConnectSource ( midiInPortRef, src, NULL) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
|
void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
|
||||||
|
@ -832,6 +852,32 @@ if ( iNumInChan == 4 )
|
||||||
return kAudioHardwareNoError;
|
return kAudioHardwareNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSound::callbackMIDI ( const MIDIPacketList* pktlist,
|
||||||
|
void* refCon,
|
||||||
|
void* )
|
||||||
|
{
|
||||||
|
CSound* pSound = static_cast<CSound*> ( refCon );
|
||||||
|
|
||||||
|
if ( pSound->midiInPortRef != static_cast<MIDIPortRef> ( NULL ) )
|
||||||
|
{
|
||||||
|
MIDIPacket* midiPacket = const_cast<MIDIPacket*> ( pktlist->packet );
|
||||||
|
|
||||||
|
for ( unsigned int j = 0; j < pktlist->numPackets; j++ )
|
||||||
|
{
|
||||||
|
CVector<uint8_t> vMIDIPaketBytes ( midiPacket->length );
|
||||||
|
|
||||||
|
// copy packet and send it to the MIDI parser
|
||||||
|
for ( int i = 0; i < midiPacket->length; i++ )
|
||||||
|
{
|
||||||
|
vMIDIPaketBytes[i] = static_cast<uint8_t> ( midiPacket->data[i] );
|
||||||
|
}
|
||||||
|
pSound->ParseMIDIMessage ( vMIDIPaketBytes );
|
||||||
|
|
||||||
|
midiPacket = MIDIPacketNext ( midiPacket );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CSound::ConvertCFStringToQString ( const CFStringRef stringRef,
|
bool CSound::ConvertCFStringToQString ( const CFStringRef stringRef,
|
||||||
QString& sOut )
|
QString& sOut )
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,11 +103,17 @@ protected:
|
||||||
const AudioTimeStamp*,
|
const AudioTimeStamp*,
|
||||||
void* inRefCon );
|
void* inRefCon );
|
||||||
|
|
||||||
|
static void callbackMIDI ( const MIDIPacketList* pktlist,
|
||||||
|
void* refCon,
|
||||||
|
void* );
|
||||||
|
|
||||||
AudioDeviceID audioInputDevice[MAX_NUMBER_SOUND_CARDS];
|
AudioDeviceID audioInputDevice[MAX_NUMBER_SOUND_CARDS];
|
||||||
AudioDeviceID audioOutputDevice[MAX_NUMBER_SOUND_CARDS];
|
AudioDeviceID audioOutputDevice[MAX_NUMBER_SOUND_CARDS];
|
||||||
AudioDeviceIOProcID audioInputProcID;
|
AudioDeviceIOProcID audioInputProcID;
|
||||||
AudioDeviceIOProcID audioOutputProcID;
|
AudioDeviceIOProcID audioOutputProcID;
|
||||||
|
|
||||||
|
MIDIPortRef midiInPortRef;
|
||||||
|
|
||||||
QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS];
|
QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS];
|
||||||
QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS];
|
QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS];
|
||||||
|
|
||||||
|
|
|
@ -97,11 +97,24 @@ void CSoundBase::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSoundBase::ParseMIDIMessage ( const CVector<int8_t>& vMIDIPaketBytes )
|
void CSoundBase::ParseMIDIMessage ( const CVector<uint8_t>& vMIDIPaketBytes )
|
||||||
{
|
{
|
||||||
|
for ( int i = 0; i < vMIDIPaketBytes.Size(); i++ )
|
||||||
|
{
|
||||||
|
|
||||||
|
// TEST debugging
|
||||||
|
printf ( "%02X ", vMIDIPaketBytes[i] );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
static int cnt = 0;
|
||||||
|
cnt++;
|
||||||
|
if ( cnt >= 10 * AUD_MIX_FADER_MAX ) cnt = 0;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
int iChannelIdx = 0;
|
int iChannelIdx = 0;
|
||||||
int iFaderLevel = 0;
|
int iFaderLevel = cnt / 10;
|
||||||
EmitControllerInFaderLevel ( iChannelIdx, iFaderLevel );
|
EmitControllerInFaderLevel ( iChannelIdx, iFaderLevel );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ protected:
|
||||||
void run();
|
void run();
|
||||||
bool bRun;
|
bool bRun;
|
||||||
|
|
||||||
void ParseMIDIMessage ( const CVector<int8_t>& vMIDIPaketBytes );
|
void ParseMIDIMessage ( const CVector<uint8_t>& vMIDIPaketBytes );
|
||||||
|
|
||||||
bool bIsCallbackAudioInterface;
|
bool bIsCallbackAudioInterface;
|
||||||
QString strSystemDriverTechniqueName;
|
QString strSystemDriverTechniqueName;
|
||||||
|
|
Loading…
Add table
Reference in a new issue