From f22762d7efcc3a18383ca060780287a96b7a1006 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Thu, 2 Jul 2020 17:04:05 +0200 Subject: [PATCH] support storing group state --- ChangeLog | 2 +- src/audiomixerboard.cpp | 74 ++++++++++++++++++++++------------------- src/audiomixerboard.h | 30 +++++++++-------- src/client.cpp | 1 + src/client.h | 1 + src/clientdlg.cpp | 14 ++++---- src/global.h | 3 ++ src/settings.cpp | 19 +++++++++++ 8 files changed, 88 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index f587ac24..d0400aec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ 3.5.9git -- bug fix: grouping faders in the client should be proportional (see discussion in #202) +- bug fix: grouping faders in the client should be proportional (see discussion in #202, #419) TODO bug fix: incorrect selection of UI language (#408) !!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index eaee3ca9..2a151c15 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -379,11 +379,6 @@ void CChannelFader::SetPanValue ( const int iPan ) } } -void CChannelFader::SetFaderIsSelect ( const bool bIsSelected ) -{ - pcbGroup->setChecked ( bIsSelected ); -} - void CChannelFader::SetFaderIsSolo ( const bool bIsSolo ) { // changing the state automatically emits the signal, too @@ -659,19 +654,20 @@ double CChannelFader::CalcFaderGain ( const double dValue ) * CAudioMixerBoard * \******************************************************************************/ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : - QGroupBox ( parent ), - vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), - vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), - vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ), - vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), - vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ), - iNewClientFaderLevel ( 100 ), - bDisplayPans ( false ), - bIsPanSupported ( false ), - bNoFaderVisible ( true ), - iMyChannelID ( INVALID_INDEX ), - strServerName ( "" ), - eRecorderState ( RS_UNDEFINED ) + QGroupBox ( parent ), + vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), + vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), + vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ), + vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), + vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ), + vecStoredFaderGroupID ( MAX_NUM_STORED_FADER_SETTINGS, INVALID_INDEX ), + iNewClientFaderLevel ( 100 ), + bDisplayPans ( false ), + bIsPanSupported ( false ), + bNoFaderVisible ( true ), + iMyChannelID ( INVALID_INDEX ), + strServerName ( "" ), + eRecorderState ( RS_UNDEFINED ) { // add group box and hboxlayout QHBoxLayout* pGroupBoxLayout = new QHBoxLayout ( this ); @@ -967,17 +963,20 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf int iStoredPanValue; bool bStoredFaderIsSolo; bool bStoredFaderIsMute; + int iGroupID; if ( GetStoredFaderSettings ( vecChanInfo[j], iStoredFaderLevel, iStoredPanValue, bStoredFaderIsSolo, - bStoredFaderIsMute ) ) + bStoredFaderIsMute, + iGroupID ) ) { vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel ); vecpChanFader[i]->SetPanValue ( iStoredPanValue ); vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo ); vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute ); + vecpChanFader[i]->SetGroupID ( iGroupID ); // Must be the last to be set in the fader! } } @@ -1076,13 +1075,13 @@ void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx, // 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 ) + if ( ( vecpChanFader[iChannelIdx]->GetGroupID() != INVALID_INDEX ) && !bIsGroupUpdate ) { for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { // update rest of faders selected if ( vecpChanFader[i]->IsVisible() && - vecpChanFader[i]->IsSelect() && + ( vecpChanFader[i]->GetGroupID() == vecpChanFader[iChannelIdx]->GetGroupID() ) && ( i != iChannelIdx ) && ( dLevelRatio >= 0 ) ) { @@ -1106,10 +1105,11 @@ void CAudioMixerBoard::StoreFaderSettings ( CChannelFader* pChanFader ) if ( pChanFader->IsVisible() && !pChanFader->GetReceivedName().isEmpty() ) { - CVector viOldStoredFaderLevels ( vecStoredFaderLevels ); - CVector viOldStoredPanValues ( vecStoredPanValues ); - CVector vbOldStoredFaderIsSolo ( vecStoredFaderIsSolo ); - CVector vbOldStoredFaderIsMute ( vecStoredFaderIsMute ); + CVector viOldStoredFaderLevels ( vecStoredFaderLevels ); + CVector viOldStoredPanValues ( vecStoredPanValues ); + CVector vbOldStoredFaderIsSolo ( vecStoredFaderIsSolo ); + CVector vbOldStoredFaderIsMute ( vecStoredFaderIsMute ); + CVector vbOldStoredFaderGroupID ( vecStoredFaderGroupID ); // init temporary list count (may be overwritten later on) int iTempListCnt = 0; @@ -1120,11 +1120,12 @@ void CAudioMixerBoard::StoreFaderSettings ( CChannelFader* pChanFader ) true ); // current fader level and solo state is at the top of the list - vecStoredFaderLevels[0] = pChanFader->GetFaderLevel(); - vecStoredPanValues[0] = pChanFader->GetPanValue(); - vecStoredFaderIsSolo[0] = pChanFader->IsSolo(); - vecStoredFaderIsMute[0] = pChanFader->IsMute(); - iTempListCnt = 1; + vecStoredFaderLevels[0] = pChanFader->GetFaderLevel(); + vecStoredPanValues[0] = pChanFader->GetPanValue(); + vecStoredFaderIsSolo[0] = pChanFader->IsSolo(); + vecStoredFaderIsMute[0] = pChanFader->IsMute(); + vecStoredFaderGroupID[0] = pChanFader->GetGroupID(); + iTempListCnt = 1; for ( int iIdx = 0; iIdx < MAX_NUM_STORED_FADER_SETTINGS; iIdx++ ) { @@ -1136,10 +1137,11 @@ void CAudioMixerBoard::StoreFaderSettings ( CChannelFader* pChanFader ) // index in case the entry was not present in the vector before if ( iIdx != iOldIdx ) { - vecStoredFaderLevels[iTempListCnt] = viOldStoredFaderLevels[iIdx]; - vecStoredPanValues[iTempListCnt] = viOldStoredPanValues[iIdx]; - vecStoredFaderIsSolo[iTempListCnt] = vbOldStoredFaderIsSolo[iIdx]; - vecStoredFaderIsMute[iTempListCnt] = vbOldStoredFaderIsMute[iIdx]; + vecStoredFaderLevels[iTempListCnt] = viOldStoredFaderLevels[iIdx]; + vecStoredPanValues[iTempListCnt] = viOldStoredPanValues[iIdx]; + vecStoredFaderIsSolo[iTempListCnt] = vbOldStoredFaderIsSolo[iIdx]; + vecStoredFaderIsMute[iTempListCnt] = vbOldStoredFaderIsMute[iIdx]; + vecStoredFaderGroupID[iTempListCnt] = vbOldStoredFaderGroupID[iIdx]; iTempListCnt++; } @@ -1152,7 +1154,8 @@ bool CAudioMixerBoard::GetStoredFaderSettings ( const CChannelInfo& ChanInfo, int& iStoredFaderLevel, int& iStoredPanValue, bool& bStoredFaderIsSolo, - bool& bStoredFaderIsMute ) + bool& bStoredFaderIsMute, + int& iGroupID ) { // only do the check if the name string is not empty if ( !ChanInfo.strName.isEmpty() ) @@ -1167,6 +1170,7 @@ bool CAudioMixerBoard::GetStoredFaderSettings ( const CChannelInfo& ChanInfo, iStoredPanValue = vecStoredPanValues[iIdx]; bStoredFaderIsSolo = vecStoredFaderIsSolo[iIdx] != 0; bStoredFaderIsMute = vecStoredFaderIsMute[iIdx] != 0; + iGroupID = vecStoredFaderGroupID[iIdx]; // values found and copied, return OK return true; diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index fbf1496f..bbde40e6 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -50,25 +50,25 @@ public: CChannelFader ( QWidget* pNW ); QString GetReceivedName() { return cReceivedChanInfo.strName; } - int GetReceivedInstrument() { return cReceivedChanInfo.iInstrument; } - void SetChannelInfos ( const CChannelInfo& cChanInfo ); - void Show() { pFrame->show(); } - void Hide() { pFrame->hide(); } - bool IsVisible() { return !pFrame->isHidden(); } - bool IsSolo() { return pcbSolo->isChecked(); } - bool IsMute() { return pcbMute->isChecked(); } - bool IsSelect() { return pcbGroup->isChecked(); } - void SetGUIDesign ( const EGUIDesign eNewDesign ); - void SetDisplayChannelLevel ( const bool eNDCL ); - bool GetDisplayChannelLevel(); - void SetDisplayPans ( const bool eNDP ); + int GetReceivedInstrument() { return cReceivedChanInfo.iInstrument; } + void SetChannelInfos ( const CChannelInfo& cChanInfo ); + void Show() { pFrame->show(); } + void Hide() { pFrame->hide(); } + bool IsVisible() { return !pFrame->isHidden(); } + bool IsSolo() { return pcbSolo->isChecked(); } + bool IsMute() { return pcbMute->isChecked(); } + int GetGroupID() { return pcbGroup->isChecked() ? 0 : INVALID_INDEX; } + void SetGUIDesign ( const EGUIDesign eNewDesign ); + void SetDisplayChannelLevel ( const bool eNDCL ); + bool GetDisplayChannelLevel(); + void SetDisplayPans ( const bool eNDP ); QFrame* GetMainWidget() { return pFrame; } void SetPanValue ( const int iPan ); void SetFaderIsSolo ( const bool bIsSolo ); void SetFaderIsMute ( const bool bIsMute ); + void SetGroupID ( const int iGroupID ) { pcbGroup->setChecked ( iGroupID != INVALID_INDEX ); } void SetRemoteFaderIsMute ( const bool bIsMute ); - void SetFaderIsSelect ( const bool bIsMute ); void SetFaderLevel ( const double dLevel, const bool bIsGroupUpdate = false ); @@ -203,6 +203,7 @@ public: CVector vecStoredPanValues; CVector vecStoredFaderIsSolo; CVector vecStoredFaderIsMute; + CVector vecStoredFaderGroupID; int iNewClientFaderLevel; protected: @@ -225,7 +226,8 @@ protected: int& iStoredFaderLevel, int& iStoredPanValue, bool& bStoredFaderIsSolo, - bool& bStoredFaderIsMute ); + bool& bStoredFaderIsMute, + int& iGroupID ); void StoreFaderSettings ( CChannelFader* pChanFader ); void UpdateSoloStates(); diff --git a/src/client.cpp b/src/client.cpp index 24afe5d9..fa3e3e50 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -38,6 +38,7 @@ CClient::CClient ( const quint16 iPortNumber, vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ), vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ), + vecStoredFaderGroupID ( MAX_NUM_STORED_FADER_SETTINGS, INVALID_INDEX ), iNewClientFaderLevel ( 100 ), bConnectDlgShowAllMusicians ( true ), strClientName ( strNClientName ), diff --git a/src/client.h b/src/client.h index 0487e2ec..675fe41c 100755 --- a/src/client.h +++ b/src/client.h @@ -285,6 +285,7 @@ public: CVector vecStoredPanValues; CVector vecStoredFaderIsSolo; CVector vecStoredFaderIsMute; + CVector vecStoredFaderGroupID; int iNewClientFaderLevel; bool bConnectDlgShowAllMusicians; QString strClientName; diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 166f0d98..3d76b99d 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -189,12 +189,13 @@ CClientDlg::CClientDlg ( CClient* pNCliP, MainMixerBoard->SetDisplayChannelLevels ( pClient->GetDisplayChannelLevels() ); // restore fader settings - MainMixerBoard->vecStoredFaderTags = pClient->vecStoredFaderTags; - MainMixerBoard->vecStoredFaderLevels = pClient->vecStoredFaderLevels; - MainMixerBoard->vecStoredPanValues = pClient->vecStoredPanValues; - MainMixerBoard->vecStoredFaderIsSolo = pClient->vecStoredFaderIsSolo; - MainMixerBoard->vecStoredFaderIsMute = pClient->vecStoredFaderIsMute; - MainMixerBoard->iNewClientFaderLevel = pClient->iNewClientFaderLevel; + MainMixerBoard->vecStoredFaderTags = pClient->vecStoredFaderTags; + MainMixerBoard->vecStoredFaderLevels = pClient->vecStoredFaderLevels; + MainMixerBoard->vecStoredPanValues = pClient->vecStoredPanValues; + MainMixerBoard->vecStoredFaderIsSolo = pClient->vecStoredFaderIsSolo; + MainMixerBoard->vecStoredFaderIsMute = pClient->vecStoredFaderIsMute; + MainMixerBoard->vecStoredFaderGroupID = pClient->vecStoredFaderGroupID; + MainMixerBoard->iNewClientFaderLevel = pClient->iNewClientFaderLevel; // init status label OnTimerStatus(); @@ -602,6 +603,7 @@ void CClientDlg::closeEvent ( QCloseEvent* Event ) pClient->vecStoredPanValues = MainMixerBoard->vecStoredPanValues; pClient->vecStoredFaderIsSolo = MainMixerBoard->vecStoredFaderIsSolo; pClient->vecStoredFaderIsMute = MainMixerBoard->vecStoredFaderIsMute; + pClient->vecStoredFaderGroupID = MainMixerBoard->vecStoredFaderGroupID; pClient->iNewClientFaderLevel = MainMixerBoard->iNewClientFaderLevel; pClient->bConnectDlgShowAllMusicians = ConnectDlg.GetShowAllMusicians(); diff --git a/src/global.h b/src/global.h index 304e813b..dc4fea5a 100755 --- a/src/global.h +++ b/src/global.h @@ -152,6 +152,9 @@ LED bar: lbr #define AUD_MIX_FADER_MAX 100 #define AUD_MIX_PAN_MAX 100 +// maximum number of fader groups +#define MAX_NUM_FADER_GROUPS 10 + // maximum number of recognized sound cards installed in the system #define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS) diff --git a/src/settings.cpp b/src/settings.cpp index 2efd5186..b11f5d89 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -278,6 +278,17 @@ void CClientSettings::ReadFromXML ( const QDomDocument& IniXMLDocument ) } } + // stored fader group ID + for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_SETTINGS; iIdx++ ) + { + if ( GetNumericIniSet ( IniXMLDocument, "client", + QString ( "storedgroupid%1" ).arg ( iIdx ), + 0, MAX_NUM_FADER_GROUPS, iValue ) ) + { + pClient->vecStoredFaderGroupID[iIdx] = iValue; + } + } + // new client level if ( GetNumericIniSet ( IniXMLDocument, "client", "newclientlevel", 0, 100, iValue ) ) @@ -585,6 +596,14 @@ void CClientSettings::WriteToXML ( QDomDocument& IniXMLDocument ) pClient->vecStoredFaderIsMute[iIdx] != 0 ); } + // stored fader group ID + for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_SETTINGS; iIdx++ ) + { + SetNumericIniSet ( IniXMLDocument, "client", + QString ( "storedgroupid%1" ).arg ( iIdx ), + pClient->vecStoredFaderGroupID[iIdx] ); + } + // new client level SetNumericIniSet ( IniXMLDocument, "client", "newclientlevel", pClient->iNewClientFaderLevel );