From a49cb6408c80dd9301a851f0682231f4c8c6a697 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Tue, 26 May 2020 20:45:10 +0200 Subject: [PATCH] bug fix: honour own fader and Mute button in Mute Myself (#148) --- src/audiomixerboard.cpp | 20 ++++++++++++++------ src/audiomixerboard.h | 16 ++++++++++------ src/client.cpp | 18 +++++++++++++++++- src/client.h | 4 ++-- src/clientdlg.cpp | 4 ++-- src/clientdlg.h | 4 ++-- 6 files changed, 47 insertions(+), 19 deletions(-) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 9515a661..ab76977d 100644 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -316,6 +316,7 @@ void CChannelFader::Reset() plblCountryFlag->setToolTipDuration ( iToolTipDurMs ); bOtherChannelIsSolo = false; + bIsMyOwnFader = false; } void CChannelFader::SetFaderLevel ( const int iLevel ) @@ -379,7 +380,7 @@ void CChannelFader::SendFaderLevelToServer ( const int iLevel ) ( !bOtherChannelIsSolo || IsSolo() ) ) { // emit signal for new fader gain value - emit gainValueChanged ( CalcFaderGain ( iLevel ) ); + emit gainValueChanged ( CalcFaderGain ( iLevel ), bIsMyOwnFader ); } } @@ -399,7 +400,7 @@ void CChannelFader::SetMute ( const bool bState ) if ( bState ) { // mute channel -> send gain of 0 - emit gainValueChanged ( 0 ); + emit gainValueChanged ( 0, bIsMyOwnFader ); } else { @@ -407,7 +408,7 @@ void CChannelFader::SetMute ( const bool bState ) if ( !bOtherChannelIsSolo || IsSolo() ) { // mute was unchecked, get current fader value and apply - emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ) ); + emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader ); } } } @@ -657,7 +658,7 @@ inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots() { int iCurChanID = slotId - 1; - void ( CAudioMixerBoard::* pGainValueChanged )( double ) = + void ( CAudioMixerBoard::* pGainValueChanged )( double, bool ) = &CAudioMixerBoardSlots::OnChGainValueChanged; void ( CAudioMixerBoard::* pPanValueChanged )( double ) = @@ -792,6 +793,12 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf // the fader was not in use, reset everything for new client vecpChanFader[i]->Reset(); + // check if this is my own fader and set fader property + if ( i == iMyChannelID ) + { + vecpChanFader[i]->SetIsMyOwnFader(); + } + // show fader vecpChanFader[i]->Show(); @@ -918,9 +925,10 @@ void CAudioMixerBoard::UpdateSoloStates() } void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx, - const double dValue ) + const double dValue, + const bool bIsMyOwnFader ) { - emit ChangeChanGain ( iChannelIdx, dValue ); + emit ChangeChanGain ( iChannelIdx, dValue, bIsMyOwnFader ); } void CAudioMixerBoard::UpdatePanValue ( const int iChannelIdx, diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 29a5fdc2..2a18c704 100644 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -71,6 +71,7 @@ public: int GetPanValue() { return pPan->value(); } void Reset(); void SetChannelLevel ( const uint16_t iLevel ); + void SetIsMyOwnFader() { bIsMyOwnFader = true; } protected: double CalcFaderGain ( const int value ); @@ -100,6 +101,7 @@ protected: QString strReceivedName; bool bOtherChannelIsSolo; + bool bIsMyOwnFader; public slots: void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); } @@ -107,7 +109,7 @@ public slots: void OnMuteStateChanged ( int value ); signals: - void gainValueChanged ( double value ); + void gainValueChanged ( double value, bool bIsMyOwnFader ); void panValueChanged ( double value ); void soloStateChanged ( int value ); }; @@ -116,12 +118,13 @@ template class CAudioMixerBoardSlots : public CAudioMixerBoardSlots { public: - void OnChGainValueChanged ( double dValue ) { UpdateGainValue ( slotId - 1, dValue ); } + void OnChGainValueChanged ( double dValue, bool bIsMyOwnFader ) { UpdateGainValue ( slotId - 1, dValue, bIsMyOwnFader ); } void OnChPanValueChanged ( double dValue ) { UpdatePanValue ( slotId - 1, dValue ); } protected: virtual void UpdateGainValue ( const int iChannelIdx, - const double dValue ) = 0; + const double dValue, + const bool bIsMyOwnFader ) = 0; virtual void UpdatePanValue ( const int iChannelIdx, const double dValue ) = 0; }; @@ -147,7 +150,7 @@ public: void SetDisplayPans ( const bool eNDP ); void SetPanIsSupported(); void SetRemoteFaderIsMute ( const int iChannelIdx, const bool bIsMute ); - void SetMyChannelID ( const int iChanID ) { iMyChannelID = iChanID; } + void SetMyChannelID ( const int iChannelIdx ) { iMyChannelID = iChannelIdx; } void SetFaderLevel ( const int iChannelIdx, const int iValue ); @@ -201,7 +204,8 @@ protected: QString strServerName; virtual void UpdateGainValue ( const int iChannelIdx, - const double dValue ); + const double dValue, + const bool bIsMyOwnFader ); virtual void UpdatePanValue ( const int iChannelIdx, const double dValue ); @@ -209,7 +213,7 @@ protected: inline void connectFaderSignalsToMixerBoardSlots(); signals: - void ChangeChanGain ( int iId, double dGain ); + void ChangeChanGain ( int iId, double dGain, bool bIsMyOwnFader ); void ChangeChanPan ( int iId, double dPan ); void NumClientsChanged ( int iNewNumClients ); }; diff --git a/src/client.cpp b/src/client.cpp index 9d22c818..a6dd8e7a 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -61,6 +61,7 @@ CClient::CClient ( const quint16 iPortNumber, iNumAudioChannels ( 1 ), bIsInitializationPhase ( true ), bMuteOutStream ( false ), + dMuteOutStreamGain ( 1.0 ), Socket ( &Channel, iPortNumber ), Sound ( AudioCallback, this, iCtrlMIDIChannel, bNoAutoJackConnect, strNClientName ), iAudioInFader ( AUD_FADER_IN_MIDDLE ), @@ -380,6 +381,19 @@ void CClient::SetDoAutoSockBufSize ( const bool bValue ) CreateServerJitterBufferMessage(); } +void CClient::SetRemoteChanGain ( const int iId, + const double dGain, + const bool bIsMyOwnFader ) +{ + // if this gain is for my own channel, apply the value for the Mute Myself function + if ( bIsMyOwnFader ) + { + dMuteOutStreamGain = dGain; + } + + Channel.SetRemoteChanGain ( iId, dGain ); +} + bool CClient::SetServerAddr ( QString strNAddr ) { CHostAddress HostAddress; @@ -877,6 +891,8 @@ void CClient::Init() vecZeros.Init ( iStereoBlockSizeSam, 0 ); vecsStereoSndCrdMuteStream.Init ( iStereoBlockSizeSam ); + dMuteOutStreamGain = 1.0; + opus_custom_encoder_ctl ( CurOpusEncoder, OPUS_SET_BITRATE ( CalcBitRateBitsPerSecFromCodedBytes ( @@ -1198,7 +1214,7 @@ fflush(pFileDelay); for ( i = 0; i < iStereoBlockSizeSam; i++ ) { vecsStereoSndCrd[i] = Double2Short ( - static_cast ( vecsStereoSndCrd[i] ) + vecsStereoSndCrdMuteStream[i] ); + vecsStereoSndCrd[i] + vecsStereoSndCrdMuteStream[i] * dMuteOutStreamGain ); } } diff --git a/src/client.h b/src/client.h index 368edd9d..bc6a1da4 100755 --- a/src/client.h +++ b/src/client.h @@ -243,8 +243,7 @@ public: void SetMuteOutStream ( const bool bDoMute ) { bMuteOutStream = bDoMute; } - void SetRemoteChanGain ( const int iId, const double dGain ) - { Channel.SetRemoteChanGain ( iId, dGain ); } + void SetRemoteChanGain ( const int iId, const double dGain, const bool bIsMyOwnFader ); void SetRemoteChanPan ( const int iId, const double dPan ) { Channel.SetRemoteChanPan ( iId, dPan ); } @@ -343,6 +342,7 @@ protected: int iNumAudioChannels; bool bIsInitializationPhase; bool bMuteOutStream; + double dMuteOutStreamGain; CVector vecCeltData; CHighPrioSocket Socket; diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 3bfb457b..44736084 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -526,8 +526,8 @@ CClientDlg::CClientDlg ( CClient* pNCliP, QObject::connect ( &ClientSettingsDlg, SIGNAL ( NewClientLevelChanged() ), this, SLOT ( OnNewClientLevelChanged() ) ); - QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanGain ( int, double ) ), - this, SLOT ( OnChangeChanGain ( int, double ) ) ); + QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanGain ( int, double, bool ) ), + this, SLOT ( OnChangeChanGain ( int, double, bool ) ) ); QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanPan ( int, double ) ), this, SLOT ( OnChangeChanPan ( int, double ) ) ); diff --git a/src/clientdlg.h b/src/clientdlg.h index ffddbf0e..a54d22f5 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -169,8 +169,8 @@ public slots: void OnChatTextReceived ( QString strChatText ); void OnLicenceRequired ( ELicenceType eLicenceType ); - void OnChangeChanGain ( int iId, double dGain ) - { pClient->SetRemoteChanGain ( iId, dGain ); } + void OnChangeChanGain ( int iId, double dGain, bool bIsMyOwnFader ) + { pClient->SetRemoteChanGain ( iId, dGain, bIsMyOwnFader ); } void OnChangeChanPan ( int iId, double dPan ) { pClient->SetRemoteChanPan ( iId, dPan ); }