Skip to content

Commit a8bb22e

Browse files
committed
Factor out common code
1 parent 4cb01e3 commit a8bb22e

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

src/audiomixerboard.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,22 +1335,16 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
13351335

13361336
void CAudioMixerBoard::SetFaderLevel ( const int iChannelIdx, const int iValue )
13371337
{
1338-
// only apply new fader level if channel index is valid and the fader is visible
1339-
if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) )
1340-
{
1341-
if ( vecpChanFader[static_cast<size_t> ( iChannelIdx )]->IsVisible() )
1342-
{
1343-
vecpChanFader[static_cast<size_t> ( iChannelIdx )]->SetFaderLevel ( iValue );
1344-
}
1345-
}
13461338
// Proposed change: if iChannelIdx is -1 and our own channel ID is a valid index
13471339
// then we adjust our own fader level:
1348-
if((iChannelIdx == -1) && iMyChannelID != INVALID_INDEX)
1340+
const int iTheChannelIdx = ( iChannelIdx == INVALID_INDEX ) ? iMyChannelID : iChannelIdx;
1341+
1342+
// only apply new fader level if channel index is valid and the fader is visible
1343+
if ( ( iTheChannelIdx >= 0 ) && ( iTheChannelIdx < MAX_NUM_CHANNELS ) )
13491344
{
1350-
if ( vecpChanFader[static_cast<size_t> ( iMyChannelID )]->IsVisible() )
1345+
if ( vecpChanFader[static_cast<size_t> ( iTheChannelIdx )]->IsVisible() )
13511346
{
1352-
//printf("debug: set our own fader(%d) level to %d\n", iMyChannelID, iValue);
1353-
vecpChanFader[static_cast<size_t> ( iMyChannelID )]->SetFaderLevel ( iValue );
1347+
vecpChanFader[static_cast<size_t> ( iTheChannelIdx )]->SetFaderLevel ( iValue );
13541348
}
13551349
}
13561350
}

src/sound/soundbase.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,21 +363,16 @@ void CSoundBase::ParseMIDIMessage ( const CVector<uint8_t>& vMIDIPaketBytes )
363363
switch ( cCtrl.eType )
364364
{
365365
case Fader:
366+
case OurFader:
366367
{
367368
// we are assuming that the controller number is the same
368369
// as the audio fader index and the range is 0-127
369370
const int iFaderLevel = static_cast<int> ( static_cast<double> ( iValue ) / 127 * AUD_MIX_FADER_MAX );
371+
const int iTheChannel = cCtrl.eType == OurFader ? INVALID_INDEX : cCtrl.iChannel;
370372

371373
// consider offset for the faders
372374

373-
emit ControllerInFaderLevel ( cCtrl.iChannel, iFaderLevel );
374-
}
375-
break;
376-
case OurFader:
377-
{
378-
// special message about our own fader - emit a fader level whatever-it-is-called with channel id -1
379-
const int iFaderLevel = static_cast<int> ( static_cast<double> ( iValue ) / 127*AUD_MIX_FADER_MAX );
380-
emit ControllerInFaderLevel ( -1, iFaderLevel);
375+
emit ControllerInFaderLevel ( iTheChannel, iFaderLevel );
381376
}
382377
break;
383378
case Pan:

0 commit comments

Comments
 (0)