support for storing fader levels on a reconnect -> not yet finished, there is a known bug which has to be fixed!
This commit is contained in:
parent
9a9ca7c1c4
commit
471fb0c6ae
2 changed files with 123 additions and 68 deletions
|
@ -114,7 +114,7 @@ CChannelFader::CChannelFader ( QWidget* pNW,
|
||||||
|
|
||||||
// Connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
QObject::connect ( pFader, SIGNAL ( valueChanged ( int ) ),
|
QObject::connect ( pFader, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT ( OnGainValueChanged ( int ) ) );
|
this, SLOT ( OnLevelValueChanged ( int ) ) );
|
||||||
|
|
||||||
QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnMuteStateChanged ( int ) ) );
|
this, SLOT ( OnMuteStateChanged ( int ) ) );
|
||||||
|
@ -159,10 +159,10 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelFader::Reset ( const int iLevelValue )
|
void CChannelFader::Reset()
|
||||||
{
|
{
|
||||||
// init gain value -> maximum value as definition according to server
|
// init gain value -> maximum value as definition according to server
|
||||||
pFader->setValue ( iLevelValue );
|
pFader->setValue ( AUD_MIX_FADER_MAX );
|
||||||
|
|
||||||
// reset mute/solo check boxes
|
// reset mute/solo check boxes
|
||||||
pcbMute->setChecked ( false );
|
pcbMute->setChecked ( false );
|
||||||
|
@ -171,24 +171,31 @@ void CChannelFader::Reset ( const int iLevelValue )
|
||||||
// clear instrument picture and label text
|
// clear instrument picture and label text
|
||||||
pInstrument->setVisible ( false );
|
pInstrument->setVisible ( false );
|
||||||
pLabel->setText ( "" );
|
pLabel->setText ( "" );
|
||||||
|
strReceivedName = "";
|
||||||
|
|
||||||
bOtherChannelIsSolo = false;
|
bOtherChannelIsSolo = false;
|
||||||
|
}
|
||||||
|
|
||||||
// if the reset value is not the default one, tell the server about it
|
void CChannelFader::SetFaderLevel ( const int iLevel )
|
||||||
if ( iLevelValue != AUD_MIX_FADER_MAX )
|
{
|
||||||
|
// first make a range check
|
||||||
|
if ( ( iLevel >= 0 ) && ( iLevel <= AUD_MIX_FADER_MAX ) )
|
||||||
{
|
{
|
||||||
emit gainValueChanged ( CalcFaderGain ( iLevelValue ) );
|
// we set the new fader level in the GUI (slider control) and also tell the
|
||||||
|
// server about the change
|
||||||
|
pFader->setValue ( iLevel );
|
||||||
|
SendFaderLevelToServer ( iLevel );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelFader::OnGainValueChanged ( int value )
|
void CChannelFader::SendFaderLevelToServer ( const int iLevel )
|
||||||
{
|
{
|
||||||
// if mute flag is set or other channel is on solo, do not apply the new
|
// if mute flag is set or other channel is on solo, do not apply the new
|
||||||
// fader value
|
// fader value
|
||||||
if ( ( pcbMute->checkState() == Qt::Unchecked ) && !bOtherChannelIsSolo )
|
if ( ( pcbMute->checkState() == Qt::Unchecked ) && !bOtherChannelIsSolo )
|
||||||
{
|
{
|
||||||
// emit signal for new fader gain value
|
// emit signal for new fader gain value
|
||||||
emit gainValueChanged ( CalcFaderGain ( value ) );
|
emit gainValueChanged ( CalcFaderGain ( iLevel ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,26 +261,29 @@ void CChannelFader::SetOtherSoloState ( const bool bState )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelFader::SetText ( const QString sText )
|
void CChannelFader::SetText ( const CChannelInfo& ChanInfo )
|
||||||
{
|
{
|
||||||
const int iBreakPos = MAX_LEN_FADER_TAG / 2;
|
// store original received name
|
||||||
|
strReceivedName = ChanInfo.strName;
|
||||||
|
|
||||||
// break text at predefined position, if text is too short, break anyway to
|
// break text at predefined position, if text is too short, break anyway to
|
||||||
// make sure we have two lines for fader tag
|
// make sure we have two lines for fader tag
|
||||||
QString sModText = sText;
|
const int iBreakPos = MAX_LEN_FADER_TAG / 2;
|
||||||
|
|
||||||
if ( sModText.length() > iBreakPos )
|
QString strModText = GenFaderText ( ChanInfo );
|
||||||
|
|
||||||
|
if ( strModText.length() > iBreakPos )
|
||||||
{
|
{
|
||||||
sModText.insert ( iBreakPos, QString ( "\n" ) );
|
strModText.insert ( iBreakPos, QString ( "\n" ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// insert line break at the beginning of the string -> make sure
|
// insert line break at the beginning of the string -> make sure
|
||||||
// if we only have one line that the text appears at the bottom line
|
// if we only have one line that the text appears at the bottom line
|
||||||
sModText.prepend ( QString ( "\n" ) );
|
strModText.prepend ( QString ( "\n" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
pLabel->setText ( sModText );
|
pLabel->setText ( strModText );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelFader::SetInstrumentPicture ( const int iInstrument )
|
void CChannelFader::SetInstrumentPicture ( const int iInstrument )
|
||||||
|
@ -306,6 +316,25 @@ double CChannelFader::CalcFaderGain ( const int value )
|
||||||
return static_cast<double> ( value ) / AUD_MIX_FADER_MAX;
|
return static_cast<double> ( value ) / AUD_MIX_FADER_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CChannelFader::GenFaderText ( const CChannelInfo& ChanInfo )
|
||||||
|
{
|
||||||
|
// if text is empty, show IP address instead
|
||||||
|
if ( ChanInfo.strName.isEmpty() )
|
||||||
|
{
|
||||||
|
// convert IP address to text and show it (use dummy port number
|
||||||
|
// since it is not used here)
|
||||||
|
const CHostAddress TempAddr =
|
||||||
|
CHostAddress ( QHostAddress ( ChanInfo.iIpAddr ), 0 );
|
||||||
|
|
||||||
|
return TempAddr.toString ( CHostAddress::SM_IP_NO_LAST_BYTE );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// show name of channel
|
||||||
|
return ChanInfo.strName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* CAudioMixerBoard *
|
* CAudioMixerBoard *
|
||||||
|
@ -391,7 +420,7 @@ void CAudioMixerBoard::HideAll()
|
||||||
// make all controls invisible
|
// make all controls invisible
|
||||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
// before hiding the fader, store its level (if some conditions are fulfulled)
|
// before hiding the fader, store its level (if some conditions are fullfilled)
|
||||||
StoreFaderLevel ( vecpChanFader[i] );
|
StoreFaderLevel ( vecpChanFader[i] );
|
||||||
|
|
||||||
vecpChanFader[i]->Hide();
|
vecpChanFader[i]->Hide();
|
||||||
|
@ -420,7 +449,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
|
||||||
// check if fader was already in use -> preserve gain value
|
// check if fader was already in use -> preserve gain value
|
||||||
if ( !vecpChanFader[i]->IsVisible() )
|
if ( !vecpChanFader[i]->IsVisible() )
|
||||||
{
|
{
|
||||||
vecpChanFader[i]->Reset ( GetStoredFaderLevel ( vecChanInfo[j] ) );
|
vecpChanFader[i]->Reset();
|
||||||
|
|
||||||
// show fader
|
// show fader
|
||||||
vecpChanFader[i]->Show();
|
vecpChanFader[i]->Show();
|
||||||
|
@ -433,9 +462,24 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
|
||||||
vecpChanFader[i]->ResetSoloState();
|
vecpChanFader[i]->ResetSoloState();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update text
|
// update text (if different from the current one)
|
||||||
vecpChanFader[i]->
|
if ( vecpChanFader[i]->GetReceivedName().compare ( vecChanInfo[j].strName ) )
|
||||||
SetText ( GenFaderText ( vecChanInfo[j] ) );
|
{
|
||||||
|
// set the text in the fader
|
||||||
|
vecpChanFader[i]->SetText ( vecChanInfo[j] );
|
||||||
|
|
||||||
|
// the text has actually changed, search in the list of
|
||||||
|
// stored gains if we have a matching entry
|
||||||
|
const int iStoredFaderLevel =
|
||||||
|
GetStoredFaderLevel ( vecChanInfo[j] );
|
||||||
|
|
||||||
|
// only apply retreived fader level if it is different from
|
||||||
|
// the default one
|
||||||
|
if ( iStoredFaderLevel != AUD_MIX_FADER_MAX )
|
||||||
|
{
|
||||||
|
vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update other channel infos (only available for new protocol
|
// update other channel infos (only available for new protocol
|
||||||
// which is not compatible with old versions -> this way we make
|
// which is not compatible with old versions -> this way we make
|
||||||
|
@ -456,7 +500,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
|
||||||
// if current fader is not used, hide it
|
// if current fader is not used, hide it
|
||||||
if ( !bFaderIsUsed )
|
if ( !bFaderIsUsed )
|
||||||
{
|
{
|
||||||
// before hiding the fader, store its level (if some conditions are fulfulled)
|
// before hiding the fader, store its level (if some conditions are fullfilled)
|
||||||
StoreFaderLevel ( vecpChanFader[i] );
|
StoreFaderLevel ( vecpChanFader[i] );
|
||||||
|
|
||||||
vecpChanFader[i]->Hide();
|
vecpChanFader[i]->Hide();
|
||||||
|
@ -501,56 +545,65 @@ void CAudioMixerBoard::OnGainValueChanged ( const int iChannelIdx,
|
||||||
emit ChangeChanGain ( iChannelIdx, dValue );
|
emit ChangeChanGain ( iChannelIdx, dValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CAudioMixerBoard::GenFaderText ( const CChannelInfo& ChanInfo )
|
|
||||||
{
|
|
||||||
// if text is empty, show IP address instead
|
|
||||||
if ( ChanInfo.strName.isEmpty() )
|
|
||||||
{
|
|
||||||
// convert IP address to text and show it (use dummy port number
|
|
||||||
// since it is not used here)
|
|
||||||
const CHostAddress TempAddr =
|
|
||||||
CHostAddress ( QHostAddress ( ChanInfo.iIpAddr ), 0 );
|
|
||||||
|
|
||||||
return TempAddr.toString ( CHostAddress::SM_IP_NO_LAST_BYTE );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// show name of channel
|
|
||||||
return ChanInfo.strName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAudioMixerBoard::StoreFaderLevel ( CChannelFader* pChanFader )
|
void CAudioMixerBoard::StoreFaderLevel ( CChannelFader* pChanFader )
|
||||||
{
|
{
|
||||||
|
// if the fader was visible and the name is not empty, we store the old gain
|
||||||
// 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() &&
|
if ( pChanFader->IsVisible() &&
|
||||||
!pChanFader->IsDefaultFaderLevel() )
|
!pChanFader->GetReceivedName().isEmpty() )
|
||||||
{
|
{
|
||||||
|
// init temporary list count (may be overwritten later on)
|
||||||
|
int iTempListCnt = 0;
|
||||||
|
|
||||||
// TODO the actual strName is not preserved in the fader -> problem: maybe
|
// check if the new fader level is the default one -> in that case the
|
||||||
// the IP address was substituted which we do not want to use for our
|
// entry must be deleted from the list if currently present in the list
|
||||||
// level storage!!!!
|
const bool bNewLevelIsDefaultFaderLevel =
|
||||||
// TODO solve this problem
|
( pChanFader->GetFaderLevel() == AUD_MIX_FADER_MAX );
|
||||||
|
|
||||||
|
// add the new entry at the top of the list and get the index of the old
|
||||||
|
// position of the entry in the list (in case it was there before)
|
||||||
|
|
||||||
|
|
||||||
// TODO implementation
|
|
||||||
// use modified AddStringFiFoWithCompare function (which returns the indices)
|
|
||||||
|
|
||||||
|
// TODO this does not work for removing an entry, i.e., if bNewLevelIsDefaultFaderLevel is true!!!!!
|
||||||
|
// -> fix this bug!!!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const int iOldIdx =
|
||||||
|
vecStoredFaderTags.AddStringFiFoWithCompare ( pChanFader->GetReceivedName() );
|
||||||
|
|
||||||
|
CVector<int> viOldFaderGains ( vecStoredFaderGains );
|
||||||
|
|
||||||
|
// if the new value is not the default value, put it on the top of the
|
||||||
|
// list, otherwise just remove it from the list
|
||||||
|
if ( !bNewLevelIsDefaultFaderLevel )
|
||||||
|
{
|
||||||
|
// current fader level is at the top of the list
|
||||||
|
vecStoredFaderGains[0] = pChanFader->GetFaderLevel();
|
||||||
|
iTempListCnt = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ )
|
||||||
|
{
|
||||||
|
// first check if we still have space in our data storage
|
||||||
|
if ( iTempListCnt < MAX_NUM_STORED_FADER_LEVELS )
|
||||||
|
{
|
||||||
|
// check for the old index of the current entry (this has to be
|
||||||
|
// skipped), note that per definition: the old index is an illegal
|
||||||
|
// index in case the entry was not present in the vector before
|
||||||
|
if ( iIdx != iOldIdx )
|
||||||
|
{
|
||||||
|
vecStoredFaderGains[iTempListCnt] = viOldFaderGains[iIdx];
|
||||||
|
|
||||||
|
iTempListCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAudioMixerBoard::GetStoredFaderLevel ( const CChannelInfo& ChanInfo )
|
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
|
// only do the check if the name string is not empty
|
||||||
if ( !ChanInfo.strName.isEmpty() )
|
if ( !ChanInfo.strName.isEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -564,7 +617,6 @@ int CAudioMixerBoard::GetStoredFaderLevel ( const CChannelInfo& ChanInfo )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// return default value
|
// return default value
|
||||||
return AUD_MIX_FADER_MAX;
|
return AUD_MIX_FADER_MAX;
|
||||||
|
|
|
@ -51,7 +51,8 @@ class CChannelFader : public QObject
|
||||||
public:
|
public:
|
||||||
CChannelFader ( QWidget* pNW, QHBoxLayout* pParentLayout );
|
CChannelFader ( QWidget* pNW, QHBoxLayout* pParentLayout );
|
||||||
|
|
||||||
void SetText ( const QString sText );
|
void SetText ( const CChannelInfo& ChanInfo );
|
||||||
|
QString GetReceivedName() { return strReceivedName; }
|
||||||
void SetInstrumentPicture ( const int iInstrument );
|
void SetInstrumentPicture ( const int iInstrument );
|
||||||
void Show() { pFrame->show(); }
|
void Show() { pFrame->show(); }
|
||||||
void Hide() { pFrame->hide(); }
|
void Hide() { pFrame->hide(); }
|
||||||
|
@ -61,13 +62,15 @@ public:
|
||||||
void ResetSoloState();
|
void ResetSoloState();
|
||||||
void SetOtherSoloState ( const bool bState );
|
void SetOtherSoloState ( const bool bState );
|
||||||
|
|
||||||
|
void SetFaderLevel ( const int iLevel );
|
||||||
int GetFaderLevel() { return pFader->value(); }
|
int GetFaderLevel() { return pFader->value(); }
|
||||||
bool IsDefaultFaderLevel() { return GetFaderLevel() == AUD_MIX_FADER_MAX; }
|
void Reset();
|
||||||
void Reset ( const int iLevelValue = AUD_MIX_FADER_MAX );
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double CalcFaderGain ( const int value );
|
double CalcFaderGain ( const int value );
|
||||||
void SetMute ( const bool bState );
|
void SetMute ( const bool bState );
|
||||||
|
QString GenFaderText ( const CChannelInfo& ChanInfo );
|
||||||
|
void SendFaderLevelToServer ( const int iLevel );
|
||||||
|
|
||||||
QFrame* pFrame;
|
QFrame* pFrame;
|
||||||
QSlider* pFader;
|
QSlider* pFader;
|
||||||
|
@ -76,10 +79,12 @@ protected:
|
||||||
QLabel* pLabel;
|
QLabel* pLabel;
|
||||||
QLabel* pInstrument;
|
QLabel* pInstrument;
|
||||||
|
|
||||||
|
QString strReceivedName;
|
||||||
|
|
||||||
bool bOtherChannelIsSolo;
|
bool bOtherChannelIsSolo;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnGainValueChanged ( int value );
|
void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); }
|
||||||
void OnMuteStateChanged ( int value );
|
void OnMuteStateChanged ( int value );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -101,8 +106,6 @@ public:
|
||||||
void SetGUIDesign ( const EGUIDesign eNewDesign );
|
void SetGUIDesign ( const EGUIDesign eNewDesign );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString GenFaderText ( const CChannelInfo& ChanInfo );
|
|
||||||
|
|
||||||
int GetStoredFaderLevel ( const CChannelInfo& ChanInfo );
|
int GetStoredFaderLevel ( const CChannelInfo& ChanInfo );
|
||||||
void StoreFaderLevel ( CChannelFader* pChanFader );
|
void StoreFaderLevel ( CChannelFader* pChanFader );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue