add support for level meter bars for normal skin (fancy skin still uses LEDs)

This commit is contained in:
Volker Fischer 2020-04-22 21:19:55 +02:00
parent fc98c545ae
commit 471d1df835
11 changed files with 163 additions and 122 deletions

View file

@ -3,6 +3,8 @@
3.5.2git 3.5.2git
* use audio level meter bars for normal skin
* store Show All Musicians setting in the ini-file * store Show All Musicians setting in the ini-file
* improved Mac installer, coded by doloopuntil * improved Mac installer, coded by doloopuntil

View file

@ -56,12 +56,12 @@ CChannelFader::CChannelFader ( QWidget* pNW,
QVBoxLayout* pLabelPictGrid = new QVBoxLayout ( ); QVBoxLayout* pLabelPictGrid = new QVBoxLayout ( );
// setup channel level // setup channel level
plbrChannelLevel->setContentsMargins( 0, 3, 2, 3 ); plbrChannelLevel->setContentsMargins ( 0, 3, 2, 3 );
// 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 );
// setup fader tag label (black bold text which is centered) // 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 ( plbrChannelLevel, 0, Qt::AlignRight );
pLevelsGrid->addWidget ( pFader, 0, Qt::AlignLeft ); pLevelsGrid->addWidget ( pFader, 0, Qt::AlignLeft );
pMuteSoloGrid->addWidget ( pcbMute, 0, Qt::AlignLeft ); pMuteSoloGrid->addWidget ( pcbMute, 0, Qt::AlignLeft );
pMuteSoloGrid->addWidget ( pcbSolo, 0, Qt::AlignLeft ); pMuteSoloGrid->addWidget ( pcbSolo, 0, Qt::AlignLeft );
pMainGrid->addWidget ( pLevelsBox, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pLevelsBox, 0, Qt::AlignHCenter );
pMainGrid->addWidget ( pMuteSoloBox, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pMuteSoloBox, 0, Qt::AlignHCenter );
@ -172,18 +172,17 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )
" padding-bottom: -15px; }" " padding-bottom: -15px; }"
"QSlider::handle { image: url(:/png/fader/res/faderhandle.png); }" ); "QSlider::handle { image: url(:/png/fader/res/faderhandle.png); }" );
// mute button pcbMute->setText ( tr ( "MUTE" ) );
pcbMute->setText ( tr ( "MUTE" ) ); pcbSolo->setText ( tr ( "SOLO" ) );
plbrChannelLevel->SetLevelMeterType ( CMultiColorLEDBar::MT_LED );
// solo button
pcbSolo->setText ( tr ( "SOLO" ) );
break; break;
default: default:
// reset style sheet and set original paramters // reset style sheet and set original paramters
pFader->setStyleSheet ( "" ); pFader->setStyleSheet ( "" );
pcbMute->setText ( tr ( "Mute" ) ); pcbMute->setText ( tr ( "Mute" ) );
pcbSolo->setText ( tr ( "Solo" ) ); pcbSolo->setText ( tr ( "Solo" ) );
plbrChannelLevel->SetLevelMeterType ( CMultiColorLEDBar::MT_BAR );
break; break;
} }
} }
@ -826,7 +825,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
bStoredFaderIsSolo, bStoredFaderIsSolo,
bStoredFaderIsMute ) ) bStoredFaderIsMute ) )
{ {
vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel ); vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel );
vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo ); vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo );
vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute ); vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute );
} }

View file

@ -114,8 +114,8 @@ public:
bool IsRunning() { return Sound.IsRunning(); } bool IsRunning() { return Sound.IsRunning(); }
bool SetServerAddr ( QString strNAddr ); bool SetServerAddr ( QString strNAddr );
double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); } double MicLeveldB_L() { return SignalLevelMeter.MicLeveldBLeft(); }
double MicLevelR() { return SignalLevelMeter.MicLevelRight(); } double MicLeveldB_R() { return SignalLevelMeter.MicLeveldBRight(); }
bool GetAndResetbJitterBufferOKFlag(); bool GetAndResetbJitterBufferOKFlag();

View file

@ -936,34 +936,28 @@ void CClientDlg::OnLocalMuteStateChanged ( int value )
void CClientDlg::OnTimerSigMet() void CClientDlg::OnTimerSigMet()
{ {
// get current input levels // get current input levels
double dCurSigLevelL = pClient->MicLevelL(); double dCurSigLeveldB_L = pClient->MicLeveldB_L();
double dCurSigLevelR = pClient->MicLevelR(); double dCurSigLeveldB_R = pClient->MicLeveldB_R();
// linear transformation of the input level range to the progress-bar // linear transformation of the input level range to the progress-bar range
// range dCurSigLeveldB_L -= LOW_BOUND_SIG_METER;
dCurSigLevelL -= LOW_BOUND_SIG_METER; dCurSigLeveldB_L *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
dCurSigLevelL *= NUM_STEPS_LED_BAR / dCurSigLeveldB_R -= LOW_BOUND_SIG_METER;
( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); dCurSigLeveldB_R *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
// lower bound the signal // lower bound the signal
if ( dCurSigLevelL < 0 ) if ( dCurSigLeveldB_L < 0 )
{ {
dCurSigLevelL = 0; dCurSigLeveldB_L = 0;
} }
if ( dCurSigLeveldB_R < 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 )
{ {
dCurSigLevelR = 0; dCurSigLeveldB_R = 0;
} }
// show current level // show current level
lbrInputLevelL->setValue ( static_cast<int> ( ceil ( dCurSigLevelL ) ) ); lbrInputLevelL->setValue ( dCurSigLeveldB_L );
lbrInputLevelR->setValue ( static_cast<int> ( ceil ( dCurSigLevelR ) ) ); lbrInputLevelR->setValue ( dCurSigLeveldB_R );
} }
void CClientDlg::OnTimerBuffersLED() void CClientDlg::OnTimerBuffersLED()
@ -1187,6 +1181,8 @@ rbtReverbSelR->setStyleSheet ( "color: rgb(220, 220, 220);"
"font: bold;" ); "font: bold;" );
#endif #endif
lbrInputLevelL->SetLevelMeterType ( CMultiColorLEDBar::MT_LED );
lbrInputLevelR->SetLevelMeterType ( CMultiColorLEDBar::MT_LED );
break; break;
default: default:
@ -1199,6 +1195,8 @@ rbtReverbSelL->setStyleSheet ( "" );
rbtReverbSelR->setStyleSheet ( "" ); rbtReverbSelR->setStyleSheet ( "" );
#endif #endif
lbrInputLevelL->SetLevelMeterType ( CMultiColorLEDBar::MT_BAR );
lbrInputLevelR->SetLevelMeterType ( CMultiColorLEDBar::MT_BAR );
break; break;
} }

View file

@ -242,7 +242,7 @@
<item> <item>
<widget class="CMultiColorLEDBar" name="lbrInputLevelL" native="true"> <widget class="CMultiColorLEDBar" name="lbrInputLevelL" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -258,7 +258,7 @@
<item> <item>
<widget class="CMultiColorLEDBar" name="lbrInputLevelR" native="true"> <widget class="CMultiColorLEDBar" name="lbrInputLevelR" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -346,34 +346,14 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout"> <widget class="QPushButton" name="butConnect">
<item> <property name="text">
<widget class="QPushButton" name="butConnect"> <string>C&amp;onnect</string>
<property name="text"> </property>
<string>C&amp;onnect</string> <property name="default">
</property> <bool>true</bool>
<property name="default"> </property>
<bool>true</bool> </widget>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>

View file

@ -166,11 +166,6 @@ LED bar: lbr
// maximum number of fader settings to be stored (together with the fader tags) // maximum number of fader settings to be stored (together with the fader tags)
#define MAX_NUM_STORED_FADER_SETTINGS 200 #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 // range for signal level meter
#define LOW_BOUND_SIG_METER ( -50.0 ) // dB #define LOW_BOUND_SIG_METER ( -50.0 ) // dB
#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB #define UPPER_BOUND_SIG_METER ( 0.0 ) // dB

View file

@ -29,39 +29,65 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f ) CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f ) :
: QFrame ( parent, f ) QWidget ( parent, f ),
eLevelMeterType ( MT_BAR )
{ {
// set total number of LEDs // initialize LED meter
iNumLEDs = NUM_STEPS_LED_BAR; QWidget* pLEDMeter = new QWidget();
QVBoxLayout* pLEDLayout = new QVBoxLayout ( pLEDMeter );
// create layout and set spacing to zero pLEDLayout->setAlignment ( Qt::AlignHCenter );
pMainLayout = new QVBoxLayout ( this ); pLEDLayout->setMargin ( 0 );
pMainLayout->setAlignment ( Qt::AlignHCenter ); pLEDLayout->setSpacing ( 0 );
pMainLayout->setMargin ( 0 );
pMainLayout->setSpacing ( 0 );
// create LEDs // create LEDs
vecpLEDs.Init ( iNumLEDs ); vecpLEDs.Init ( NUM_STEPS_LED_BAR );
for ( int iLEDIdx = iNumLEDs - 1; iLEDIdx >= 0; iLEDIdx-- )
for ( int iLEDIdx = NUM_STEPS_LED_BAR - 1; iLEDIdx >= 0; iLEDIdx-- )
{ {
// create LED object // create LED object
vecpLEDs[iLEDIdx] = new cLED ( parent ); vecpLEDs[iLEDIdx] = new cLED ( parent );
// add LED to layout with spacer (do not add spacer on the bottom of the // add LED to layout with spacer (do not add spacer on the bottom of the
// first LED) // 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() CMultiColorLEDBar::~CMultiColorLEDBar()
{ {
// clean up the LED objects // 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]; delete vecpLEDs[iLEDIdx];
} }
@ -80,7 +106,7 @@ void CMultiColorLEDBar::changeEvent ( QEvent* curEvent )
void CMultiColorLEDBar::Reset ( const bool bEnabled ) void CMultiColorLEDBar::Reset ( const bool bEnabled )
{ {
// update state of all LEDs // 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 // different reset behavoiur for enabled and disabled control
if ( bEnabled ) 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() ) if ( this->isEnabled() )
{ {
// update state of all LEDs for current level value switch ( eLevelMeterType )
for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ )
{ {
// set active LED color if value is above current LED index case MT_LED:
if ( iLEDIdx < value ) // 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) // set active LED color if value is above current LED index
if ( iLEDIdx < YELLOW_BOUND_LED_BAR ) if ( iLEDIdx < dValue )
{ {
// green region // check which color we should use (green, yellow or red)
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREEN ); if ( iLEDIdx < YELLOW_BOUND_LED_BAR )
}
else
{
if ( iLEDIdx < RED_BOUND_LED_BAR )
{ {
// yellow region // green region
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_YELLOW ); vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREEN );
} }
else else
{ {
// red region if ( iLEDIdx < RED_BOUND_LED_BAR )
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_RED ); {
// 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 break;
{
// we use grey LED for inactive state case MT_BAR:
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREY ); pProgressBar->setValue ( 100 * dValue );
} break;
} }
} }
} }
@ -144,8 +195,7 @@ CMultiColorLEDBar::cLED::cLED ( QWidget* parent ) :
pLEDLabel = new QLabel ( "", parent ); pLEDLabel = new QLabel ( "", parent );
// bitmap defines minimum size of the label // bitmap defines minimum size of the label
pLEDLabel->setMinimumSize ( pLEDLabel->setMinimumSize ( BitmCubeRoundGrey.width(), BitmCubeRoundGrey.height() );
BitmCubeRoundGrey.width(), BitmCubeRoundGrey.height() );
// set initial bitmap // set initial bitmap
pLEDLabel->setPixmap ( BitmCubeRoundGrey ); pLEDLabel->setPixmap ( BitmCubeRoundGrey );

View file

@ -28,20 +28,36 @@
#include <QPixmap> #include <QPixmap>
#include <QTimer> #include <QTimer>
#include <QLayout> #include <QLayout>
#include <QProgressBar>
#include <QStackedLayout>
#include "util.h" #include "util.h"
#include "global.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 ********************************************************************/ /* Classes ********************************************************************/
class CMultiColorLEDBar : public QFrame class CMultiColorLEDBar : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
enum ELevelMeterType
{
MT_LED,
MT_BAR
};
CMultiColorLEDBar ( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); CMultiColorLEDBar ( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
virtual ~CMultiColorLEDBar(); virtual ~CMultiColorLEDBar();
void setValue ( const int value ); void setValue ( const double dValue );
void SetLevelMeterType ( const ELevelMeterType eNType );
protected: protected:
class cLED class cLED
@ -57,7 +73,7 @@ protected:
}; };
cLED ( QWidget* parent ); cLED ( QWidget* parent );
void setColor ( const ELightColor eNewColor ); void setColor ( const ELightColor eNewColor );
QLabel* getLabelPointer() { return pLEDLabel; } QLabel* getLabelPointer() { return pLEDLabel; }
protected: protected:
@ -74,8 +90,8 @@ protected:
void Reset ( const bool bEnabled ); void Reset ( const bool bEnabled );
virtual void changeEvent ( QEvent* curEvent ); virtual void changeEvent ( QEvent* curEvent );
QVBoxLayout* pMainLayout; QStackedLayout* pStackedLayout;
ELevelMeterType eLevelMeterType;
int iNumLEDs; CVector<cLED*> vecpLEDs;
CVector<cLED*> vecpLEDs; QProgressBar* pProgressBar;
}; };

View file

@ -1757,6 +1757,7 @@ void CServer::CreateLevelsForAllConChannels ( const int i
const CVector<int16_t>& vecsData = vecvecsData[j]; const CVector<int16_t>& vecsData = vecvecsData[j];
double dCurLevel = 0.0; double dCurLevel = 0.0;
if ( vecNumAudioChannels[j] == 1 ) if ( vecNumAudioChannels[j] == 1 )
{ {
// mono // mono
@ -1785,8 +1786,7 @@ void CServer::CreateLevelsForAllConChannels ( const int i
// map to signal level meter // map to signal level meter
dCurSigLevel -= LOW_BOUND_SIG_METER; dCurSigLevel -= LOW_BOUND_SIG_METER;
dCurSigLevel *= NUM_STEPS_LED_BAR / dCurSigLevel *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
if ( dCurSigLevel < 0 ) if ( dCurSigLevel < 0 )
{ {

View file

@ -41,6 +41,7 @@
#include "util.h" #include "util.h"
#include "serverlogging.h" #include "serverlogging.h"
#include "serverlist.h" #include "serverlist.h"
#include "multicolorledbar.h"
#include "recorder/jamrecorder.h" #include "recorder/jamrecorder.h"

View file

@ -655,8 +655,8 @@ public:
CStereoSignalLevelMeter() { Reset(); } CStereoSignalLevelMeter() { Reset(); }
void Update ( const CVector<short>& vecsAudio ); void Update ( const CVector<short>& vecsAudio );
double MicLevelLeft() { return CalcLogResult ( dCurLevelL ); } double MicLeveldBLeft() { return CalcLogResult ( dCurLevelL ); }
double MicLevelRight() { return CalcLogResult ( dCurLevelR ); } double MicLeveldBRight() { return CalcLogResult ( dCurLevelR ); }
static double CalcLogResult ( const double& dLinearLevel ); static double CalcLogResult ( const double& dLinearLevel );
void Reset() void Reset()