From 797a99141778587ec9f0ab7b1cd5c44a79f80302 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Thu, 28 Feb 2013 20:54:47 +0000 Subject: [PATCH] support for storing fader tags/levels in settings file --- src/audiomixerboard.h | 12 ++++------ src/client.cpp | 2 ++ src/client.h | 2 ++ src/global.h | 3 +++ src/llconclientdlg.cpp | 13 +++++++++- src/settings.cpp | 54 +++++++++++++++++++++++++++++++++++------- src/util.h | 26 +++++++++++++------- 7 files changed, 87 insertions(+), 25 deletions(-) diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index eeaebcc3..268c4764 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -38,11 +38,6 @@ #include "util.h" -/* Definitions ****************************************************************/ -// audio mixer fader range -#define AUD_MIX_FADER_MAX 100 - - /* Classes ********************************************************************/ class CChannelFader : public QObject { @@ -105,6 +100,10 @@ public: void SetServerName ( const QString& strNewServerName ); void SetGUIDesign ( const EGUIDesign eNewDesign ); + // settings + CVector vecStoredFaderTags; + CVector vecStoredFaderLevels; + protected: int GetStoredFaderLevel ( const CChannelInfo& ChanInfo ); void StoreFaderLevel ( CChannelFader* pChanFader ); @@ -115,9 +114,6 @@ protected: 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/client.cpp b/src/client.cpp index bc1fdaeb..80a58c30 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -29,6 +29,8 @@ CClient::CClient ( const quint16 iPortNumber ) : vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), ChannelInfo (), + vecStoredFaderTags ( MAX_NUM_STORED_FADER_LEVELS, "" ), + vecStoredFaderLevels ( MAX_NUM_STORED_FADER_LEVELS, AUD_MIX_FADER_MAX ), Channel ( false ), /* we need a client channel -> "false" */ eAudioCompressionType ( CT_OPUS ), iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ), diff --git a/src/client.h b/src/client.h index 15345ddb..56ab1581 100755 --- a/src/client.h +++ b/src/client.h @@ -244,6 +244,8 @@ public: // settings CVector vstrIPAddress; CChannelCoreInfo ChannelInfo; + CVector vecStoredFaderTags; + CVector vecStoredFaderLevels; #ifdef LLCON_VST_PLUGIN // VST version must have direct access to sound object diff --git a/src/global.h b/src/global.h index 5019dc28..6e8b2372 100755 --- a/src/global.h +++ b/src/global.h @@ -139,6 +139,9 @@ LED bar: lbr // default network buffer size #define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks +// audio mixer fader maximum value +#define AUD_MIX_FADER_MAX 100 + // maximum number of recognized sound cards installed in the system, // definition for "no device" #define MAX_NUMBER_SOUND_CARDS 30 diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 355acb66..6053cae7 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -232,6 +232,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, // reset mixer board MainMixerBoard->HideAll(); + // restore fader settings + MainMixerBoard->vecStoredFaderTags = pClient->vecStoredFaderTags; + MainMixerBoard->vecStoredFaderLevels = pClient->vecStoredFaderLevels; + // init fader tag line edit and instrument picture edtFaderTag->setText ( pClient->ChannelInfo.strName ); butInstPicture->setIcon ( QIcon ( @@ -481,6 +485,13 @@ void CLlconClientDlg::closeEvent ( QCloseEvent* Event ) // store fader tag pClient->ChannelInfo.strName = edtFaderTag->text(); + // store mixer fader settings (we have to hide all mixer faders first to + // initiate a storage of the current mixer fader levels in case we are + // just in a connected state) + MainMixerBoard->HideAll(); + pClient->vecStoredFaderTags = MainMixerBoard->vecStoredFaderTags; + pClient->vecStoredFaderLevels = MainMixerBoard->vecStoredFaderLevels; + // default implementation of this event handler routine Event->accept(); } @@ -862,7 +873,7 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart, { // store new address at the top of the list, if the list was already // full, the last element is thrown out - pClient->vstrIPAddress.AddStringFiFoWithCompare ( strSelectedAddress ); + pClient->vstrIPAddress.StringFiFoWithCompare ( strSelectedAddress ); } // everything was ok with the connection dialog, set flag diff --git a/src/settings.cpp b/src/settings.cpp index 491da79c..11b04437 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -28,6 +28,7 @@ /* Implementation *************************************************************/ void CSettings::Load() { + int iIdx; int iValue; bool bValue; QDomDocument IniXMLDocument; @@ -50,19 +51,38 @@ void CSettings::Load() // client: // IP addresses - for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ ) + for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ ) { QString sDefaultIP = ""; // use default only for first entry - if ( iIPAddrIdx == 0 ) + if ( iIdx == 0 ) { sDefaultIP = DEFAULT_SERVER_ADDRESS; } - pClient->vstrIPAddress[iIPAddrIdx] = + pClient->vstrIPAddress[iIdx] = GetIniSetting ( IniXMLDocument, "client", - QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), sDefaultIP ); + QString ( "ipaddress%1" ).arg ( iIdx ), sDefaultIP ); + } + + // stored fader tags + for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ ) + { + pClient->vecStoredFaderTags[iIdx] = + GetIniSetting ( IniXMLDocument, "client", + QString ( "storedfadertag%1" ).arg ( iIdx ), "" ); + } + + // stored fader levels + for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ ) + { + if ( GetNumericIniSet ( IniXMLDocument, "client", QString ( "storedfaderlevel%1" ).arg ( iIdx ), + 0, AUD_MIX_FADER_MAX, iValue ) ) + { + pClient->vecStoredFaderLevels[iIdx] = iValue; + + } } // name @@ -71,7 +91,7 @@ void CSettings::Load() // instrument if ( GetNumericIniSet ( IniXMLDocument, "client", "instrument", - 0, CInstPictures::GetNumAvailableInst() - 1, iValue ) ) + 0, CInstPictures::GetNumAvailableInst() - 1, iValue ) ) { pClient->ChannelInfo.iInstrument = iValue; } @@ -257,6 +277,8 @@ void CSettings::Load() void CSettings::Save() { + int iIdx; + // create XML document for storing initialization parameters QDomDocument IniXMLDocument; @@ -267,11 +289,27 @@ void CSettings::Save() // client: // IP addresses - for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ ) + for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ ) { PutIniSetting ( IniXMLDocument, "client", - QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), - pClient->vstrIPAddress[iIPAddrIdx] ); + QString ( "ipaddress%1" ).arg ( iIdx ), + pClient->vstrIPAddress[iIdx] ); + } + + // stored fader tags + for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ ) + { + PutIniSetting ( IniXMLDocument, "client", + QString ( "storedfadertag%1" ).arg ( iIdx ), + pClient->vecStoredFaderTags[iIdx] ); + } + + // stored fader levels + for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ ) + { + SetNumericIniSet ( IniXMLDocument, "client", + QString ( "storedfaderlevel%1" ).arg ( iIdx ), + pClient->vecStoredFaderLevels[iIdx] ); } // name diff --git a/src/util.h b/src/util.h index c3db7ea1..0325b7d4 100755 --- a/src/util.h +++ b/src/util.h @@ -112,7 +112,8 @@ public: void Enlarge ( const int iAddedSize ); void Add ( const TData& tI ) { Enlarge ( 1 ); pData[iVectorSize - 1] = tI; } - int AddStringFiFoWithCompare ( const QString strNewValue ); + int StringFiFoWithCompare ( const QString strNewValue, + const bool bDoAdding = true ); inline int Size() const { return iVectorSize; } @@ -206,16 +207,25 @@ template void CVector::Reset ( const TData tResetVal ) } // note: this is only supported for string vectors -template int CVector::AddStringFiFoWithCompare ( const QString strNewValue ) +template int CVector::StringFiFoWithCompare ( const QString strNewValue, + const bool bDoAdding ) { - int iOldIndex = -1; // init with illegal index per definition CVector vstrTempList ( iVectorSize, "" ); - // store the new element in the current storage list at - // the top, make sure we do not have more than allowed stored - // elements - vstrTempList[0] = strNewValue; - int iTempListCnt = 1; + // init with illegal index per definition + int iOldIndex = -1; + + // init temporary list count (may be overwritten later on) + int iTempListCnt = 0; + + if ( bDoAdding ) + { + // store the new element in the current storage list at + // the top, make sure we do not have more than allowed stored + // elements + vstrTempList[0] = strNewValue; + iTempListCnt = 1; + } for ( int iIdx = 0; iIdx < iVectorSize; iIdx++ ) {