first version of LED input level meter finished -> not yet ready, some work still has to be done
This commit is contained in:
parent
3537e2fc6d
commit
c9bb67ae14
7 changed files with 122 additions and 97 deletions
|
@ -107,9 +107,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags f ) : QFra
|
|||
setFrameShadow ( QFrame::Sunken );
|
||||
|
||||
// add hboxlayout with horizontal spacer
|
||||
|
||||
// TODO is this ok this way? Don't we need the border 11 and space 0?
|
||||
pMainLayout = new QHBoxLayout ( this );//, 11, 0 );
|
||||
pMainLayout = new QHBoxLayout ( this );
|
||||
|
||||
pMainLayout->addItem ( new QSpacerItem ( 0, 0, QSizePolicy::Expanding ) );
|
||||
|
||||
|
|
|
@ -96,6 +96,11 @@
|
|||
#define MAX_NUMBER_SOUND_CARDS 10
|
||||
#define INVALID_SNC_CARD_DEVICE -1
|
||||
|
||||
// defines for LED input level meter
|
||||
#define NUM_STEPS_INP_LEV_METER 10
|
||||
#define YELLOW_BOUND_INP_LEV_METER 7
|
||||
#define RED_BOUND_INP_LEV_METER 9
|
||||
|
||||
|
||||
// maximum number of internet connections (channels)
|
||||
// if you want to change this paramter, there has to be done code modifications
|
||||
|
|
|
@ -36,11 +36,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
|||
|
||||
// add help text to controls
|
||||
QString strInpLevH = tr ( "<b>Input level meter:</b> Shows the level of the "
|
||||
"input audio signal of the sound card. The level is in dB. Overload "
|
||||
"should be avoided." );
|
||||
"input audio signal of the sound card. Overload should be avoided." );
|
||||
TextLabelInputLevel->setWhatsThis ( strInpLevH );
|
||||
ProgressBarInputLevelL->setWhatsThis ( strInpLevH );
|
||||
ProgressBarInputLevelR->setWhatsThis ( strInpLevH );
|
||||
MultiColorLEDBarInputLevelL->setWhatsThis ( strInpLevH );
|
||||
MultiColorLEDBarInputLevelR->setWhatsThis ( strInpLevH );
|
||||
|
||||
PushButtonConnect->setWhatsThis ( tr ( "<b>Connect / Disconnect Button:"
|
||||
"</b> Push this button to connect the server. A valid IP address has "
|
||||
|
@ -105,12 +104,8 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
|||
PushButtonConnect->setText ( CON_BUT_CONNECTTEXT );
|
||||
|
||||
// init input level meter bars
|
||||
ProgressBarInputLevelL->setMinimum ( 0 );
|
||||
ProgressBarInputLevelL->setMaximum ( NUM_STEPS_INP_LEV_METER );
|
||||
ProgressBarInputLevelL->setValue ( 0 );
|
||||
ProgressBarInputLevelR->setMinimum ( 0 );
|
||||
ProgressBarInputLevelR->setMaximum ( NUM_STEPS_INP_LEV_METER );
|
||||
ProgressBarInputLevelR->setValue ( 0 );
|
||||
MultiColorLEDBarInputLevelL->setValue ( 0 );
|
||||
MultiColorLEDBarInputLevelR->setValue ( 0 );
|
||||
|
||||
|
||||
// init slider controls ---
|
||||
|
@ -296,8 +291,8 @@ void CLlconClientDlg::OnConnectDisconBut()
|
|||
|
||||
// stop timer for level meter bars and reset them
|
||||
TimerSigMet.stop();
|
||||
ProgressBarInputLevelL->setValue ( 0 );
|
||||
ProgressBarInputLevelR->setValue ( 0 );
|
||||
MultiColorLEDBarInputLevelL->setValue ( 0 );
|
||||
MultiColorLEDBarInputLevelR->setValue ( 0 );
|
||||
|
||||
// immediately update status bar
|
||||
OnTimerStatus();
|
||||
|
@ -353,8 +348,8 @@ void CLlconClientDlg::OnTimerSigMet()
|
|||
double dCurSigLevelL = pClient->MicLevelL();
|
||||
double dCurSigLevelR = pClient->MicLevelR();
|
||||
|
||||
/* linear transformation of the input level range to the progress-bar
|
||||
range */
|
||||
// linear transformation of the input level range to the progress-bar
|
||||
// range
|
||||
dCurSigLevelL -= LOW_BOUND_SIG_METER;
|
||||
dCurSigLevelL *= NUM_STEPS_INP_LEV_METER /
|
||||
( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
|
||||
|
@ -376,8 +371,8 @@ void CLlconClientDlg::OnTimerSigMet()
|
|||
}
|
||||
|
||||
// show current level
|
||||
ProgressBarInputLevelL->setValue ( (int) ceil ( dCurSigLevelL ) );
|
||||
ProgressBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) );
|
||||
MultiColorLEDBarInputLevelL->setValue ( (int) ceil ( dCurSigLevelL ) );
|
||||
MultiColorLEDBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) );
|
||||
}
|
||||
|
||||
void CLlconClientDlg::UpdateDisplay()
|
||||
|
|
|
@ -51,9 +51,6 @@
|
|||
#define CON_BUT_CONNECTTEXT "C&onnect"
|
||||
#define CON_BUT_DISCONNECTTEXT "D&isconnect"
|
||||
|
||||
// steps for input level meter
|
||||
#define NUM_STEPS_INP_LEV_METER 100
|
||||
|
||||
// update time for GUI controls
|
||||
#define LEVELMETER_UPDATE_TIME 100 // ms
|
||||
#define STATUSBAR_UPDATE_TIME 1000 // ms
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>492</width>
|
||||
<height>310</height>
|
||||
<width>488</width>
|
||||
<height>336</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
|
@ -28,21 +28,6 @@
|
|||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="PixmapLabelCorrados" >
|
||||
<property name="sizePolicy" >
|
||||
|
@ -67,21 +52,6 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
|
@ -136,49 +106,37 @@
|
|||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="ProgressBarInputLevelL" >
|
||||
<widget class="CMultiColorLEDBar" native="1" name="MultiColorLEDBarInputLevelL" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Expanding" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="ProgressBarInputLevelR" >
|
||||
<widget class="CMultiColorLEDBar" native="1" name="MultiColorLEDBarInputLevelR" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Expanding" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -645,6 +603,12 @@ Fader</string>
|
|||
<extends>QWidget</extends>
|
||||
<header>audiomixerboard.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CMultiColorLEDBar</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>multicolorledbar.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>LineEditServerAddr</tabstop>
|
||||
|
|
|
@ -31,14 +31,75 @@
|
|||
/* Implementation *************************************************************/
|
||||
CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f )
|
||||
: QLabel ( parent, f ),
|
||||
BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ),
|
||||
BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ),
|
||||
BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ),
|
||||
BitmCubeRoundRed ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ),
|
||||
BitmCubeEdgeGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
||||
BitmCubeEdgeGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
||||
BitmCubeEdgeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
||||
BitmCubeEdgeRed ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) )
|
||||
BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
||||
BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreenSmall.png" ) ),
|
||||
BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDYellowSmall.png" ) ),
|
||||
BitmCubeRoundRed ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDRedSmall.png" ) )
|
||||
{
|
||||
// set total number of LEDs
|
||||
iNumLEDs = NUM_STEPS_INP_LEV_METER;
|
||||
|
||||
// create layout and set spacing to zero
|
||||
pMainLayout = new QHBoxLayout ( this );
|
||||
pMainLayout->setSpacing ( 0 );
|
||||
|
||||
// create LEDs
|
||||
vecpLEDs.Init ( iNumLEDs );
|
||||
for ( int i = 0; i < iNumLEDs; i++ )
|
||||
{
|
||||
// create LED label
|
||||
vecpLEDs[i] = new QLabel ( "", parent );
|
||||
|
||||
// add LED to layout
|
||||
pMainLayout->addWidget ( vecpLEDs[i] );
|
||||
|
||||
// set initial bitmap
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundGrey );
|
||||
|
||||
// bitmap defines minimum size of the label
|
||||
vecpLEDs[i]->setMinimumSize (
|
||||
BitmCubeRoundGrey.width(), BitmCubeRoundGrey.height() );
|
||||
}
|
||||
}
|
||||
|
||||
void CMultiColorLEDBar::setValue ( const int value )
|
||||
{
|
||||
|
||||
// TODO speed optimiation: only change bitmaps of LEDs which
|
||||
// actually have to be changed
|
||||
|
||||
// use green LEDs for the range from 0 to the YELLOW_BOUND_INP_LEV_METER,
|
||||
// yellow in the range YELLOW_BOUND_INP_LEV_METER to
|
||||
// RED_BOUND_INP_LEV_METER and red for up to value and grey for the rest
|
||||
for ( int i = 0; i < iNumLEDs; i++ )
|
||||
{
|
||||
if ( i < value )
|
||||
{
|
||||
// we are below current input level, check which color
|
||||
// we should use (green, yellow or red)
|
||||
if ( i < YELLOW_BOUND_INP_LEV_METER )
|
||||
{
|
||||
// green region
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundGreen );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( i < RED_BOUND_INP_LEV_METER )
|
||||
{
|
||||
// yellow region
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundYellow );
|
||||
}
|
||||
else
|
||||
{
|
||||
// red region
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundRed );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are above current input level -> use grey LED
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundGrey );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <qlabel.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qtimer.h>
|
||||
#include <qlayout.h>
|
||||
#include "util.h"
|
||||
#include "global.h"
|
||||
|
||||
|
||||
|
@ -39,15 +41,18 @@ class CMultiColorLEDBar : public QLabel
|
|||
public:
|
||||
CMultiColorLEDBar ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
|
||||
|
||||
void setValue ( const int value );
|
||||
|
||||
protected:
|
||||
QPixmap BitmCubeRoundGrey;
|
||||
QPixmap BitmCubeRoundGreen;
|
||||
QPixmap BitmCubeRoundYellow;
|
||||
QPixmap BitmCubeRoundRed;
|
||||
QPixmap BitmCubeEdgeGrey;
|
||||
QPixmap BitmCubeEdgeGreen;
|
||||
QPixmap BitmCubeEdgeYellow;
|
||||
QPixmap BitmCubeEdgeRed;
|
||||
|
||||
QHBoxLayout* pMainLayout;
|
||||
|
||||
int iNumLEDs;
|
||||
CVector<QLabel*> vecpLEDs;
|
||||
};
|
||||
|
||||
#endif // _MULTCOLORLEDBAR_H__FD6B49B5_87DF_48DD_E1606C2AC__INCLUDED_
|
||||
|
|
Loading…
Reference in a new issue