use the given MIDI channel number of filtering input MIDI messages (channel number 0 means that we listen to all channels)

This commit is contained in:
Volker Fischer 2019-01-22 16:11:41 +00:00
parent 2a73d6878e
commit 3609332754
2 changed files with 29 additions and 31 deletions

View file

@ -30,11 +30,12 @@ CSoundBase::CSoundBase ( const QString& strNewSystemDriverTechniqueName,
const bool bNewIsCallbackAudioInterface,
void (*fpNewProcessCallback) ( CVector<int16_t>& psData, void* pParg ),
void* pParg,
const int iCtrlMIDIChannel ) :
const int iNewCtrlMIDIChannel ) :
fpProcessCallback ( fpNewProcessCallback ),
pProcessCallbackArg ( pParg ), bRun ( false ),
bIsCallbackAudioInterface ( bNewIsCallbackAudioInterface ),
strSystemDriverTechniqueName ( strNewSystemDriverTechniqueName )
strSystemDriverTechniqueName ( strNewSystemDriverTechniqueName ),
iCtrlMIDIChannel ( iNewCtrlMIDIChannel )
{
// initializations for the sound card names (default)
lNumDevs = 1;
@ -106,18 +107,23 @@ void CSoundBase::ParseMIDIMessage ( const CVector<uint8_t>& vMIDIPaketBytes )
// check if status byte is correct
if ( ( iStatusByte >= 0x80 ) && ( iStatusByte < 0xF0 ) )
{
const int iMIDIChannel = iStatusByte & 0x0F;
// TODO check for correct channel number
// zero-based MIDI channel number (i.e. range 0-15)
const int iMIDIChannelZB = iStatusByte & 0x0F;
/*
// debugging
printf ( "%02X: ", iMIDIChannel );
printf ( "%02X: ", iMIDIChannelZB );
for ( int i = 0; i < vMIDIPaketBytes.Size(); i++ )
{
printf ( "%02X ", vMIDIPaketBytes[i] );
}
printf ( "\n" );
*/
// per definition if MIDI channel is 0, we listen to all channels
// note that iCtrlMIDIChannel is one-based channel number
if ( ( iCtrlMIDIChannel == 0 ) || ( iCtrlMIDIChannel - 1 == iMIDIChannelZB ) )
{
// we only want to parse controller messages
if ( ( iStatusByte >= 0xB0 ) && ( iStatusByte < 0xC0 ) )
{
@ -133,16 +139,7 @@ printf ( "\n" );
const int iChID = vMIDIPaketBytes[1] - 70;
EmitControllerInFaderLevel ( iChID, iFaderLevel );
/*
// TEST TD-20 Hi-Hat control for fader 0 level
if ( vMIDIPaketBytes[1] == 4 )
{
const int iFaderLevel = static_cast<int> ( static_cast<double> ( vMIDIPaketBytes[2] ) / 256 * AUD_MIX_FADER_MAX );
EmitControllerInFaderLevel ( 0, AUD_MIX_FADER_MAX - iFaderLevel ); // invert fader
}
*/
}
}
}

View file

@ -52,7 +52,7 @@ public:
const bool bNewIsCallbackAudioInterface,
void (*fpNewProcessCallback) ( CVector<int16_t>& psData, void* pParg ),
void* pParg,
const int iCtrlMIDIChannel );
const int iNewCtrlMIDIChannel );
virtual int Init ( const int iNewPrefMonoBufferSize );
virtual void Start();
@ -120,6 +120,7 @@ protected:
bool bIsCallbackAudioInterface;
QString strSystemDriverTechniqueName;
int iCtrlMIDIChannel;
CVector<int16_t> vecsAudioSndCrdStereo;