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

@ -172,11 +172,9 @@ 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" ) );
plbrChannelLevel->SetLevelMeterType ( CMultiColorLEDBar::MT_LED );
break;
default:
@ -184,6 +182,7 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )
pFader->setStyleSheet ( "" );
pcbMute->setText ( tr ( "Mute" ) );
pcbSolo->setText ( tr ( "Solo" ) );
plbrChannelLevel->SetLevelMeterType ( CMultiColorLEDBar::MT_BAR );
break;
}
}

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>
@ -345,8 +345,6 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="butConnect">
<property name="text">
@ -357,24 +355,6 @@
</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>
</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)
#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,15 +120,34 @@ 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() )
{
switch ( eLevelMeterType )
{
case MT_LED:
// update state of all LEDs for current level value
for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ )
for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ )
{
// set active LED color if value is above current LED index
if ( iLEDIdx < value )
if ( iLEDIdx < dValue )
{
// check which color we should use (green, yellow or red)
if ( iLEDIdx < YELLOW_BOUND_LED_BAR )
@ -130,6 +175,12 @@ void CMultiColorLEDBar::setValue ( const int value )
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
@ -74,8 +90,8 @@ protected:
void Reset ( const bool bEnabled );
virtual void changeEvent ( QEvent* curEvent );
QVBoxLayout* pMainLayout;
int iNumLEDs;
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()