support for storing fader tags/levels in settings file

This commit is contained in:
Volker Fischer 2013-02-28 20:54:47 +00:00
parent b8759620ef
commit 797a991417
7 changed files with 87 additions and 25 deletions

View file

@ -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<QString> vecStoredFaderTags;
CVector<int> vecStoredFaderLevels;
protected:
int GetStoredFaderLevel ( const CChannelInfo& ChanInfo );
void StoreFaderLevel ( CChannelFader* pChanFader );
@ -115,9 +114,6 @@ protected:
CVector<CChannelFader*> vecpChanFader;
QHBoxLayout* pMainLayout;
CVector<QString> vecStoredFaderTags;
CVector<int> vecStoredFaderGains;
public slots:
// CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!!

View file

@ -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 ),

View file

@ -244,6 +244,8 @@ public:
// settings
CVector<QString> vstrIPAddress;
CChannelCoreInfo ChannelInfo;
CVector<QString> vecStoredFaderTags;
CVector<int> vecStoredFaderLevels;
#ifdef LLCON_VST_PLUGIN
// VST version must have direct access to sound object

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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<class TData> void CVector<TData>::Reset ( const TData tResetVal )
}
// note: this is only supported for string vectors
template<class TData> int CVector<TData>::AddStringFiFoWithCompare ( const QString strNewValue )
template<class TData> int CVector<TData>::StringFiFoWithCompare ( const QString strNewValue,
const bool bDoAdding )
{
int iOldIndex = -1; // init with illegal index per definition
CVector<QString> 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++ )
{