implemented Mute check box on faders, prepared for Solo check box on faders

This commit is contained in:
Volker Fischer 2009-05-08 03:54:12 +00:00
parent 3bc7d3cc32
commit fb35fe3b2d
4 changed files with 123 additions and 60 deletions

View file

@ -27,53 +27,100 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CChannelFader::CChannelFader ( QWidget* pNW, CChannelFader::CChannelFader ( QWidget* pNW,
QHBoxLayout* pParentLayout, QHBoxLayout* pParentLayout )
QString sName )
{ {
// create new GUI control objects and store pointers to them // create new GUI control objects and store pointers to them
pMainGrid = new QGridLayout(); pMainGrid = new QVBoxLayout();
pFader = new QSlider ( Qt::Vertical, pNW ); pFader = new QSlider ( Qt::Vertical, pNW );
pcbMute = new QCheckBox ( "Mute", pNW );
pcbSolo = new QCheckBox ( "Solo", pNW );
pLabel = new QLabel ( "", pNW ); pLabel = new QLabel ( "", pNW );
// setup layout
pMainGrid->setSpacing ( 2 );
// setup slider // setup slider
pFader->setPageStep ( 1 ); pFader->setPageStep ( 1 );
pFader->setTickPosition ( QSlider::TicksBothSides ); pFader->setTickPosition ( QSlider::TicksBothSides );
pFader->setRange ( 0, AUD_MIX_FADER_MAX ); pFader->setRange ( 0, AUD_MIX_FADER_MAX );
pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 ); pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 );
pFader->setValue ( 0 ); // set init value
// set label text
pLabel->setText ( sName );
// add slider to grid as position 0 / 0 // TEST solo functionality is not yet implemented, disable control
pMainGrid->addWidget( pFader, 0, 0, Qt::AlignHCenter ); pcbSolo->setEnabled ( false );
// add label to grid as position 1 / 0
pMainGrid->addWidget( pLabel, 1, 0, Qt::AlignHCenter );
pParentLayout->insertLayout ( 0, pMainGrid ); // add user controls to grid
pMainGrid->addWidget( pFader, 0, Qt::AlignHCenter );
pMainGrid->addWidget( pcbMute, 0, Qt::AlignHCenter );
pMainGrid->addWidget( pcbSolo, 0, Qt::AlignHCenter );
pMainGrid->addWidget( pLabel, 0, Qt::AlignHCenter );
// add fader layout to audio mixer board layout
pParentLayout->addLayout ( pMainGrid );
// reset current fader
Reset();
// add help text to controls // add help text to controls
pFader->setWhatsThis ( "<b>Mixer Fader:</b> Adjusts the audio level of this " pFader->setWhatsThis ( "<b>Mixer Fader:</b> Adjusts the audio level of "
"channel. All connected clients at the server will be assigned an audio " "this channel. All connected clients at the server will be assigned "
"fader at each client" ); "an audio fader at each client." );
pLabel->setWhatsThis ( "<b>Mixer Fader Label:</b> Label (fader tag) identifying " pcbMute->setWhatsThis ( "<b>Mute:</b> Mutes the current channel." );
"the connected client. The tag name can be set in the clients main window." );
pcbSolo->setWhatsThis ( "<b>Solo:</b> If Solo checkbox is checked, only "
"the current channel is active and all other channels are muted. Only "
"one channel at a time can be set to solo." );
pLabel->setWhatsThis ( "<b>Mixer Fader Label:</b> Label (fader tag) "
"identifying the connected client. The tag name can be set in the "
"clients main window." );
// connections ------------------------------------------------------------- // connections -------------------------------------------------------------
QObject::connect ( pFader, SIGNAL ( valueChanged ( int ) ), QObject::connect ( pFader, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnValueChanged ( int ) ) ); this, SLOT ( OnFaderValueChanged ( int ) ) );
QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnMuteStateChanged ( int ) ) );
} }
void CChannelFader::OnValueChanged ( int value ) void CChannelFader::Reset()
{ {
// convert actual slider range in gain values // init gain value -> maximum value as definition according to server
// and normalize so that maximum gain is 1 pFader->setValue ( AUD_MIX_FADER_MAX );
const double dCurGain = static_cast<double> ( value ) / AUD_MIX_FADER_MAX;
emit valueChanged ( dCurGain ); // reset mute/solo check boxes
pcbMute->setChecked ( false );
pcbSolo->setChecked ( false );
// clear label
pLabel->setText ( "" );
}
void CChannelFader::OnFaderValueChanged ( int value )
{
// if mute flag is set, do not apply the new fader value
if ( pcbMute->checkState() == Qt::Unchecked )
{
// emit signal for new fader gain value
emit faderValueChanged ( CalcFaderGain ( value ) );
}
}
void CChannelFader::OnMuteStateChanged ( int value )
{
if ( static_cast<Qt::CheckState> ( value ) == Qt::Checked )
{
// mute channel -> send gain of 0
emit faderValueChanged ( 0 );
}
else
{
// mute was unchecked, get current fader value and apply
emit faderValueChanged ( CalcFaderGain ( pFader->value() ) );
}
} }
void CChannelFader::SetText ( const QString sText ) void CChannelFader::SetText ( const QString sText )
@ -90,7 +137,9 @@ void CChannelFader::SetText ( const QString sText )
} }
else else
{ {
sModText.append ( QString ( "<br>" ) ); // 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
sModText.insert ( 0, QString ( "<br>" ) );
} }
// use bold text // use bold text
@ -100,6 +149,13 @@ void CChannelFader::SetText ( const QString sText )
pLabel->setText ( sModText ); pLabel->setText ( sModText );
} }
double CChannelFader::CalcFaderGain ( const int value )
{
// convert actual slider range in gain values
// and normalize so that maximum gain is 1
return static_cast<double> ( value ) / AUD_MIX_FADER_MAX;
}
CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags f ) : QFrame ( parent, f ) CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags f ) : QFrame ( parent, f )
{ {
// set modified style // set modified style
@ -115,7 +171,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags f ) : QFra
vecpChanFader.Init ( MAX_NUM_CHANNELS ); vecpChanFader.Init ( MAX_NUM_CHANNELS );
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
vecpChanFader[i] = new CChannelFader ( this, pMainLayout, "" ); vecpChanFader[i] = new CChannelFader ( this, pMainLayout );
vecpChanFader[i]->Hide(); vecpChanFader[i]->Hide();
} }
@ -123,16 +179,16 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags f ) : QFra
// connections ------------------------------------------------------------- // connections -------------------------------------------------------------
// CODE TAG: MAX_NUM_CHANNELS_TAG // CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!! // make sure we have MAX_NUM_CHANNELS connections!!!
QObject::connect ( vecpChanFader[0], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh0 ( double ) ) ); QObject::connect ( vecpChanFader[0], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh0 ( double ) ) );
QObject::connect ( vecpChanFader[1], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh1 ( double ) ) ); QObject::connect ( vecpChanFader[1], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh1 ( double ) ) );
QObject::connect ( vecpChanFader[2], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh2 ( double ) ) ); QObject::connect ( vecpChanFader[2], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh2 ( double ) ) );
QObject::connect ( vecpChanFader[3], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh3 ( double ) ) ); QObject::connect ( vecpChanFader[3], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh3 ( double ) ) );
QObject::connect ( vecpChanFader[4], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh4 ( double ) ) ); QObject::connect ( vecpChanFader[4], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh4 ( double ) ) );
QObject::connect ( vecpChanFader[5], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh5 ( double ) ) ); QObject::connect ( vecpChanFader[5], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh5 ( double ) ) );
QObject::connect ( vecpChanFader[6], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh6 ( double ) ) ); QObject::connect ( vecpChanFader[6], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh6 ( double ) ) );
QObject::connect ( vecpChanFader[7], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh7 ( double ) ) ); QObject::connect ( vecpChanFader[7], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh7 ( double ) ) );
QObject::connect ( vecpChanFader[8], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh8 ( double ) ) ); QObject::connect ( vecpChanFader[8], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh8 ( double ) ) );
QObject::connect ( vecpChanFader[9], SIGNAL ( valueChanged ( double ) ), this, SLOT ( OnValueChangedCh9 ( double ) ) ); QObject::connect ( vecpChanFader[9], SIGNAL ( faderValueChanged ( double ) ), this, SLOT ( OnFaderValueChangedCh9 ( double ) ) );
} }
void CAudioMixerBoard::HideAll() void CAudioMixerBoard::HideAll()
@ -160,7 +216,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelShortInfo>& vecCh
// 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]->ResetGain(); vecpChanFader[i]->Reset();
// show fader // show fader
vecpChanFader[i]->Show(); vecpChanFader[i]->Show();

View file

@ -27,6 +27,7 @@
#include <qframe.h> #include <qframe.h>
#include <qlabel.h> #include <qlabel.h>
#include <qcheckbox.h>
#include <qlayout.h> #include <qlayout.h>
#include <qstring.h> #include <qstring.h>
#include <qslider.h> #include <qslider.h>
@ -47,33 +48,39 @@ class CChannelFader : public QObject
Q_OBJECT Q_OBJECT
public: public:
CChannelFader ( QWidget* pNW, QHBoxLayout* pParentLayout, QString sName ); CChannelFader ( QWidget* pNW, QHBoxLayout* pParentLayout );
~CChannelFader() ~CChannelFader()
{ {
pLabel->close(); pLabel->close();
pcbMute->close();
pcbSolo->close();
pFader->close(); pFader->close();
// TODO get rid of pMainGrid // TODO get rid of pMainGrid
} }
void SetText ( const QString sText ); void SetText ( const QString sText );
void Show() { pLabel->show(); pFader->show(); } void Show() { pLabel->show(); pcbMute->show(); pcbSolo->show(); pFader->show(); }
void Hide() { pLabel->hide(); pFader->hide(); } void Hide() { pLabel->hide(); pcbMute->hide(); pcbSolo->hide(); pFader->hide(); }
bool IsVisible() { return pLabel->isVisible(); } bool IsVisible() { return pLabel->isVisible(); }
// init gain value -> maximum value as definition according to server void Reset();
void ResetGain() { pFader->setValue ( AUD_MIX_FADER_MAX ); }
protected: protected:
QGridLayout* pMainGrid; double CalcFaderGain ( const int value );
QVBoxLayout* pMainGrid;
QSlider* pFader; QSlider* pFader;
QCheckBox* pcbMute;
QCheckBox* pcbSolo;
QLabel* pLabel; QLabel* pLabel;
public slots: public slots:
void OnValueChanged ( int value ); void OnFaderValueChanged ( int value );
void OnMuteStateChanged ( int value );
signals: signals:
void valueChanged ( double value ); void faderValueChanged ( double value );
}; };
@ -96,20 +103,19 @@ protected:
public slots: public slots:
// CODE TAG: MAX_NUM_CHANNELS_TAG // CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!! // make sure we have MAX_NUM_CHANNELS connections!!!
void OnValueChangedCh0 ( double dValue ) { emit ChangeChanGain ( 0, dValue ); } void OnFaderValueChangedCh0 ( double dValue ) { emit ChangeChanGain ( 0, dValue ); }
void OnValueChangedCh1 ( double dValue ) { emit ChangeChanGain ( 1, dValue ); } void OnFaderValueChangedCh1 ( double dValue ) { emit ChangeChanGain ( 1, dValue ); }
void OnValueChangedCh2 ( double dValue ) { emit ChangeChanGain ( 2, dValue ); } void OnFaderValueChangedCh2 ( double dValue ) { emit ChangeChanGain ( 2, dValue ); }
void OnValueChangedCh3 ( double dValue ) { emit ChangeChanGain ( 3, dValue ); } void OnFaderValueChangedCh3 ( double dValue ) { emit ChangeChanGain ( 3, dValue ); }
void OnValueChangedCh4 ( double dValue ) { emit ChangeChanGain ( 4, dValue ); } void OnFaderValueChangedCh4 ( double dValue ) { emit ChangeChanGain ( 4, dValue ); }
void OnValueChangedCh5 ( double dValue ) { emit ChangeChanGain ( 5, dValue ); } void OnFaderValueChangedCh5 ( double dValue ) { emit ChangeChanGain ( 5, dValue ); }
void OnValueChangedCh6 ( double dValue ) { emit ChangeChanGain ( 6, dValue ); } void OnFaderValueChangedCh6 ( double dValue ) { emit ChangeChanGain ( 6, dValue ); }
void OnValueChangedCh7 ( double dValue ) { emit ChangeChanGain ( 7, dValue ); } void OnFaderValueChangedCh7 ( double dValue ) { emit ChangeChanGain ( 7, dValue ); }
void OnValueChangedCh8 ( double dValue ) { emit ChangeChanGain ( 8, dValue ); } void OnFaderValueChangedCh8 ( double dValue ) { emit ChangeChanGain ( 8, dValue ); }
void OnValueChangedCh9 ( double dValue ) { emit ChangeChanGain ( 9, dValue ); } void OnFaderValueChangedCh9 ( double dValue ) { emit ChangeChanGain ( 9, dValue ); }
signals: signals:
void ChangeChanGain ( int iId, double dGain ); void ChangeChanGain ( int iId, double dGain );
}; };
#endif // MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_ #endif // MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_

View file

@ -37,7 +37,8 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
// add help text to controls // add help text to controls
QString strInpLevH = tr ( "<b>Input level meter:</b> Shows the level of the " QString strInpLevH = tr ( "<b>Input level meter:</b> Shows the level of the "
"input audio signal of the sound card. Overload should be avoided." ); "input audio signal of the sound card. Overload should be avoided." );
TextLabelInputLevel->setWhatsThis ( strInpLevH ); TextLabelInputLevelL->setWhatsThis ( strInpLevH );
TextLabelInputLevelR->setWhatsThis ( strInpLevH );
MultiColorLEDBarInputLevelL->setWhatsThis ( strInpLevH ); MultiColorLEDBarInputLevelL->setWhatsThis ( strInpLevH );
MultiColorLEDBarInputLevelR->setWhatsThis ( strInpLevH ); MultiColorLEDBarInputLevelR->setWhatsThis ( strInpLevH );

View file

@ -5,7 +5,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>520</width> <width>531</width>
<height>324</height> <height>324</height>
</rect> </rect>
</property> </property>
@ -83,7 +83,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="TextLabelInputLevel" > <widget class="QLabel" name="TextLabelInputLevelL" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" > <sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" >
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -99,7 +99,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="TextLabelInputLevel_2" > <widget class="QLabel" name="TextLabelInputLevelR" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" > <sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" >
<horstretch>0</horstretch> <horstretch>0</horstretch>