Skip to content

Commit

Permalink
Factor out common code
Browse files Browse the repository at this point in the history
  • Loading branch information
pljones committed Nov 2, 2024
1 parent f4b7dd5 commit f38942d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/sound/soundbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,16 @@ void CSoundBase::ParseMIDIMessage ( const CVector<uint8_t>& vMIDIPaketBytes )
switch ( cCtrl.eType )
{
case Fader:
case OurFader:
{
// we are assuming that the controller number is the same
// as the audio fader index and the range is 0-127
const int iFaderLevel = static_cast<int> ( static_cast<double> ( iValue ) / 127 * AUD_MIX_FADER_MAX );
const int iTheChannel = cCtrl.eType == OurFader ? I_MY_CHANNEL : cCtrl.iChannel;

// consider offset for the faders

emit ControllerInFaderLevel ( cCtrl.iChannel, iFaderLevel );
}
break;
case OurFader:
{
// special message about our own fader - emit a fader level whatever-it-is-called with channel id -1
const int iFaderLevel = static_cast<int> ( static_cast<double> ( iValue ) / 127*AUD_MIX_FADER_MAX );
emit ControllerInFaderLevel ( I_MY_CHANNEL, iFaderLevel);
emit ControllerInFaderLevel ( iTheChannel, iFaderLevel );
}
break;
case Pan:
Expand Down

0 comments on commit f38942d

Please sign in to comment.