diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 16c96416f2..174a61d082 100644 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -1343,22 +1343,16 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf void CAudioMixerBoard::SetFaderLevel ( const int iChannelIdx, const int iValue ) { + // If iChannelIdx is I_MY_CHANNEL and our own channel ID is a valid index + // then we adjust our own fader level + const int iTheChannelIdx = ( iChannelIdx == I_MY_CHANNEL ) ? iMyChannelID : iChannelIdx; + // only apply new fader level if channel index is valid and the fader is visible - if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) ) - { - if ( vecpChanFader[static_cast ( iChannelIdx )]->IsVisible() ) - { - vecpChanFader[static_cast ( iChannelIdx )]->SetFaderLevel ( iValue ); - } - } - // Proposed change: if iChannelIdx is -1 and our own channel ID is a valid index - // then we adjust our own fader level: - if((iChannelIdx == -1) && iMyChannelID != INVALID_INDEX) + if ( ( iTheChannelIdx >= 0 ) && ( iTheChannelIdx < MAX_NUM_CHANNELS ) ) { - if ( vecpChanFader[static_cast ( iMyChannelID )]->IsVisible() ) + if ( vecpChanFader[static_cast ( iTheChannelIdx )]->IsVisible() ) { - //printf("debug: set our own fader(%d) level to %d\n", iMyChannelID, iValue); - vecpChanFader[static_cast ( iMyChannelID )]->SetFaderLevel ( iValue ); + vecpChanFader[static_cast ( iTheChannelIdx )]->SetFaderLevel ( iValue ); } } } diff --git a/src/sound/soundbase.cpp b/src/sound/soundbase.cpp index 3a315e0223..b56d8b4820 100644 --- a/src/sound/soundbase.cpp +++ b/src/sound/soundbase.cpp @@ -377,7 +377,7 @@ void CSoundBase::ParseMIDIMessage ( const CVector& vMIDIPaketBytes ) { // special message about our own fader - emit a fader level whatever-it-is-called with channel id -1 const int iFaderLevel = static_cast ( static_cast ( iValue ) / 127*AUD_MIX_FADER_MAX ); - emit ControllerInFaderLevel ( -1, iFaderLevel); + emit ControllerInFaderLevel ( I_MY_CHANNEL, iFaderLevel); } break; case Pan: diff --git a/src/sound/soundbase.h b/src/sound/soundbase.h index fa7090b51a..ceacd1d429 100644 --- a/src/sound/soundbase.h +++ b/src/sound/soundbase.h @@ -32,6 +32,7 @@ #endif #include "../global.h" #include "../util.h" +#define I_MY_CHANNEL -1 // TODO better solution with enum definition // problem: in signals it seems not to work to use CSoundBase::ESndCrdResetType