From 2c0b8a611916ec134c986474e7e8ee75a9852a42 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 20 Jun 2020 20:29:43 +0200 Subject: [PATCH] fix of: when changing a large group of faders, the volume change is very very slow, also the feedback from server, it seems the protocol is overloaded totally --- ChangeLog | 2 -- src/audiomixerboard.cpp | 56 +++++++++++++++++++++++------------------ src/audiomixerboard.h | 36 ++++++++++++++++++++------ 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac1a0d38..93132ba9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,9 +21,7 @@ TODO grouping does not work as expected: - - when changing a large group of faders, the volume change is very very slow, also the feedback from server, it seems the protocol is overloaded totally - vertical space between check boxes should be smaller - - get rid of bIsSelected TODO minimum height of faders (dependent on style) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 276553bf..88227143 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -313,7 +313,7 @@ void CChannelFader::Reset() iPreviousFaderLevel = AUD_MIX_FADER_MAX; pPan->setValue ( AUD_MIX_PAN_MAX / 2 ); - // reset mute/solo/select check boxes and level meter + // reset mute/solo/group check boxes and level meter pcbMute->setChecked ( false ); pcbSolo->setChecked ( false ); pcbGroup->setChecked ( false ); @@ -339,15 +339,20 @@ void CChannelFader::Reset() bIsMyOwnFader = false; } -void CChannelFader::SetFaderLevel ( const int iLevel ) +void CChannelFader::SetFaderLevel ( const int iLevel, + const bool bIsGroupUpdate ) { // first make a range check if ( ( iLevel >= 0 ) && ( iLevel <= AUD_MIX_FADER_MAX ) ) { // we set the new fader level in the GUI (slider control) and also tell the - // server about the change - pFader->setValue ( iLevel ); - SendFaderLevelToServer ( iLevel ); + // server about the change (block the signal of the fader since we want to + // call SendFaderLevelToServer with a special additional parameter) + pFader->blockSignals ( true ); + pFader->setValue ( iLevel ); + pFader->blockSignals ( false ); + + SendFaderLevelToServer ( iLevel, bIsGroupUpdate ); } } @@ -356,10 +361,9 @@ void CChannelFader::SetPanValue ( const int iPan ) // first make a range check if ( ( iPan >= 0 ) && ( iPan <= AUD_MIX_PAN_MAX ) ) { - // we set the new fader level in the GUI (slider control) and also tell the - // server about the change - pPan->setValue ( iPan ); - SendPanValueToServer ( iPan ); + // we set the new fader level in the GUI (slider control) which then + // emits to signal to tell the server about the change (implicitly) + pPan->setValue ( iPan ); } } @@ -393,7 +397,8 @@ void CChannelFader::SetRemoteFaderIsMute ( const bool bIsMute ) } } -void CChannelFader::SendFaderLevelToServer ( const int iLevel ) +void CChannelFader::SendFaderLevelToServer ( const int iLevel, + const bool bIsGroupUpdate ) { // if mute flag is set or other channel is on solo, do not apply the new // fader value (exception: we are on solo, in that case we ignore the @@ -402,14 +407,17 @@ void CChannelFader::SendFaderLevelToServer ( const int iLevel ) ( !bOtherChannelIsSolo || IsSolo() ) ) { // emit signal for new fader gain value - emit gainValueChanged ( CalcFaderGain ( iLevel ), bIsMyOwnFader, iLevel - iPreviousFaderLevel ); + emit gainValueChanged ( CalcFaderGain ( iLevel ), + bIsMyOwnFader, + bIsGroupUpdate, + iLevel - iPreviousFaderLevel ); iPreviousFaderLevel = iLevel; } } void CChannelFader::SendPanValueToServer ( const int iPan ) -{ +{ emit panValueChanged ( static_cast ( iPan ) / AUD_MIX_PAN_MAX ); } @@ -424,7 +432,7 @@ void CChannelFader::SetMute ( const bool bState ) if ( bState ) { // mute channel -> send gain of 0 - emit gainValueChanged ( 0, bIsMyOwnFader, 0 ); + emit gainValueChanged ( 0, bIsMyOwnFader, false, 0 ); } else { @@ -432,7 +440,7 @@ void CChannelFader::SetMute ( const bool bState ) if ( !bOtherChannelIsSolo || IsSolo() ) { // mute was unchecked, get current fader value and apply - emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader, 0 ); + emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader, false, 0 ); } } } @@ -691,7 +699,7 @@ inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots() { int iCurChanID = slotId - 1; - void ( CAudioMixerBoard::* pGainValueChanged )( double, bool, int ) = + void ( CAudioMixerBoard::* pGainValueChanged )( double, bool, bool, int ) = &CAudioMixerBoardSlots::OnChGainValueChanged; void ( CAudioMixerBoard::* pPanValueChanged )( double ) = @@ -1023,27 +1031,25 @@ void CAudioMixerBoard::UpdateSoloStates() void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx, const double dValue, const bool bIsMyOwnFader, + const bool bIsGroupUpdate, const int iDiffLevel ) { // update current gain emit ChangeChanGain ( iChannelIdx, dValue, bIsMyOwnFader ); - // if this fader is selected, all other selected must be updated as well - if ( vecpChanFader[iChannelIdx]->IsSelect() ) + // if this fader is selected, all other in the group must be updated as + // well (note that we do not have to update if this is already a group update + // to avoid an infinite loop) + if ( vecpChanFader[iChannelIdx]->IsSelect() && !bIsGroupUpdate ) { for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { // update rest of faders selected if ( vecpChanFader[i]->IsVisible() && vecpChanFader[i]->IsSelect() && ( i != iChannelIdx ) ) { - // temporaly unselect so it does not repeat this again and again... - vecpChanFader[i]->SetFaderIsSelect ( false ); - - // "move" faders with moving fader level - vecpChanFader[i]->SetFaderLevel ( vecpChanFader[i]->GetFaderLevel() + iDiffLevel ); - - // back to selected status - vecpChanFader[i]->SetFaderIsSelect ( true ); + // synchronize faders with moving fader level (it is important + // to set the group flag to avoid inifinite looping) + vecpChanFader[i]->SetFaderLevel ( vecpChanFader[i]->GetFaderLevel() + iDiffLevel, true ); } } } diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 3921a778..3d10c137 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -64,25 +64,28 @@ public: void SetDisplayPans ( const bool eNDP ); QFrame* GetMainWidget() { return pFrame; } - void UpdateSoloState ( const bool bNewOtherSoloState ); - void SetFaderLevel ( const int iLevel ); void SetPanValue ( const int iPan ); void SetFaderIsSolo ( const bool bIsSolo ); void SetFaderIsMute ( const bool bIsMute ); void SetRemoteFaderIsMute ( const bool bIsMute ); void SetFaderIsSelect ( const bool bIsMute ); + void SetFaderLevel ( const int iLevel, + const bool bIsGroupUpdate = false ); + int GetFaderLevel() { return pFader->value(); } int GetPanValue() { return pPan->value(); } void Reset(); void SetChannelLevel ( const uint16_t iLevel ); void SetIsMyOwnFader() { bIsMyOwnFader = true; } + void UpdateSoloState ( const bool bNewOtherSoloState ); protected: double CalcFaderGain ( const int value ); void SetMute ( const bool bState ); - void SendFaderLevelToServer ( const int iLevel ); - void SendPanValueToServer ( const int iPan ); void SetupFaderTag ( const ESkillLevel eSkillLevel ); + void SendPanValueToServer ( const int iPan ); + void SendFaderLevelToServer ( const int iLevel, + const bool bIsGroupUpdate ); QFrame* pFrame; @@ -112,12 +115,16 @@ protected: int iPreviousFaderLevel; public slots: - void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); } + void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, false ); } void OnPanValueChanged ( int value ) { SendPanValueToServer ( value ); } void OnMuteStateChanged ( int value ); signals: - void gainValueChanged ( double value, bool bIsMyOwnFader, int iDiffLevel ); + void gainValueChanged ( double value, + bool bIsMyOwnFader, + bool bIsGroupUpdate, + int iDiffLevel ); + void panValueChanged ( double value ); void soloStateChanged ( int value ); }; @@ -126,14 +133,24 @@ template class CAudioMixerBoardSlots : public CAudioMixerBoardSlots { public: - void OnChGainValueChanged ( double dValue, bool bIsMyOwnFader, int iDiffLevel ) { UpdateGainValue ( slotId - 1, dValue, bIsMyOwnFader, iDiffLevel ); } + void OnChGainValueChanged ( double dValue, + bool bIsMyOwnFader, + bool bIsGroupUpdate, + int iDiffLevel ) { UpdateGainValue ( slotId - 1, + dValue, + bIsMyOwnFader, + bIsGroupUpdate, + iDiffLevel ); } + void OnChPanValueChanged ( double dValue ) { UpdatePanValue ( slotId - 1, dValue ); } protected: virtual void UpdateGainValue ( const int iChannelIdx, const double dValue, const bool bIsMyOwnFader, + const bool bIsGroupUpdate, const int iDiffLevel ) = 0; + virtual void UpdatePanValue ( const int iChannelIdx, const double dValue ) = 0; }; @@ -149,7 +166,8 @@ class CAudioMixerBoard : Q_OBJECT public: - CAudioMixerBoard ( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + CAudioMixerBoard ( QWidget* parent = nullptr, + Qt::WindowFlags f = nullptr ); void HideAll(); void ApplyNewConClientList ( CVector& vecChanInfo ); @@ -223,7 +241,9 @@ protected: virtual void UpdateGainValue ( const int iChannelIdx, const double dValue, const bool bIsMyOwnFader, + const bool bIsGroupUpdate, const int iDiffLevel ); + virtual void UpdatePanValue ( const int iChannelIdx, const double dValue );