diff --git a/ChangeLog b/ChangeLog index 882a0389..cccb8a54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,10 +13,11 @@ - improve server audio mix processing for better clipping behavior +- support MIDI control faders in headless build (#483) + - bug fix: --showallservers ping column sort is alphabetic (#201) -TODO If network configuration of client changes (e.g. Wifi to LAN) we may get audio issues for a period of time #426 diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index dbb30020..93fc5303 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -470,7 +470,7 @@ void CChannelFader::SendFaderLevelToServer ( const double dLevel, ( !bOtherChannelIsSolo || IsSolo() ) ); // emit signal for new fader gain value - emit gainValueChanged ( CalcFaderGain ( dLevel ), + emit gainValueChanged ( MathUtils::CalcFaderGain ( dLevel ), bIsMyOwnFader, bIsGroupUpdate, bSuppressServerUpdate, @@ -569,7 +569,7 @@ void CChannelFader::SetMute ( const bool bState ) if ( !bOtherChannelIsSolo || IsSolo() ) { // mute was unchecked, get current fader value and apply - emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader, false, false, -1 ); // set level ratio to in invalid value + emit gainValueChanged ( MathUtils::CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader, false, false, -1 ); // set level ratio to in invalid value } } } @@ -771,23 +771,6 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) plblLabel->setToolTip ( strToolTip ); } -double CChannelFader::CalcFaderGain ( const double dValue ) -{ - // convert actual slider range in gain values - // and normalize so that maximum gain is 1 - const double dInValueRange0_1 = dValue / AUD_MIX_FADER_MAX; - - // map range from 0..1 to range -35..0 dB and calculate linear gain - if ( dValue == 0 ) - { - return 0; // -infinity - } - else - { - return pow ( 10, ( dInValueRange0_1 * 35 - 35 ) / 20 ); - } -} - /******************************************************************************\ * CAudioMixerBoard * diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 9819b5ad..b650622e 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -84,7 +84,6 @@ public: protected: void UpdateGroupIDDependencies(); - double CalcFaderGain ( const double dValue ); void SetMute ( const bool bState ); void SetupFaderTag ( const ESkillLevel eSkillLevel ); void SendPanValueToServer ( const int iPan ); diff --git a/src/client.cpp b/src/client.cpp index f6e3580e..cfc395f3 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -182,7 +182,7 @@ CClient::CClient ( const quint16 iPortNumber, this, &CClient::OnSndCrdReinitRequest ); QObject::connect ( &Sound, &CSound::ControllerInFaderLevel, - this, &CClient::ControllerInFaderLevel ); + this, &CClient::OnControllerInFaderLevel ); QObject::connect ( &Socket, &CHighPrioSocket::InvalidPacketReceived, this, &CClient::OnInvalidPacketReceived ); @@ -684,6 +684,22 @@ void CClient::OnHandledSignal ( int sigNum ) #endif } +void CClient::OnControllerInFaderLevel ( int iChannelIdx, + int iValue ) +{ + // in case of a headless client the faders cannot be moved so we need + // to send the controller information directly to the server +#ifdef HEADLESS + // only apply new fader level if channel index is valid + if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) ) + { + SetRemoteChanGain ( iChannelIdx, MathUtils::CalcFaderGain ( iValue ), false ); + } +#endif + + emit ControllerInFaderLevel ( iChannelIdx, iValue ); +} + void CClient::Start() { // init object diff --git a/src/client.h b/src/client.h index 4ab5970d..0cd61e7b 100755 --- a/src/client.h +++ b/src/client.h @@ -245,7 +245,7 @@ public: void SetRemoteChanGain ( const int iId, const double dGain, const bool bIsMyOwnFader ); - void SetRemoteChanPan ( const int iId, const double dPan ) + void SetRemoteChanPan ( const int iId, const double dPan ) { Channel.SetRemoteChanPan ( iId, dPan ); } void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); } @@ -372,7 +372,7 @@ protected: CSignalHandler* pSignalHandler; -public slots: +protected slots: void OnHandledSignal ( int sigNum ); void OnSendProtMessage ( CVector vecMessage ); void OnInvalidPacketReceived ( CHostAddress RecHostAddr ); @@ -397,6 +397,7 @@ public slots: int iNumClients ); void OnSndCrdReinitRequest ( int iSndCrdResetType ); + void OnControllerInFaderLevel ( int iChannelIdx, int iValue ); signals: void ConClientListMesReceived ( CVector vecChanInfo ); diff --git a/src/util.h b/src/util.h index e6423010..866036f3 100755 --- a/src/util.h +++ b/src/util.h @@ -1278,6 +1278,24 @@ public: { return bXFade ? dPan : std::min ( 0.5, dPan ) * 2; } + + // calculate linear gain from fader values which are in dB + static double CalcFaderGain ( const double dValue ) + { + // convert actual slider range in gain values + // and normalize so that maximum gain is 1 + const double dInValueRange0_1 = dValue / AUD_MIX_FADER_MAX; + + // map range from 0..1 to range -35..0 dB and calculate linear gain + if ( dValue == 0 ) + { + return 0; // -infinity + } + else + { + return pow ( 10, ( dInValueRange0_1 * 35 - 35 ) / 20 ); + } + } };