From 8db54e8616d89481b8dc2170a02b750c9d64dfe8 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Sun, 29 Mar 2020 22:40:53 +0100 Subject: [PATCH] Add channel level LED bar --- src/audiomixerboard.cpp | 106 +++++++++++++++++++++++++++++++++------- src/audiomixerboard.h | 33 +++++++++---- 2 files changed, 110 insertions(+), 29 deletions(-) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 5f2534e6..98c708ef 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -34,17 +34,29 @@ CChannelFader::CChannelFader ( QWidget* pNW, // create new GUI control objects and store pointers to them (note that // QWidget takes the ownership of the pMainGrid so that this only has // to be created locally in this constructor) - pFrame = new QFrame ( pNW ); - QVBoxLayout* pMainGrid = new QVBoxLayout ( pFrame ); - pFader = new QSlider ( Qt::Vertical, pFrame ); - pcbMute = new QCheckBox ( "Mute", pFrame ); - pcbSolo = new QCheckBox ( "Solo", pFrame ); - pLabelInstBox = new QGroupBox ( pFrame ); - plblLabel = new QLabel ( "", pFrame ); - plblInstrument = new QLabel ( pFrame ); - plblCountryFlag = new QLabel ( pFrame ); - QHBoxLayout* pLabelGrid = new QHBoxLayout ( pLabelInstBox ); - QVBoxLayout* pLabelPictGrid = new QVBoxLayout(); + pFrame = new QFrame ( pNW ); + + pLevelsBox = new QWidget ( pFrame ); + plbrChannelLevel = new CMultiColorLEDBar ( pLevelsBox ); + pFader = new QSlider ( Qt::Vertical, pLevelsBox ); + + pMuteSoloBox = new QWidget ( pFrame ); + pcbMute = new QCheckBox ( "Mute", pMuteSoloBox ); + pcbSolo = new QCheckBox ( "Solo", pMuteSoloBox ); + + pLabelInstBox = new QGroupBox ( pFrame ); + plblLabel = new QLabel ( "", pFrame ); + plblInstrument = new QLabel ( pFrame ); + plblCountryFlag = new QLabel ( pFrame ); + + QVBoxLayout* pMainGrid = new QVBoxLayout ( pFrame ); + QHBoxLayout* pLevelsGrid = new QHBoxLayout ( pLevelsBox ); + QVBoxLayout* pMuteSoloGrid = new QVBoxLayout ( pMuteSoloBox ); + QHBoxLayout* pLabelGrid = new QHBoxLayout ( pLabelInstBox ); + QVBoxLayout* pLabelPictGrid = new QVBoxLayout ( ); + + // setup channel level + plbrChannelLevel->setContentsMargins( 0, 3, 2, 3 ); // setup slider pFader->setPageStep ( 1 ); @@ -62,18 +74,30 @@ CChannelFader::CChannelFader ( QWidget* pNW, // set margins of the layouts to zero to get maximum space for the controls pMainGrid->setContentsMargins ( 0, 0, 0, 0 ); + + pLevelsGrid->setContentsMargins ( 0, 0, 0, 0 ); + pLevelsGrid->setSpacing ( 0 ); // only minimal space + + pMuteSoloGrid->setContentsMargins ( 0, 0, 0, 0 ); + pLabelGrid->setContentsMargins ( 0, 0, 0, 0 ); pLabelGrid->setSpacing ( 2 ); // only minimal space between picture and text // add user controls to the grids pLabelPictGrid->addWidget ( plblCountryFlag, 0, Qt::AlignHCenter ); pLabelPictGrid->addWidget ( plblInstrument, 0, Qt::AlignHCenter ); + pLabelGrid->addLayout ( pLabelPictGrid ); pLabelGrid->addWidget ( plblLabel, 0, Qt::AlignVCenter ); - pMainGrid->addWidget ( pFader, 0, Qt::AlignHCenter ); - pMainGrid->addWidget ( pcbMute, 0, Qt::AlignLeft ); - pMainGrid->addWidget ( pcbSolo, 0, Qt::AlignLeft ); + pLevelsGrid->addWidget ( plbrChannelLevel, 0, Qt::AlignRight ); + pLevelsGrid->addWidget ( pFader, 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 ); pMainGrid->addWidget ( pLabelInstBox ); // add fader frame to audio mixer board layout @@ -83,17 +107,23 @@ CChannelFader::CChannelFader ( QWidget* pNW, Reset(); // add help text to controls + plbrChannelLevel->setWhatsThis ( tr ( "Channel Level: Displays the " + "pre-fader audio level of this channel. All connected clients at the " + "server will be assigned an audio level, the same value for each client." ) ); + plbrChannelLevel->setAccessibleName ( tr ( "Input level of the current audio " + "channel at the server" ) ); + pFader->setWhatsThis ( tr ( "Mixer Fader: Adjusts the audio level of " "this channel. All connected clients at the server will be assigned " - "an audio fader at each client." ) ); - pFader->setAccessibleName ( tr ( "Mixer level setting of the connected client " - "at the server" ) ); + "an audio fader at each client, adjusting the local mix." ) ); + pFader->setAccessibleName ( tr ( "Local mix level setting of the current audio " + "channel at the server" ) ); - pcbMute->setWhatsThis ( tr ( "Mute: With the Mute checkbox, the current " + pcbMute->setWhatsThis ( tr ( "Mute: With the Mute checkbox, the " "audio channel can be muted." ) ); pcbMute->setAccessibleName ( tr ( "Mute button" ) ); - pcbSolo->setWhatsThis ( tr ( "Solo: With the Solo checkbox, the current " + pcbSolo->setWhatsThis ( tr ( "Solo: With the Solo checkbox, the " "audio channel can be set to solo which means that all other channels " "except of the current channel are muted. It is possible to set more than " "one channel to solo." ) ); @@ -158,6 +188,11 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) } } +void CChannelFader::SetDisplayChannelLevel ( const bool eNDCL ) +{ + plbrChannelLevel->setHidden( !eNDCL ); +} + void CChannelFader::SetupFaderTag ( const ESkillLevel eSkillLevel ) { // setup group box for label/instrument picture: set a thick black border @@ -306,6 +341,11 @@ void CChannelFader::UpdateSoloState ( const bool bNewOtherSoloState ) } } +void CChannelFader::SetChannelLevel ( const uint16_t iLevel ) +{ + plbrChannelLevel->setValue ( iLevel ); +} + void CChannelFader::SetText ( const CChannelInfo& ChanInfo ) { // store original received name @@ -634,6 +674,17 @@ void CAudioMixerBoard::SetGUIDesign ( const EGUIDesign eNewDesign ) } } +void CAudioMixerBoard::SetDisplayChannelLevels ( const bool eNDCL ) +{ + bDisplayChannelLevels = eNDCL; + + // apply preference to child GUI controls + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) + { + vecpChanFader[i]->SetDisplayChannelLevel ( bDisplayChannelLevels ); + } +} + void CAudioMixerBoard::HideAll() { // make all controls invisible @@ -710,6 +761,9 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf } } + // At some future time a new level will arrive -- ??? + vecpChanFader[i]->SetChannelLevel ( 0 ); + // set the text in the fader vecpChanFader[i]->SetText ( vecChanInfo[j] ); @@ -857,3 +911,17 @@ bool CAudioMixerBoard::GetStoredFaderSettings ( const CChannelInfo& ChanInfo, // return "not OK" since we did not find matching fader settings return false; } + +void CAudioMixerBoard::SetChannelLevels ( const CVector& vecChannelLevel ) +{ + const int iNumChannelLevels = vecChannelLevel.Size(); + int i = 0; + + for ( int iChId = 0; iChId < MAX_NUM_CHANNELS; iChId++ ) + { + if ( vecpChanFader[iChId]->IsVisible() && i < iNumChannelLevels ) + { + vecpChanFader[iChId]->SetChannelLevel ( vecChannelLevel[i++] ); + } + } +} diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index e22c485d..6ce15c94 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -36,6 +36,7 @@ #include #include "global.h" #include "util.h" +#include "multicolorledbar.h" /* Classes ********************************************************************/ @@ -55,6 +56,7 @@ public: bool IsSolo() { return pcbSolo->isChecked(); } bool IsMute() { return pcbMute->isChecked(); } void SetGUIDesign ( const EGUIDesign eNewDesign ); + void SetDisplayChannelLevel ( const bool eNDCL ); void UpdateSoloState ( const bool bNewOtherSoloState ); void SetFaderLevel ( const int iLevel ); @@ -62,6 +64,7 @@ public: void SetFaderIsMute ( const bool bIsMute ); int GetFaderLevel() { return pFader->value(); } void Reset(); + void SetChannelLevel ( const uint16_t iLevel ); protected: double CalcFaderGain ( const int value ); @@ -69,18 +72,24 @@ protected: void SendFaderLevelToServer ( const int iLevel ); void SetupFaderTag ( const ESkillLevel eSkillLevel ); - QFrame* pFrame; - QGroupBox* pLabelInstBox; - QSlider* pFader; - QCheckBox* pcbMute; - QCheckBox* pcbSolo; - QLabel* plblLabel; - QLabel* plblInstrument; - QLabel* plblCountryFlag; + QFrame* pFrame; - QString strReceivedName; + QWidget* pLevelsBox; + QWidget* pMuteSoloBox; + CMultiColorLEDBar* plbrChannelLevel; + QSlider* pFader; - bool bOtherChannelIsSolo; + QCheckBox* pcbMute; + QCheckBox* pcbSolo; + + QGroupBox* pLabelInstBox; + QLabel* plblLabel; + QLabel* plblInstrument; + QLabel* plblCountryFlag; + + QString strReceivedName; + + bool bOtherChannelIsSolo; public slots: void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); } @@ -103,10 +112,13 @@ public: void ApplyNewConClientList ( CVector& vecChanInfo ); void SetServerName ( const QString& strNewServerName ); void SetGUIDesign ( const EGUIDesign eNewDesign ); + void SetDisplayChannelLevels ( const bool eNDCL ); void SetFaderLevel ( const int iChannelIdx, const int iValue ); + void SetChannelLevels ( const CVector& vecChannelLevel ); + // settings CVector vecStoredFaderTags; CVector vecStoredFaderLevels; @@ -129,6 +141,7 @@ protected: CVector vecpChanFader; QGroupBox* pGroupBox; QHBoxLayout* pMainLayout; + bool bDisplayChannelLevels; bool bNoFaderVisible; public slots: