From 471d1df835664529769b43f958f373fd480a99ed Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 22 Apr 2020 21:19:55 +0200 Subject: [PATCH] add support for level meter bars for normal skin (fancy skin still uses LEDs) --- ChangeLog | 2 + src/audiomixerboard.cpp | 27 ++++---- src/client.h | 4 +- src/clientdlg.cpp | 36 +++++------ src/clientdlgbase.ui | 40 +++--------- src/global.h | 5 -- src/multicolorledbar.cpp | 132 +++++++++++++++++++++++++++------------ src/multicolorledbar.h | 30 ++++++--- src/server.cpp | 4 +- src/server.h | 1 + src/util.h | 4 +- 11 files changed, 163 insertions(+), 122 deletions(-) diff --git a/ChangeLog b/ChangeLog index c719ea90..faf7cf89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ 3.5.2git + * use audio level meter bars for normal skin + * store Show All Musicians setting in the ini-file * improved Mac installer, coded by doloopuntil diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 6569c3f6..903015ef 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -56,12 +56,12 @@ CChannelFader::CChannelFader ( QWidget* pNW, QVBoxLayout* pLabelPictGrid = new QVBoxLayout ( ); // setup channel level - plbrChannelLevel->setContentsMargins( 0, 3, 2, 3 ); + plbrChannelLevel->setContentsMargins ( 0, 3, 2, 3 ); // setup slider - pFader->setPageStep ( 1 ); + pFader->setPageStep ( 1 ); 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 ); // setup fader tag label (black bold text which is centered) @@ -93,8 +93,8 @@ CChannelFader::CChannelFader ( QWidget* pNW, pLevelsGrid->addWidget ( plbrChannelLevel, 0, Qt::AlignRight ); pLevelsGrid->addWidget ( pFader, 0, Qt::AlignLeft ); - pMuteSoloGrid->addWidget ( pcbMute, 0, Qt::AlignLeft ); - pMuteSoloGrid->addWidget ( pcbSolo, 0, Qt::AlignLeft ); + pMuteSoloGrid->addWidget ( pcbMute, 0, Qt::AlignLeft ); + pMuteSoloGrid->addWidget ( pcbSolo, 0, Qt::AlignLeft ); pMainGrid->addWidget ( pLevelsBox, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pMuteSoloBox, 0, Qt::AlignHCenter ); @@ -172,18 +172,17 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) " padding-bottom: -15px; }" "QSlider::handle { image: url(:/png/fader/res/faderhandle.png); }" ); - // mute button - pcbMute->setText ( tr ( "MUTE" ) ); - - // solo button - pcbSolo->setText ( tr ( "SOLO" ) ); + pcbMute->setText ( tr ( "MUTE" ) ); + pcbSolo->setText ( tr ( "SOLO" ) ); + plbrChannelLevel->SetLevelMeterType ( CMultiColorLEDBar::MT_LED ); break; default: // reset style sheet and set original paramters - pFader->setStyleSheet ( "" ); - pcbMute->setText ( tr ( "Mute" ) ); - pcbSolo->setText ( tr ( "Solo" ) ); + pFader->setStyleSheet ( "" ); + pcbMute->setText ( tr ( "Mute" ) ); + pcbSolo->setText ( tr ( "Solo" ) ); + plbrChannelLevel->SetLevelMeterType ( CMultiColorLEDBar::MT_BAR ); break; } } @@ -826,7 +825,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf bStoredFaderIsSolo, bStoredFaderIsMute ) ) { - vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel ); + vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel ); vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo ); vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute ); } diff --git a/src/client.h b/src/client.h index bcf60790..f3dda0ec 100755 --- a/src/client.h +++ b/src/client.h @@ -114,8 +114,8 @@ public: bool IsRunning() { return Sound.IsRunning(); } bool SetServerAddr ( QString strNAddr ); - double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); } - double MicLevelR() { return SignalLevelMeter.MicLevelRight(); } + double MicLeveldB_L() { return SignalLevelMeter.MicLeveldBLeft(); } + double MicLeveldB_R() { return SignalLevelMeter.MicLeveldBRight(); } bool GetAndResetbJitterBufferOKFlag(); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 47cf4189..fb138d3e 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -936,34 +936,28 @@ void CClientDlg::OnLocalMuteStateChanged ( int value ) void CClientDlg::OnTimerSigMet() { // get current input levels - double dCurSigLevelL = pClient->MicLevelL(); - double dCurSigLevelR = pClient->MicLevelR(); + double dCurSigLeveldB_L = pClient->MicLeveldB_L(); + double dCurSigLeveldB_R = pClient->MicLeveldB_R(); - // linear transformation of the input level range to the progress-bar - // range - dCurSigLevelL -= LOW_BOUND_SIG_METER; - dCurSigLevelL *= NUM_STEPS_LED_BAR / - ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); + // linear transformation of the input level range to the progress-bar range + dCurSigLeveldB_L -= LOW_BOUND_SIG_METER; + dCurSigLeveldB_L *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); + dCurSigLeveldB_R -= LOW_BOUND_SIG_METER; + dCurSigLeveldB_R *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); // lower bound the signal - if ( dCurSigLevelL < 0 ) + if ( dCurSigLeveldB_L < 0 ) { - dCurSigLevelL = 0; + dCurSigLeveldB_L = 0; } - - dCurSigLevelR -= LOW_BOUND_SIG_METER; - dCurSigLevelR *= NUM_STEPS_LED_BAR / - ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); - - // lower bound the signal - if ( dCurSigLevelR < 0 ) + if ( dCurSigLeveldB_R < 0 ) { - dCurSigLevelR = 0; + dCurSigLeveldB_R = 0; } // show current level - lbrInputLevelL->setValue ( static_cast ( ceil ( dCurSigLevelL ) ) ); - lbrInputLevelR->setValue ( static_cast ( ceil ( dCurSigLevelR ) ) ); + lbrInputLevelL->setValue ( dCurSigLeveldB_L ); + lbrInputLevelR->setValue ( dCurSigLeveldB_R ); } void CClientDlg::OnTimerBuffersLED() @@ -1187,6 +1181,8 @@ rbtReverbSelR->setStyleSheet ( "color: rgb(220, 220, 220);" "font: bold;" ); #endif + lbrInputLevelL->SetLevelMeterType ( CMultiColorLEDBar::MT_LED ); + lbrInputLevelR->SetLevelMeterType ( CMultiColorLEDBar::MT_LED ); break; default: @@ -1199,6 +1195,8 @@ rbtReverbSelL->setStyleSheet ( "" ); rbtReverbSelR->setStyleSheet ( "" ); #endif + lbrInputLevelL->SetLevelMeterType ( CMultiColorLEDBar::MT_BAR ); + lbrInputLevelR->SetLevelMeterType ( CMultiColorLEDBar::MT_BAR ); break; } diff --git a/src/clientdlgbase.ui b/src/clientdlgbase.ui index 6ea1adc3..955f4f35 100755 --- a/src/clientdlgbase.ui +++ b/src/clientdlgbase.ui @@ -242,7 +242,7 @@ - + 0 0 @@ -258,7 +258,7 @@ - + 0 0 @@ -346,34 +346,14 @@ - - - - - C&onnect - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 0 - 25 - - - - - + + + C&onnect + + + true + + diff --git a/src/global.h b/src/global.h index f40c9393..382f5599 100755 --- a/src/global.h +++ b/src/global.h @@ -166,11 +166,6 @@ LED bar: lbr // maximum number of fader settings to be stored (together with the fader tags) #define MAX_NUM_STORED_FADER_SETTINGS 200 -// defines for LED level meter CMultiColorLEDBar -#define NUM_STEPS_LED_BAR 8 -#define RED_BOUND_LED_BAR 7 -#define YELLOW_BOUND_LED_BAR 5 - // range for signal level meter #define LOW_BOUND_SIG_METER ( -50.0 ) // dB #define UPPER_BOUND_SIG_METER ( 0.0 ) // dB diff --git a/src/multicolorledbar.cpp b/src/multicolorledbar.cpp index 8baedfb8..0cd94af4 100755 --- a/src/multicolorledbar.cpp +++ b/src/multicolorledbar.cpp @@ -29,39 +29,65 @@ /* Implementation *************************************************************/ -CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f ) - : QFrame ( parent, f ) +CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f ) : + QWidget ( parent, f ), + eLevelMeterType ( MT_BAR ) { - // set total number of LEDs - iNumLEDs = NUM_STEPS_LED_BAR; - - // create layout and set spacing to zero - pMainLayout = new QVBoxLayout ( this ); - pMainLayout->setAlignment ( Qt::AlignHCenter ); - pMainLayout->setMargin ( 0 ); - pMainLayout->setSpacing ( 0 ); + // initialize LED meter + QWidget* pLEDMeter = new QWidget(); + QVBoxLayout* pLEDLayout = new QVBoxLayout ( pLEDMeter ); + pLEDLayout->setAlignment ( Qt::AlignHCenter ); + pLEDLayout->setMargin ( 0 ); + pLEDLayout->setSpacing ( 0 ); // create LEDs - vecpLEDs.Init ( iNumLEDs ); - for ( int iLEDIdx = iNumLEDs - 1; iLEDIdx >= 0; iLEDIdx-- ) + vecpLEDs.Init ( NUM_STEPS_LED_BAR ); + + for ( int iLEDIdx = NUM_STEPS_LED_BAR - 1; iLEDIdx >= 0; iLEDIdx-- ) { // create LED object vecpLEDs[iLEDIdx] = new cLED ( parent ); // add LED to layout with spacer (do not add spacer on the bottom of the // first LED) - if ( iLEDIdx < iNumLEDs - 1 ) + if ( iLEDIdx < NUM_STEPS_LED_BAR - 1 ) { - pMainLayout->addStretch(); + pLEDLayout->addStretch(); } - pMainLayout->addWidget ( vecpLEDs[iLEDIdx]->getLabelPointer() ); + + pLEDLayout->addWidget ( vecpLEDs[iLEDIdx]->getLabelPointer() ); } + + // initialize bar meter + pProgressBar = new QProgressBar(); + pProgressBar->setOrientation ( Qt::Vertical ); + pProgressBar->setRange ( 0, 100 * NUM_STEPS_LED_BAR ); + pProgressBar->setFormat ( "" ); // suppress percent numbers + pProgressBar->setStyleSheet ( + "QProgressBar { margin: 1px;" + " padding: 1px; " + " width: 15px; }" + "QProgressBar::chunk { background: green; }" ); + + // setup stacked layout for meter type switching mechanism + pStackedLayout = new QStackedLayout ( this ); + pStackedLayout->addWidget ( pLEDMeter ); + pStackedLayout->addWidget ( pProgressBar ); + + // according to QScrollArea description: "When using a scroll area to display the + // contents of a custom widget, it is important to ensure that the size hint of + // the child widget is set to a suitable value." + pProgressBar->setMinimumSize ( QSize ( 1, 1 ) ); + pLEDMeter->setMinimumSize ( QSize ( 1, 1 ) ); + + // update the meter type (using the default value of the meter type) + SetLevelMeterType ( eLevelMeterType ); } CMultiColorLEDBar::~CMultiColorLEDBar() { // clean up the LED objects - for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ ) + for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ ) { delete vecpLEDs[iLEDIdx]; } @@ -80,7 +106,7 @@ void CMultiColorLEDBar::changeEvent ( QEvent* curEvent ) void CMultiColorLEDBar::Reset ( const bool bEnabled ) { // update state of all LEDs - for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ ) + for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ ) { // different reset behavoiur for enabled and disabled control if ( bEnabled ) @@ -94,41 +120,66 @@ void CMultiColorLEDBar::Reset ( const bool bEnabled ) } } -void CMultiColorLEDBar::setValue ( const int value ) +void CMultiColorLEDBar::SetLevelMeterType ( const ELevelMeterType eNType ) +{ + eLevelMeterType = eNType; + + switch ( eNType ) + { + case MT_LED: + pStackedLayout->setCurrentIndex ( 0 ); + break; + + case MT_BAR: + pStackedLayout->setCurrentIndex ( 1 ); + break; + } +} + +void CMultiColorLEDBar::setValue ( const double dValue ) { if ( this->isEnabled() ) { - // update state of all LEDs for current level value - for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ ) + switch ( eLevelMeterType ) { - // set active LED color if value is above current LED index - if ( iLEDIdx < value ) + case MT_LED: + // update state of all LEDs for current level value + for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ ) { - // check which color we should use (green, yellow or red) - if ( iLEDIdx < YELLOW_BOUND_LED_BAR ) + // set active LED color if value is above current LED index + if ( iLEDIdx < dValue ) { - // green region - vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREEN ); - } - else - { - if ( iLEDIdx < RED_BOUND_LED_BAR ) + // check which color we should use (green, yellow or red) + if ( iLEDIdx < YELLOW_BOUND_LED_BAR ) { - // yellow region - vecpLEDs[iLEDIdx]->setColor ( cLED::RL_YELLOW ); + // green region + vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREEN ); } else { - // red region - vecpLEDs[iLEDIdx]->setColor ( cLED::RL_RED ); + if ( iLEDIdx < RED_BOUND_LED_BAR ) + { + // yellow region + vecpLEDs[iLEDIdx]->setColor ( cLED::RL_YELLOW ); + } + else + { + // red region + vecpLEDs[iLEDIdx]->setColor ( cLED::RL_RED ); + } } } + else + { + // we use grey LED for inactive state + vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREY ); + } } - else - { - // we use grey LED for inactive state - vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREY ); - } + break; + + case MT_BAR: + pProgressBar->setValue ( 100 * dValue ); + break; } } } @@ -144,8 +195,7 @@ CMultiColorLEDBar::cLED::cLED ( QWidget* parent ) : pLEDLabel = new QLabel ( "", parent ); // bitmap defines minimum size of the label - pLEDLabel->setMinimumSize ( - BitmCubeRoundGrey.width(), BitmCubeRoundGrey.height() ); + pLEDLabel->setMinimumSize ( BitmCubeRoundGrey.width(), BitmCubeRoundGrey.height() ); // set initial bitmap pLEDLabel->setPixmap ( BitmCubeRoundGrey ); diff --git a/src/multicolorledbar.h b/src/multicolorledbar.h index 6d215c55..bd3863c6 100755 --- a/src/multicolorledbar.h +++ b/src/multicolorledbar.h @@ -28,20 +28,36 @@ #include #include #include +#include +#include #include "util.h" #include "global.h" +/* Definitions ****************************************************************/ +// defines for LED level meter CMultiColorLEDBar +#define NUM_STEPS_LED_BAR 8 +#define RED_BOUND_LED_BAR 7 +#define YELLOW_BOUND_LED_BAR 5 + + /* Classes ********************************************************************/ -class CMultiColorLEDBar : public QFrame +class CMultiColorLEDBar : public QWidget { Q_OBJECT public: + enum ELevelMeterType + { + MT_LED, + MT_BAR + }; + CMultiColorLEDBar ( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); virtual ~CMultiColorLEDBar(); - void setValue ( const int value ); + void setValue ( const double dValue ); + void SetLevelMeterType ( const ELevelMeterType eNType ); protected: class cLED @@ -57,7 +73,7 @@ protected: }; cLED ( QWidget* parent ); - void setColor ( const ELightColor eNewColor ); + void setColor ( const ELightColor eNewColor ); QLabel* getLabelPointer() { return pLEDLabel; } protected: @@ -74,8 +90,8 @@ protected: void Reset ( const bool bEnabled ); virtual void changeEvent ( QEvent* curEvent ); - QVBoxLayout* pMainLayout; - - int iNumLEDs; - CVector vecpLEDs; + QStackedLayout* pStackedLayout; + ELevelMeterType eLevelMeterType; + CVector vecpLEDs; + QProgressBar* pProgressBar; }; diff --git a/src/server.cpp b/src/server.cpp index 4c93c723..7d794815 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -1757,6 +1757,7 @@ void CServer::CreateLevelsForAllConChannels ( const int i const CVector& vecsData = vecvecsData[j]; double dCurLevel = 0.0; + if ( vecNumAudioChannels[j] == 1 ) { // mono @@ -1785,8 +1786,7 @@ void CServer::CreateLevelsForAllConChannels ( const int i // map to signal level meter dCurSigLevel -= LOW_BOUND_SIG_METER; - dCurSigLevel *= NUM_STEPS_LED_BAR / - ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); + dCurSigLevel *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); if ( dCurSigLevel < 0 ) { diff --git a/src/server.h b/src/server.h index 4559089b..d56a42c8 100755 --- a/src/server.h +++ b/src/server.h @@ -41,6 +41,7 @@ #include "util.h" #include "serverlogging.h" #include "serverlist.h" +#include "multicolorledbar.h" #include "recorder/jamrecorder.h" diff --git a/src/util.h b/src/util.h index c5e2d6ac..99fff348 100755 --- a/src/util.h +++ b/src/util.h @@ -655,8 +655,8 @@ public: CStereoSignalLevelMeter() { Reset(); } void Update ( const CVector& vecsAudio ); - double MicLevelLeft() { return CalcLogResult ( dCurLevelL ); } - double MicLevelRight() { return CalcLogResult ( dCurLevelR ); } + double MicLeveldBLeft() { return CalcLogResult ( dCurLevelL ); } + double MicLeveldBRight() { return CalcLogResult ( dCurLevelR ); } static double CalcLogResult ( const double& dLinearLevel ); void Reset()