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
* use audio level meter bars for normal skin
* store Show All Musicians setting in the ini-file
* improved Mac installer, coded by doloopuntil

View File

@ -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<CChannelInfo>& vecChanInf
bStoredFaderIsSolo,
bStoredFaderIsMute ) )
{
vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel );
vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel );
vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo );
vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute );
}

View File

@ -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();

View File

@ -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<int> ( ceil ( dCurSigLevelL ) ) );
lbrInputLevelR->setValue ( static_cast<int> ( 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;
}

View File

@ -242,7 +242,7 @@
<item>
<widget class="CMultiColorLEDBar" name="lbrInputLevelL" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -258,7 +258,7 @@
<item>
<widget class="CMultiColorLEDBar" name="lbrInputLevelR" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -346,34 +346,14 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="butConnect">
<property name="text">
<string>C&amp;onnect</string>
</property>
<property name="default">
<bool>true</bool>
</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>
<widget class="QPushButton" name="butConnect">
<property name="text">
<string>C&amp;onnect</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>

View File

@ -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

View File

@ -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 );

View File

@ -28,20 +28,36 @@
#include <QPixmap>
#include <QTimer>
#include <QLayout>
#include <QProgressBar>
#include <QStackedLayout>
#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<cLED*> vecpLEDs;
QStackedLayout* pStackedLayout;
ELevelMeterType eLevelMeterType;
CVector<cLED*> vecpLEDs;
QProgressBar* pProgressBar;
};

View File

@ -1757,6 +1757,7 @@ void CServer::CreateLevelsForAllConChannels ( const int i
const CVector<int16_t>& 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 )
{

View File

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

View File

@ -655,8 +655,8 @@ public:
CStereoSignalLevelMeter() { Reset(); }
void Update ( const CVector<short>& 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()