diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 1391176a..56bd9d7f 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -159,10 +159,10 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) } } -void CChannelFader::Reset() +void CChannelFader::Reset ( const int iLevelValue ) { // init gain value -> maximum value as definition according to server - pFader->setValue ( AUD_MIX_FADER_MAX ); + pFader->setValue ( iLevelValue ); // reset mute/solo check boxes pcbMute->setChecked ( false ); @@ -173,6 +173,12 @@ void CChannelFader::Reset() pLabel->setText ( "" ); bOtherChannelIsSolo = false; + + // if the reset value is not the default one, tell the server about it + if ( iLevelValue != AUD_MIX_FADER_MAX ) + { + emit gainValueChanged ( CalcFaderGain ( iLevelValue ) ); + } } void CChannelFader::OnGainValueChanged ( int value ) @@ -205,7 +211,7 @@ void CChannelFader::SetMute ( const bool bState ) if ( !bOtherChannelIsSolo ) { // mute was unchecked, get current fader value and apply - emit gainValueChanged ( CalcFaderGain ( pFader->value() ) ); + emit gainValueChanged ( CalcFaderGain ( GetFaderLevel() ) ); } } } @@ -305,7 +311,9 @@ double CChannelFader::CalcFaderGain ( const int value ) * CAudioMixerBoard * \******************************************************************************/ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : - QGroupBox ( parent ) + QGroupBox ( parent ), + vecStoredFaderTags ( MAX_NUM_STORED_FADER_LEVELS, "" ), + vecStoredFaderGains ( MAX_NUM_STORED_FADER_LEVELS, AUD_MIX_FADER_MAX ) { // set title text (default: no server given) SetServerName ( "" ); @@ -315,6 +323,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : // create all mixer controls and make them invisible vecpChanFader.Init ( MAX_NUM_CHANNELS ); + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { vecpChanFader[i] = new CChannelFader ( this, pMainLayout ); @@ -382,6 +391,9 @@ void CAudioMixerBoard::HideAll() // make all controls invisible for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { + // before hiding the fader, store its level (if some conditions are fulfulled) + StoreFaderLevel ( vecpChanFader[i] ); + vecpChanFader[i]->Hide(); } @@ -408,7 +420,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf // check if fader was already in use -> preserve gain value if ( !vecpChanFader[i]->IsVisible() ) { - vecpChanFader[i]->Reset(); + vecpChanFader[i]->Reset ( GetStoredFaderLevel ( vecChanInfo[j] ) ); // show fader vecpChanFader[i]->Show(); @@ -444,6 +456,9 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf // if current fader is not used, hide it if ( !bFaderIsUsed ) { + // before hiding the fader, store its level (if some conditions are fulfulled) + StoreFaderLevel ( vecpChanFader[i] ); + vecpChanFader[i]->Hide(); } } @@ -486,7 +501,7 @@ void CAudioMixerBoard::OnGainValueChanged ( const int iChannelIdx, emit ChangeChanGain ( iChannelIdx, dValue ); } -QString CAudioMixerBoard::GenFaderText ( CChannelInfo& ChanInfo ) +QString CAudioMixerBoard::GenFaderText ( const CChannelInfo& ChanInfo ) { // if text is empty, show IP address instead if ( ChanInfo.strName.isEmpty() ) @@ -504,3 +519,53 @@ QString CAudioMixerBoard::GenFaderText ( CChannelInfo& ChanInfo ) return ChanInfo.strName; } } + +void CAudioMixerBoard::StoreFaderLevel ( CChannelFader* pChanFader ) +{ + +// TODO fix all the outstanding issues + +/* + // if the fader was visible and its gain value was not the default + // one, we store the old gain + if ( pChanFader->IsVisible() && + !pChanFader->IsDefaultFaderLevel() ) + { + + // TODO the actual strName is not preserved in the fader -> problem: maybe + // the IP address was substituted which we do not want to use for our + // level storage!!!! + // TODO solve this problem + + + // TODO implementation + // use modified AddStringFiFoWithCompare function (which returns the indices) + + } +*/ +} + +int CAudioMixerBoard::GetStoredFaderLevel ( const CChannelInfo& ChanInfo ) +{ + +// TODO enable the following code as soon as the above problems are solved + +/* + // only do the check if the name string is not empty + if ( !ChanInfo.strName.isEmpty() ) + { + for ( int iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ ) + { + // check if fader text is already known in the list + if ( !vecStoredFaderTags[iIdx].compare ( ChanInfo.strName ) ) + { + // use stored level value (return it) + return vecStoredFaderGains[iIdx]; + } + } + } +*/ + + // return default value + return AUD_MIX_FADER_MAX; +} diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index caf9b33e..a3eb9629 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -61,7 +61,9 @@ public: void ResetSoloState(); void SetOtherSoloState ( const bool bState ); - void Reset(); + int GetFaderLevel() { return pFader->value(); } + bool IsDefaultFaderLevel() { return GetFaderLevel() == AUD_MIX_FADER_MAX; } + void Reset ( const int iLevelValue = AUD_MIX_FADER_MAX ); protected: double CalcFaderGain ( const int value ); @@ -99,13 +101,20 @@ public: void SetGUIDesign ( const EGUIDesign eNewDesign ); protected: - QString GenFaderText ( CChannelInfo& ChanInfo ); + QString GenFaderText ( const CChannelInfo& ChanInfo ); + + int GetStoredFaderLevel ( const CChannelInfo& ChanInfo ); + void StoreFaderLevel ( CChannelFader* pChanFader ); + void OnChSoloStateChanged ( const int iChannelIdx, const int iValue ); void OnGainValueChanged ( const int iChannelIdx, const double dValue ); CVector vecpChanFader; QHBoxLayout* pMainLayout; + CVector vecStoredFaderTags; + CVector vecStoredFaderGains; + public slots: // CODE TAG: MAX_NUM_CHANNELS_TAG // make sure we have MAX_NUM_CHANNELS connections!!! diff --git a/src/global.h b/src/global.h index 8cf7cd05..b2fd59ea 100755 --- a/src/global.h +++ b/src/global.h @@ -153,6 +153,9 @@ LED bar: lbr // maximum number of elemts in the server address combo box #define MAX_NUM_SERVER_ADDR_ITEMS 6 +// maximum number of fader levels to be stored (together with the fader tags) +#define MAX_NUM_STORED_FADER_LEVELS 10 + // defines for LED input level meter #define NUM_STEPS_INP_LEV_METER 8 #define RED_BOUND_INP_LEV_METER 7