fader implementation finished
This commit is contained in:
parent
d0bb262193
commit
92b695f7da
8 changed files with 123 additions and 56 deletions
|
@ -36,18 +36,15 @@ CChannelFader::CChannelFader ( QWidget* pNW,
|
||||||
{
|
{
|
||||||
// create new GUI control objects and store pointers to them
|
// create new GUI control objects and store pointers to them
|
||||||
pMainGrid = new QGridLayout ( pNW, 2, 1 );
|
pMainGrid = new QGridLayout ( pNW, 2, 1 );
|
||||||
pFader = new QSlider ( Qt::Vertical, pNW );
|
pFader = new QSlider ( Qt::Vertical, pNW );
|
||||||
pLabel = new QLabel ( "", pNW );
|
pLabel = new QLabel ( "", pNW );
|
||||||
|
|
||||||
// setup slider
|
// setup slider
|
||||||
pFader->setPageStep ( 1 );
|
pFader->setPageStep ( 1 );
|
||||||
pFader->setTickmarks ( QSlider::Both );
|
pFader->setTickmarks ( QSlider::Both );
|
||||||
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 );
|
||||||
|
pFader->setValue ( 0 ); // set init value
|
||||||
// TEST set value and make read only
|
|
||||||
pFader->setValue ( 0 );
|
|
||||||
pFader->setEnabled ( FALSE );
|
|
||||||
|
|
||||||
// set label text
|
// set label text
|
||||||
pLabel->setText ( sName );
|
pLabel->setText ( sName );
|
||||||
|
@ -59,6 +56,21 @@ pFader->setEnabled ( FALSE );
|
||||||
pMainGrid->addWidget( pLabel, 1, 0, Qt::AlignHCenter );
|
pMainGrid->addWidget( pLabel, 1, 0, Qt::AlignHCenter );
|
||||||
|
|
||||||
pParentLayout->insertLayout ( 0, pMainGrid );
|
pParentLayout->insertLayout ( 0, pMainGrid );
|
||||||
|
|
||||||
|
|
||||||
|
// connections -------------------------------------------------------------
|
||||||
|
QObject::connect ( pFader, SIGNAL ( valueChanged ( int ) ),
|
||||||
|
this, SLOT ( OnValueChanged ( int ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CChannelFader::OnValueChanged ( int value )
|
||||||
|
{
|
||||||
|
// convert actual slider range in gain values
|
||||||
|
// reverse linear scale and normalize so that maximum gain is 1
|
||||||
|
const double dCurGain =
|
||||||
|
static_cast<double> ( AUD_MIX_FADER_MAX - value ) / AUD_MIX_FADER_MAX;
|
||||||
|
|
||||||
|
emit valueChanged ( dCurGain );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelFader::SetText ( const std::string sText )
|
void CChannelFader::SetText ( const std::string sText )
|
||||||
|
@ -97,30 +109,27 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent,
|
||||||
vecpChanFader.Init ( MAX_NUM_CHANNELS );
|
vecpChanFader.Init ( MAX_NUM_CHANNELS );
|
||||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
vecpChanFader[i] = new CChannelFader ( this,
|
vecpChanFader[i] = new CChannelFader ( this, pMainLayout, "" );
|
||||||
pMainLayout, "test" );
|
|
||||||
|
|
||||||
vecpChanFader[i]->Hide();
|
vecpChanFader[i]->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TEST
|
// connections -------------------------------------------------------------
|
||||||
//vecpChanFader.Init(0);
|
// CODE TAG: MAX_NUM_CHANNELS_TAG
|
||||||
//vecpChanFader.Add(new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout, "test"));
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
|
QObject::connect(vecpChanFader[0],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh0(double)));
|
||||||
//FrameAudioFadersLayout->addWidget(new QLabel ( "test", FrameAudioFaders ));
|
QObject::connect(vecpChanFader[1],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh1(double)));
|
||||||
/*
|
QObject::connect(vecpChanFader[2],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh2(double)));
|
||||||
for ( int z = 0; z < 100; z++)
|
QObject::connect(vecpChanFader[3],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh3(double)));
|
||||||
{
|
QObject::connect(vecpChanFader[4],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh4(double)));
|
||||||
CLlconClientDlg::CChannelFader* pTest = new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout);
|
QObject::connect(vecpChanFader[5],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh5(double)));
|
||||||
delete pTest;
|
QObject::connect(vecpChanFader[6],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh6(double)));
|
||||||
}
|
QObject::connect(vecpChanFader[7],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh7(double)));
|
||||||
*/
|
QObject::connect(vecpChanFader[8],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh8(double)));
|
||||||
|
QObject::connect(vecpChanFader[9],SIGNAL(valueChanged(double)),this,SLOT(OnValueChangedCh9(double)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAudioMixerBoard::Clear()
|
void CAudioMixerBoard::HideAll()
|
||||||
{
|
{
|
||||||
// make old controls invisible
|
// make old controls invisible
|
||||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
|
@ -131,27 +140,53 @@ void CAudioMixerBoard::Clear()
|
||||||
|
|
||||||
void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelShortInfo>& vecChanInfo )
|
void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelShortInfo>& vecChanInfo )
|
||||||
{
|
{
|
||||||
int i;
|
// search for channels with are already present and preserver their gain
|
||||||
|
// setting, for all other channels, reset gain
|
||||||
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
|
{
|
||||||
|
bool bFaderIsUsed = false;
|
||||||
|
|
||||||
|
for ( int j = 0; j < vecChanInfo.Size(); j++ )
|
||||||
|
{
|
||||||
|
// search if current fader is used
|
||||||
|
if ( vecChanInfo[j].iChanID == i )
|
||||||
|
{
|
||||||
|
// check if fader was already in use -> preserve gain value
|
||||||
|
if ( !vecpChanFader[i]->IsVisible() )
|
||||||
|
{
|
||||||
|
vecpChanFader[i]->ResetGain();
|
||||||
|
|
||||||
// TODO
|
// show fader
|
||||||
|
vecpChanFader[i]->Show();
|
||||||
|
}
|
||||||
|
|
||||||
// make old controls invisible
|
// update text
|
||||||
Clear();
|
vecpChanFader[i]->SetText ( GenFaderText ( vecChanInfo[j] ) );
|
||||||
|
|
||||||
|
bFaderIsUsed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TEST add current faders
|
// if current fader is not used, hide it
|
||||||
for ( i = 0; i < vecChanInfo.Size(); i++ )
|
if ( !bFaderIsUsed )
|
||||||
|
{
|
||||||
|
vecpChanFader[i]->Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CAudioMixerBoard::GenFaderText ( CChannelShortInfo& ChanInfo )
|
||||||
{
|
{
|
||||||
QHostAddress addrTest ( vecChanInfo[i].veciIpAddr );
|
// if text is empty, show IP address instead
|
||||||
|
if ( ChanInfo.strName.empty() )
|
||||||
vecpChanFader[i]->SetText ( addrTest.toString().latin1() );
|
{
|
||||||
vecpChanFader[i]->Show();
|
// convert IP address to text and show it
|
||||||
|
const QHostAddress addrTest ( ChanInfo.iIpAddr );
|
||||||
|
return addrTest.toString().latin1();
|
||||||
|
}
|
||||||
// vecpChanFader[i] = new CLlconClientDlg::CChannelFader ( FrameAudioFaders,
|
else
|
||||||
// FrameAudioFadersLayout, addrTest.toString() );
|
{
|
||||||
}
|
// show name of channel
|
||||||
|
return ChanInfo.strName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,10 @@
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
class CChannelFader
|
class CChannelFader : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CChannelFader ( QWidget* pNW, QHBoxLayout* pNPtLy, QString sName );
|
CChannelFader ( QWidget* pNW, QHBoxLayout* pNPtLy, QString sName );
|
||||||
~CChannelFader()
|
~CChannelFader()
|
||||||
|
@ -59,6 +61,10 @@ public:
|
||||||
void SetText ( const std::string sText );
|
void SetText ( const std::string sText );
|
||||||
void Show() { pLabel->show(); pFader->show(); }
|
void Show() { pLabel->show(); pFader->show(); }
|
||||||
void Hide() { pLabel->hide(); pFader->hide(); }
|
void Hide() { pLabel->hide(); pFader->hide(); }
|
||||||
|
bool IsVisible() { return pLabel->isVisible(); }
|
||||||
|
|
||||||
|
// init gain value -> maximum value as definition according to server
|
||||||
|
void ResetGain() { pFader->setValue ( 0 ); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QGridLayout* pMainGrid;
|
QGridLayout* pMainGrid;
|
||||||
|
@ -66,6 +72,12 @@ protected:
|
||||||
QLabel* pLabel;
|
QLabel* pLabel;
|
||||||
|
|
||||||
QHBoxLayout* pParentLayout;
|
QHBoxLayout* pParentLayout;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void OnValueChanged ( int value );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void valueChanged ( double value );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,13 +88,29 @@ class CAudioMixerBoard : public QFrame
|
||||||
public:
|
public:
|
||||||
CAudioMixerBoard ( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
|
CAudioMixerBoard ( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
|
||||||
|
|
||||||
void Clear();
|
void HideAll();
|
||||||
void ApplyNewConClientList ( CVector<CChannelShortInfo>& vecChanInfo );
|
void ApplyNewConClientList ( CVector<CChannelShortInfo>& vecChanInfo );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::string GenFaderText ( CChannelShortInfo& ChanInfo );
|
||||||
|
|
||||||
CVector<CChannelFader*> vecpChanFader;
|
CVector<CChannelFader*> vecpChanFader;
|
||||||
QHBoxLayout* pMainLayout;
|
QHBoxLayout* pMainLayout;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// CODE TAG: MAX_NUM_CHANNELS_TAG
|
||||||
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
|
void OnValueChangedCh0 ( double dValue ) { emit ChangeChanGain ( 0, dValue ); }
|
||||||
|
void OnValueChangedCh1 ( double dValue ) { emit ChangeChanGain ( 1, dValue ); }
|
||||||
|
void OnValueChangedCh2 ( double dValue ) { emit ChangeChanGain ( 2, dValue ); }
|
||||||
|
void OnValueChangedCh3 ( double dValue ) { emit ChangeChanGain ( 3, dValue ); }
|
||||||
|
void OnValueChangedCh4 ( double dValue ) { emit ChangeChanGain ( 4, dValue ); }
|
||||||
|
void OnValueChangedCh5 ( double dValue ) { emit ChangeChanGain ( 5, dValue ); }
|
||||||
|
void OnValueChangedCh6 ( double dValue ) { emit ChangeChanGain ( 6, dValue ); }
|
||||||
|
void OnValueChangedCh7 ( double dValue ) { emit ChangeChanGain ( 7, dValue ); }
|
||||||
|
void OnValueChangedCh8 ( double dValue ) { emit ChangeChanGain ( 8, dValue ); }
|
||||||
|
void OnValueChangedCh9 ( double dValue ) { emit ChangeChanGain ( 9, dValue ); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ChangeChanGain ( int iId, double dGain );
|
void ChangeChanGain ( int iId, double dGain );
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,7 @@ CChannelSet::CChannelSet()
|
||||||
vecChannels[i].SetEnable ( true );
|
vecChannels[i].SetEnable ( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CODE TAG: MAX_NUM_CHANNELS_TAG
|
||||||
// make sure we have MAX_NUM_CHANNELS connections!!!
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
// send message
|
// send message
|
||||||
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh0(CVector<uint8_t>)));
|
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh0(CVector<uint8_t>)));
|
||||||
|
|
|
@ -238,6 +238,7 @@ protected:
|
||||||
QMutex Mutex;
|
QMutex Mutex;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
// CODE TAG: MAX_NUM_CHANNELS_TAG
|
||||||
// make sure we have MAX_NUM_CHANNELS connections!!!
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
// send message
|
// send message
|
||||||
void OnSendProtMessCh0(CVector<uint8_t> mess) {emit MessReadyForSending(0,mess);}
|
void OnSendProtMessCh0(CVector<uint8_t> mess) {emit MessReadyForSending(0,mess);}
|
||||||
|
|
|
@ -83,7 +83,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// maximum number of internet connections (channels)
|
// maximum number of internet connections (channels)
|
||||||
// if you want to change this paramter, change the connections in channel class, too!
|
// if you want to change this paramter, there has to be done code modifications
|
||||||
|
// on other places, too! The code tag "MAX_NUM_CHANNELS_TAG" shows these places
|
||||||
|
// (just search for the tag in the entire code)
|
||||||
#define MAX_NUM_CHANNELS 10 /* max number channels for server */
|
#define MAX_NUM_CHANNELS 10 /* max number channels for server */
|
||||||
|
|
||||||
/* sample rate offset estimation algorithm */
|
/* sample rate offset estimation algorithm */
|
||||||
|
|
|
@ -213,7 +213,7 @@ void CLlconClientDlg::OnConnectDisconBut()
|
||||||
OnTimerStatus();
|
OnTimerStatus();
|
||||||
|
|
||||||
// clear mixer board (remove all faders)
|
// clear mixer board (remove all faders)
|
||||||
MainMixerBoard->Clear();
|
MainMixerBoard->HideAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -439,7 +439,7 @@ void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain )
|
||||||
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iChanID ), 1 );
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iChanID ), 1 );
|
||||||
|
|
||||||
// actual gain, we convert from double with range 0..1 to integer
|
// actual gain, we convert from double with range 0..1 to integer
|
||||||
const int iCurGain = (int) ( dGain * ( 1 << 16 ) );
|
const int iCurGain = static_cast<int> ( dGain * ( 1 << 15 ) );
|
||||||
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iCurGain ), 2 );
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iCurGain ), 2 );
|
||||||
|
|
||||||
CreateAndSendMessage ( PROTMESSID_CHANNEL_GAIN, vecData );
|
CreateAndSendMessage ( PROTMESSID_CHANNEL_GAIN, vecData );
|
||||||
|
@ -455,7 +455,7 @@ void CProtocol::EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>&
|
||||||
const int iData =
|
const int iData =
|
||||||
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
|
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
|
||||||
|
|
||||||
const double dNewGain = (double) iData / ( 1 << 16 );
|
const double dNewGain = static_cast<double> ( iData ) / ( 1 << 15 );
|
||||||
|
|
||||||
// invoke message action
|
// invoke message action
|
||||||
emit ChangeChanGain ( iCurID, dNewGain );
|
emit ChangeChanGain ( iCurID, dNewGain );
|
||||||
|
@ -472,7 +472,7 @@ void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecCh
|
||||||
for ( int i = 0; i < iNumClients; i++ )
|
for ( int i = 0; i < iNumClients; i++ )
|
||||||
{
|
{
|
||||||
// current string size
|
// current string size
|
||||||
const int iCurStrLen = vecChanInfo[i].vecstrName.size();
|
const int iCurStrLen = vecChanInfo[i].strName.size();
|
||||||
|
|
||||||
// size of current list entry
|
// size of current list entry
|
||||||
const int iCurListEntrLen =
|
const int iCurListEntrLen =
|
||||||
|
@ -483,11 +483,11 @@ void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecCh
|
||||||
|
|
||||||
// channel ID
|
// channel ID
|
||||||
PutValOnStream ( vecData, iPos,
|
PutValOnStream ( vecData, iPos,
|
||||||
static_cast<uint32_t> ( vecChanInfo[i].veciChanID ), 1 );
|
static_cast<uint32_t> ( vecChanInfo[i].iChanID ), 1 );
|
||||||
|
|
||||||
// IP address (4 bytes)
|
// IP address (4 bytes)
|
||||||
PutValOnStream ( vecData, iPos,
|
PutValOnStream ( vecData, iPos,
|
||||||
static_cast<uint32_t> ( vecChanInfo[i].veciIpAddr ), 4 );
|
static_cast<uint32_t> ( vecChanInfo[i].iIpAddr ), 4 );
|
||||||
|
|
||||||
// number of bytes for name string (2 bytes)
|
// number of bytes for name string (2 bytes)
|
||||||
PutValOnStream ( vecData, iPos,
|
PutValOnStream ( vecData, iPos,
|
||||||
|
@ -498,7 +498,7 @@ void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecCh
|
||||||
{
|
{
|
||||||
// byte-by-byte copying of the string data
|
// byte-by-byte copying of the string data
|
||||||
PutValOnStream ( vecData, iPos,
|
PutValOnStream ( vecData, iPos,
|
||||||
static_cast<uint32_t> ( vecChanInfo[i].vecstrName[j] ), 1 );
|
static_cast<uint32_t> ( vecChanInfo[i].strName[j] ), 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/util.h
10
src/util.h
|
@ -363,13 +363,13 @@ public:
|
||||||
class CChannelShortInfo
|
class CChannelShortInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CChannelShortInfo() : veciChanID ( 0 ), veciIpAddr ( 0 ), vecstrName ( "" ) {}
|
CChannelShortInfo() : iChanID ( 0 ), iIpAddr ( 0 ), strName ( "" ) {}
|
||||||
CChannelShortInfo ( const int iNID, const uint32_t nIP, const std::string nN ) :
|
CChannelShortInfo ( const int iNID, const uint32_t nIP, const std::string nN ) :
|
||||||
veciChanID ( iNID ), veciIpAddr ( nIP ), vecstrName ( nN ) {}
|
iChanID ( iNID ), iIpAddr ( nIP ), strName ( nN ) {}
|
||||||
|
|
||||||
int veciChanID;
|
int iChanID;
|
||||||
uint32_t veciIpAddr;
|
uint32_t iIpAddr;
|
||||||
std::string vecstrName;
|
std::string strName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue