fix code style issues introduced by contributed source code

This commit is contained in:
Volker Fischer 2020-05-18 20:46:46 +02:00
parent 78413826a5
commit 7dbd2c89d1
12 changed files with 94 additions and 100 deletions

View file

@ -39,8 +39,7 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pLevelsBox = new QWidget ( pFrame ); pLevelsBox = new QWidget ( pFrame );
plbrChannelLevel = new CMultiColorLEDBar ( pLevelsBox ); plbrChannelLevel = new CMultiColorLEDBar ( pLevelsBox );
pFader = new QSlider ( Qt::Vertical, pLevelsBox ); pFader = new QSlider ( Qt::Vertical, pLevelsBox );
pPan = new QSlider ( Qt::Horizontal, pLevelsBox );
pPan = new QSlider (Qt::Horizontal, pLevelsBox);
pMuteSoloBox = new QWidget ( pFrame ); pMuteSoloBox = new QWidget ( pFrame );
pcbMute = new QCheckBox ( tr ( "Mute" ), pMuteSoloBox ); pcbMute = new QCheckBox ( tr ( "Mute" ), pMuteSoloBox );
@ -67,9 +66,8 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 ); pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 );
// setup panning slider // setup panning slider
pPan->setRange( 0, AUD_MIX_PAN_MAX); pPan->setRange ( 0, AUD_MIX_PAN_MAX );
pPan->setValue(AUD_MIX_PAN_MAX/2); pPan->setValue ( AUD_MIX_PAN_MAX / 2 );
// setup fader tag label (black bold text which is centered) // setup fader tag label (black bold text which is centered)
plblLabel->setTextFormat ( Qt::PlainText ); plblLabel->setTextFormat ( Qt::PlainText );
@ -103,7 +101,7 @@ CChannelFader::CChannelFader ( QWidget* pNW,
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 ( pPan, 0, Qt::AlignCenter ); pMainGrid->addWidget ( pPan, 0, Qt::AlignCenter );
pMainGrid->addWidget ( pLevelsBox, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pLevelsBox, 0, Qt::AlignHCenter );
pMainGrid->addWidget ( pMuteSoloBox, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pMuteSoloBox, 0, Qt::AlignHCenter );
pMainGrid->addWidget ( pLabelInstBox ); pMainGrid->addWidget ( pLabelInstBox );
@ -127,8 +125,9 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pFader->setAccessibleName ( tr ( "Local mix level setting of the current audio " pFader->setAccessibleName ( tr ( "Local mix level setting of the current audio "
"channel at the server" ) ); "channel at the server" ) );
pPan->setWhatsThis ( "<b>" + tr ( "Panning") + ":</b>" + tr ( "Sets the panning position from Left to Right of the channel. " pPan->setWhatsThis ( "<b>" + tr ( "Panning" ) + ":</b>" + tr (
" Works only in stero or preferably mono in/stereo out mode." ) ); "Sets the panning position from Left to Right of the channel. "
"Works only in stero or preferably mono in/stereo out mode." ) );
pPan->setAccessibleName ( tr ( "Local panning position of the current audio channel at the server" ) ); pPan->setAccessibleName ( tr ( "Local panning position of the current audio channel at the server" ) );
pcbMute->setWhatsThis ( "<b>" + tr ( "Mute" ) + ":</b> " + tr ( pcbMute->setWhatsThis ( "<b>" + tr ( "Mute" ) + ":</b> " + tr (
@ -158,7 +157,7 @@ CChannelFader::CChannelFader ( QWidget* pNW,
this, SLOT ( OnLevelValueChanged ( int ) ) ); this, SLOT ( OnLevelValueChanged ( int ) ) );
QObject::connect ( pPan, SIGNAL ( valueChanged ( int ) ), QObject::connect ( pPan, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnPanValueChanged ( int ) ) ); this, SLOT ( OnPanValueChanged ( int ) ) );
QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ), QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnMuteStateChanged ( int ) ) ); this, SLOT ( OnMuteStateChanged ( int ) ) );
@ -260,7 +259,7 @@ void CChannelFader::Reset()
{ {
// init gain and pan value -> maximum value as definition according to server // init gain and pan value -> maximum value as definition according to server
pFader->setValue ( AUD_MIX_FADER_MAX ); pFader->setValue ( AUD_MIX_FADER_MAX );
pPan->setValue ( AUD_MIX_PAN_MAX/2 ); pPan->setValue ( AUD_MIX_PAN_MAX / 2 );
// reset mute/solo check boxes and level meter // reset mute/solo check boxes and level meter
pcbMute->setChecked ( false ); pcbMute->setChecked ( false );
@ -298,7 +297,7 @@ void CChannelFader::SetFaderLevel ( const int iLevel )
} }
} }
void CChannelFader::SetPanValue(const int iPan) void CChannelFader::SetPanValue ( const int iPan )
{ {
// first make a range check // first make a range check
if ( ( iPan >= 0 ) && ( iPan <= AUD_MIX_PAN_MAX ) ) if ( ( iPan >= 0 ) && ( iPan <= AUD_MIX_PAN_MAX ) )
@ -306,7 +305,7 @@ void CChannelFader::SetPanValue(const int iPan)
// we set the new fader level in the GUI (slider control) and also tell the // we set the new fader level in the GUI (slider control) and also tell the
// server about the change // server about the change
pPan->setValue ( iPan ); pPan->setValue ( iPan );
SendPanValueToServer( iPan ); SendPanValueToServer ( iPan );
} }
} }
@ -337,8 +336,7 @@ void CChannelFader::SendFaderLevelToServer ( const int iLevel )
void CChannelFader::SendPanValueToServer ( const int iPan ) void CChannelFader::SendPanValueToServer ( const int iPan )
{ {
double dPan = static_cast<double> ( iPan ) / AUD_MIX_PAN_MAX; emit panValueChanged ( static_cast<double> ( iPan ) / AUD_MIX_PAN_MAX );
emit panValueChanged ( dPan );
} }
void CChannelFader::OnMuteStateChanged ( int value ) void CChannelFader::OnMuteStateChanged ( int value )
@ -559,7 +557,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) :
QScrollArea ( parent ), QScrollArea ( parent ),
vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ),
vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ),
vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX/2), vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ),
vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ),
vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ), vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ),
iNewClientFaderLevel ( 100 ), iNewClientFaderLevel ( 100 ),
@ -752,7 +750,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
bStoredFaderIsMute ) ) bStoredFaderIsMute ) )
{ {
vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel ); vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel );
vecpChanFader[i]->SetPanValue ( iStoredPanValue ); vecpChanFader[i]->SetPanValue ( iStoredPanValue );
vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo ); vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo );
vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute ); vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute );
} }
@ -834,12 +832,11 @@ void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx,
} }
void CAudioMixerBoard::UpdatePanValue ( const int iChannelIdx, void CAudioMixerBoard::UpdatePanValue ( const int iChannelIdx,
const double dValue ) const double dValue )
{ {
emit ChangeChanPan ( iChannelIdx, dValue ); emit ChangeChanPan ( iChannelIdx, dValue );
} }
void CAudioMixerBoard::StoreFaderSettings ( CChannelFader* pChanFader ) void CAudioMixerBoard::StoreFaderSettings ( CChannelFader* pChanFader )
{ {
// if the fader was visible and the name is not empty, we store the old gain // if the fader was visible and the name is not empty, we store the old gain
@ -904,7 +901,7 @@ bool CAudioMixerBoard::GetStoredFaderSettings ( const CChannelInfo& ChanInfo,
{ {
// copy stored settings values // copy stored settings values
iStoredFaderLevel = vecStoredFaderLevels[iIdx]; iStoredFaderLevel = vecStoredFaderLevels[iIdx];
iStoredPanValue = vecStoredPanValues[iIdx]; iStoredPanValue = vecStoredPanValues[iIdx];
bStoredFaderIsSolo = vecStoredFaderIsSolo[iIdx] != 0; bStoredFaderIsSolo = vecStoredFaderIsSolo[iIdx] != 0;
bStoredFaderIsMute = vecStoredFaderIsMute[iIdx] != 0; bStoredFaderIsMute = vecStoredFaderIsMute[iIdx] != 0;

View file

@ -65,7 +65,7 @@ public:
void SetFaderIsSolo ( const bool bIsSolo ); void SetFaderIsSolo ( const bool bIsSolo );
void SetFaderIsMute ( const bool bIsMute ); void SetFaderIsMute ( const bool bIsMute );
int GetFaderLevel() { return pFader->value(); } int GetFaderLevel() { return pFader->value(); }
int GetPanValue() {return pPan->value(); } int GetPanValue() { return pPan->value(); }
void Reset(); void Reset();
void SetChannelLevel ( const uint16_t iLevel ); void SetChannelLevel ( const uint16_t iLevel );
@ -82,7 +82,7 @@ protected:
QWidget* pMuteSoloBox; QWidget* pMuteSoloBox;
CMultiColorLEDBar* plbrChannelLevel; CMultiColorLEDBar* plbrChannelLevel;
QSlider* pFader; QSlider* pFader;
QSlider* pPan; QSlider* pPan;
QCheckBox* pcbMute; QCheckBox* pcbMute;
QCheckBox* pcbSolo; QCheckBox* pcbSolo;
@ -98,12 +98,12 @@ protected:
public slots: public slots:
void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); } void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); }
void OnPanValueChanged ( int value ) {SendPanValueToServer ( value ); } void OnPanValueChanged ( int value ) { SendPanValueToServer ( value ); }
void OnMuteStateChanged ( int value ); void OnMuteStateChanged ( int value );
signals: signals:
void gainValueChanged ( double value ); void gainValueChanged ( double value );
void panValueChanged (double value ); void panValueChanged ( double value );
void soloStateChanged ( int value ); void soloStateChanged ( int value );
}; };
@ -118,7 +118,7 @@ protected:
virtual void UpdateGainValue ( const int iChannelIdx, virtual void UpdateGainValue ( const int iChannelIdx,
const double dValue ) = 0; const double dValue ) = 0;
virtual void UpdatePanValue ( const int iChannelIdx, virtual void UpdatePanValue ( const int iChannelIdx,
const double dValue ) = 0; const double dValue ) = 0;
}; };
template<> template<>
@ -154,7 +154,7 @@ public:
int iNewClientFaderLevel; int iNewClientFaderLevel;
protected: protected:
bool GetStoredFaderSettings (const CChannelInfo& ChanInfo, bool GetStoredFaderSettings ( const CChannelInfo& ChanInfo,
int& iStoredFaderLevel, int& iStoredFaderLevel,
int& iStoredPanValue, int& iStoredPanValue,
bool& bStoredFaderIsSolo, bool& bStoredFaderIsSolo,
@ -176,7 +176,7 @@ protected:
virtual void UpdateGainValue ( const int iChannelIdx, virtual void UpdateGainValue ( const int iChannelIdx,
const double dValue ); const double dValue );
virtual void UpdatePanValue ( const int iChannelIdx, virtual void UpdatePanValue ( const int iChannelIdx,
const double dValue ); const double dValue );
template<unsigned int slotId> template<unsigned int slotId>
inline void connectFaderSignalsToMixerBoardSlots(); inline void connectFaderSignalsToMixerBoardSlots();

View file

@ -28,7 +28,7 @@
// CChannel implementation ***************************************************** // CChannel implementation *****************************************************
CChannel::CChannel ( const bool bNIsServer ) : CChannel::CChannel ( const bool bNIsServer ) :
vecdGains ( MAX_NUM_CHANNELS, 1.0 ), vecdGains ( MAX_NUM_CHANNELS, 1.0 ),
vecdPannings ( MAX_NUM_CHANNELS, 0.5), vecdPannings ( MAX_NUM_CHANNELS, 0.5 ),
bDoAutoSockBufSize ( true ), bDoAutoSockBufSize ( true ),
iFadeInCnt ( 0 ), iFadeInCnt ( 0 ),
iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ), iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ),
@ -88,7 +88,7 @@ qRegisterMetaType<CHostAddress> ( "CHostAddress" );
this, SLOT ( OnChangeChanGain ( int, double ) ) ); this, SLOT ( OnChangeChanGain ( int, double ) ) );
QObject::connect( &Protocol, SIGNAL ( ChangeChanPan ( int, double ) ), QObject::connect( &Protocol, SIGNAL ( ChangeChanPan ( int, double ) ),
this, SLOT ( OnChangeChanPan ( int, double ) ) ); this, SLOT ( OnChangeChanPan ( int, double ) ) );
QObject::connect( &Protocol, SIGNAL ( ChangeChanInfo ( CChannelCoreInfo ) ), QObject::connect( &Protocol, SIGNAL ( ChangeChanInfo ( CChannelCoreInfo ) ),
this, SLOT ( OnChangeChanInfo ( CChannelCoreInfo ) ) ); this, SLOT ( OnChangeChanInfo ( CChannelCoreInfo ) ) );
@ -273,7 +273,8 @@ double CChannel::GetGain ( const int iChanID )
} }
} }
void CChannel::SetPan(const int iChanID, const double dNewPan) void CChannel::SetPan ( const int iChanID,
const double dNewPan )
{ {
QMutexLocker locker ( &Mutex ); QMutexLocker locker ( &Mutex );
@ -284,7 +285,7 @@ void CChannel::SetPan(const int iChanID, const double dNewPan)
} }
} }
double CChannel::GetPan(const int iChanID) double CChannel::GetPan ( const int iChanID )
{ {
QMutexLocker locker ( &Mutex ); QMutexLocker locker ( &Mutex );
@ -368,7 +369,7 @@ void CChannel::OnChangeChanGain ( int iChanID,
void CChannel::OnChangeChanPan ( int iChanID, void CChannel::OnChangeChanPan ( int iChanID,
double dNewPan ) double dNewPan )
{ {
SetPan( iChanID, dNewPan ); SetPan ( iChanID, dNewPan );
} }
void CChannel::OnChangeChanInfo ( CChannelCoreInfo ChanInfo ) void CChannel::OnChangeChanInfo ( CChannelCoreInfo ChanInfo )

View file

@ -118,7 +118,7 @@ public:
{ Protocol.CreateChanGainMes ( iId, dGain ); } { Protocol.CreateChanGainMes ( iId, dGain ); }
void SetRemoteChanPan ( const int iId, const double dPan ) void SetRemoteChanPan ( const int iId, const double dPan )
{ Protocol.CreateChanPanMes ( iId, dPan ); } { Protocol.CreateChanPanMes ( iId, dPan ); }
bool SetSockBufNumFrames ( const int iNewNumFrames, bool SetSockBufNumFrames ( const int iNewNumFrames,
const bool bPreserve = false ); const bool bPreserve = false );
@ -197,7 +197,6 @@ protected:
// mixer and effect settings // mixer and effect settings
CVector<double> vecdGains; CVector<double> vecdGains;
CVector<double> vecdPannings; CVector<double> vecdPannings;
// network jitter-buffer // network jitter-buffer

View file

@ -35,7 +35,7 @@ CClient::CClient ( const quint16 iPortNumber,
ChannelInfo (), ChannelInfo (),
vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ),
vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ),
vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX/2 ), vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ),
vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ),
vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ), vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ),
iNewClientFaderLevel ( 100 ), iNewClientFaderLevel ( 100 ),

View file

@ -246,7 +246,7 @@ public:
{ Channel.SetRemoteChanGain ( iId, dGain ); } { Channel.SetRemoteChanGain ( iId, dGain ); }
void SetRemoteChanPan ( const int iId, const double dPan ) void SetRemoteChanPan ( const int iId, const double dPan )
{ Channel.SetRemoteChanPan ( iId, dPan ); } { Channel.SetRemoteChanPan ( iId, dPan ); }
void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); } void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); }

View file

@ -523,7 +523,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
this, SLOT ( OnChangeChanGain ( int, double ) ) ); this, SLOT ( OnChangeChanGain ( int, double ) ) );
QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanPan ( int, double ) ), QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanPan ( int, double ) ),
this, SLOT ( OnChangeChanPan ( int, double ) ) ); this, SLOT ( OnChangeChanPan ( int, double ) ) );
QObject::connect ( MainMixerBoard, SIGNAL ( NumClientsChanged ( int ) ), QObject::connect ( MainMixerBoard, SIGNAL ( NumClientsChanged ( int ) ),
this, SLOT ( OnNumClientsChanged ( int ) ) ); this, SLOT ( OnNumClientsChanged ( int ) ) );

View file

@ -167,7 +167,7 @@ public slots:
{ pClient->SetRemoteChanGain ( iId, dGain ); } { pClient->SetRemoteChanGain ( iId, dGain ); }
void OnChangeChanPan ( int iId, double dPan ) void OnChangeChanPan ( int iId, double dPan )
{ pClient->SetRemoteChanPan ( iId, dPan ); } { pClient->SetRemoteChanPan ( iId, dPan ); }
void OnNewLocalInputText ( QString strChatText ) void OnNewLocalInputText ( QString strChatText )
{ pClient->CreateChatTextMes ( strChatText ); } { pClient->CreateChatTextMes ( strChatText ); }

View file

@ -147,14 +147,10 @@ LED bar: lbr
// default network buffer size // default network buffer size
#define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks #define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks
// audio mixer fader maximum value // audio mixer fader and panning maximum value
#define AUD_MIX_FADER_MAX 100 #define AUD_MIX_FADER_MAX 100
// audio mixer panning maximum value
#define AUD_MIX_PAN_MAX 100 #define AUD_MIX_PAN_MAX 100
// maximum number of recognized sound cards installed in the system, // maximum number of recognized sound cards installed in the system,
// definition for "no device" // definition for "no device"
#define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS) #define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS)

View file

@ -805,7 +805,32 @@ void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain )
CreateAndSendMessage ( PROTMESSID_CHANNEL_GAIN, vecData ); CreateAndSendMessage ( PROTMESSID_CHANNEL_GAIN, vecData );
} }
void CProtocol::CreateChanPanMes(const int iChanID, const double dPan) bool CProtocol::EvaluateChanGainMes ( const CVector<uint8_t>& vecData )
{
int iPos = 0; // init position pointer
// check size
if ( vecData.Size() != 3 )
{
return true; // return error code
}
// channel ID
const int iCurID = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
// gain (read integer value)
const int iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// we convert the gain from integer to double with range 0..1
const double dNewGain = static_cast<double> ( iData ) / ( 1 << 15 );
// invoke message action
emit ChangeChanGain ( iCurID, dNewGain );
return false; // no error
}
void CProtocol::CreateChanPanMes ( const int iChanID, const double dPan )
{ {
CVector<uint8_t> vecData ( 3 ); // 3 bytes of data CVector<uint8_t> vecData ( 3 ); // 3 bytes of data
int iPos = 0; // init position pointer int iPos = 0; // init position pointer
@ -822,7 +847,7 @@ void CProtocol::CreateChanPanMes(const int iChanID, const double dPan)
CreateAndSendMessage ( PROTMESSID_CHANNEL_PAN, vecData ); CreateAndSendMessage ( PROTMESSID_CHANNEL_PAN, vecData );
} }
bool CProtocol::EvaluateChanGainMes ( const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateChanPanMes ( const CVector<uint8_t> &vecData )
{ {
int iPos = 0; // init position pointer int iPos = 0; // init position pointer
@ -833,39 +858,10 @@ bool CProtocol::EvaluateChanGainMes ( const CVector<uint8_t>& vecData )
} }
// channel ID // channel ID
const int iCurID = const int iCurID = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
// gain (read integer value)
const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// we convert the gain from integer to double with range 0..1
const double dNewGain = static_cast<double> ( iData ) / ( 1 << 15 );
// invoke message action
emit ChangeChanGain ( iCurID, dNewGain );
return false; // no error
}
bool CProtocol::EvaluateChanPanMes(const CVector<uint8_t> &vecData)
{
int iPos = 0; // init position pointer
// check size
if ( vecData.Size() != 3 )
{
return true; // return error code
}
// channel ID
const int iCurID =
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
// pan (read integer value) // pan (read integer value)
const int iData = const int iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// we convert the gain from integer to double with range 0..1 // we convert the gain from integer to double with range 0..1
const double dNewPan = static_cast<double> ( iData ) / ( 1 << 15 ); const double dNewPan = static_cast<double> ( iData ) / ( 1 << 15 );

View file

@ -282,7 +282,7 @@ signals:
void ReqJittBufSize(); void ReqJittBufSize();
void ChangeNetwBlSiFact ( int iNewNetwBlSiFact ); void ChangeNetwBlSiFact ( int iNewNetwBlSiFact );
void ChangeChanGain ( int iChanID, double dNewGain ); void ChangeChanGain ( int iChanID, double dNewGain );
void ChangeChanPan ( int iChanID, double dNewPan ); void ChangeChanPan ( int iChanID, double dNewPan );
void ConClientListMesReceived ( CVector<CChannelInfo> vecChanInfo ); void ConClientListMesReceived ( CVector<CChannelInfo> vecChanInfo );
void ServerFullMesReceived(); void ServerFullMesReceived();
void ReqConnClientsList(); void ReqConnClientsList();

View file

@ -340,7 +340,7 @@ CServer::CServer ( const int iNewMaxNumChan,
// allocate worst case memory for the temporary vectors // allocate worst case memory for the temporary vectors
vecChanIDsCurConChan.Init ( iMaxNumChannels ); vecChanIDsCurConChan.Init ( iMaxNumChannels );
vecvecdGains.Init ( iMaxNumChannels ); vecvecdGains.Init ( iMaxNumChannels );
vecvecdPannings.Init ( iMaxNumChannels ); vecvecdPannings.Init ( iMaxNumChannels );
vecvecsData.Init ( iMaxNumChannels ); vecvecsData.Init ( iMaxNumChannels );
vecNumAudioChannels.Init ( iMaxNumChannels ); vecNumAudioChannels.Init ( iMaxNumChannels );
vecNumFrameSizeConvBlocks.Init ( iMaxNumChannels ); vecNumFrameSizeConvBlocks.Init ( iMaxNumChannels );
@ -351,7 +351,7 @@ CServer::CServer ( const int iNewMaxNumChan,
{ {
// init vectors storing information of all channels // init vectors storing information of all channels
vecvecdGains[i].Init ( iMaxNumChannels ); vecvecdGains[i].Init ( iMaxNumChannels );
vecvecdPannings[i].Init ( iMaxNumChannels ); vecvecdPannings[i].Init ( iMaxNumChannels );
// we always use stereo audio buffers (see "vecsSendData") // we always use stereo audio buffers (see "vecsSendData")
vecvecsData[i].Init ( 2 /* stereo */ * DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES /* worst case buffer size */ ); vecvecsData[i].Init ( 2 /* stereo */ * DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES /* worst case buffer size */ );
@ -843,11 +843,12 @@ JitterMeas.Measure();
// "vecChanIDsCurConChan" to query the IDs of the currently // "vecChanIDsCurConChan" to query the IDs of the currently
// connected channels // connected channels
vecvecdGains[i][j] = vecChannels[iCurChanID].GetGain ( vecChanIDsCurConChan[j] ); vecvecdGains[i][j] = vecChannels[iCurChanID].GetGain ( vecChanIDsCurConChan[j] );
// consider audio fade-in // consider audio fade-in
vecvecdGains[i][j] *= vecChannels[vecChanIDsCurConChan[j]].GetFadeInGain(); vecvecdGains[i][j] *= vecChannels[vecChanIDsCurConChan[j]].GetFadeInGain();
//panning // panning
vecvecdPannings[i][j] = vecChannels[iCurChanID].GetPan( vecChanIDsCurConChan[j] ); //((double)rand() / (double)(RAND_MAX)); //vecChannels[iCurChanID].GetGain ( vecChanIDsCurConChan[j] ); //TODO: GetPanning vecvecdPannings[i][j] = vecChannels[iCurChanID].GetPan ( vecChanIDsCurConChan[j] );
} }
// If the server frame size is smaller than the received OPUS frame size, we need a conversion // If the server frame size is smaller than the received OPUS frame size, we need a conversion
@ -1076,13 +1077,13 @@ opus_custom_encoder_ctl ( CurOpusEncoder,
} }
/// @brief Mix all audio data from all clients together. /// @brief Mix all audio data from all clients together.
void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData, void CServer::ProcessData ( const CVector<CVector<int16_t> >& vecvecsData,
const CVector<double>& vecdGains, const CVector<double>& vecdGains,
const CVector<double>& vecdPannings, const CVector<double>& vecdPannings,
const CVector<int>& vecNumAudioChannels, const CVector<int>& vecNumAudioChannels,
CVector<int16_t>& vecsOutData, CVector<int16_t>& vecsOutData,
const int iCurNumAudChan, const int iCurNumAudChan,
const int iNumClients ) const int iNumClients )
{ {
int i, j, k; int i, j, k;
@ -1154,10 +1155,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
// get a reference to the audio data and gain of the current client // get a reference to the audio data and gain of the current client
const CVector<int16_t>& vecsData = vecvecsData[j]; const CVector<int16_t>& vecsData = vecvecsData[j];
const double dGain = vecdGains[j]; const double dGain = vecdGains[j];
const double dPan = vecdPannings[j];
const double dPanCoefL = sqrt(1-dPan); // faster: (1-dPan) // calculate pan coefficient, see http://write.flossmanuals.net/csound/b-panning-and-spatialization/ for better formula, if needed
const double dPanCoefR = sqrt(dPan); // (dPan) const double dPan = vecdPannings[j];
// see http://write.flossmanuals.net/csound/b-panning-and-spatialization/ for better formula, if needed const double dPanCoefL = sqrt ( 1 - dPan ); // faster: ( 1 - dPan )
const double dPanCoefR = sqrt ( dPan ); // ( dPan )
// if channel gain is 1, avoid multiplication for speed optimization // if channel gain is 1, avoid multiplication for speed optimization
if ( dGain == static_cast<double> ( 1.0 ) ) if ( dGain == static_cast<double> ( 1.0 ) )
@ -1169,11 +1171,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
{ {
// left channel // left channel
vecsOutData[k] = Double2Short ( vecsOutData[k] = Double2Short (
static_cast<double> ( vecsOutData[k] ) + vecsData[i] * dPanCoefL); static_cast<double> ( vecsOutData[k] ) + vecsData[i] * dPanCoefL );
// right channel // right channel
vecsOutData[k + 1] = Double2Short ( vecsOutData[k + 1] = Double2Short (
static_cast<double> ( vecsOutData[k + 1] ) + vecsData[i] * dPanCoefR); static_cast<double> ( vecsOutData[k + 1] ) + vecsData[i] * dPanCoefR );
} }
} }
else else
@ -1181,9 +1183,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
// stereo // stereo
for ( i = 0; i < ( 2 * iServerFrameSizeSamples ); i++ ) for ( i = 0; i < ( 2 * iServerFrameSizeSamples ); i++ )
{ {
double pan = (i%2==0) ? dPanCoefL : dPanCoefR; // get the correct pan value for the current channel (left or right)
const double pan = ( i % 2 == 0 ) ? dPanCoefL : dPanCoefR;
vecsOutData[i] = Double2Short ( vecsOutData[i] = Double2Short (
static_cast<double> ( vecsOutData[i] ) + vecsData[i] * pan ); static_cast<double> ( vecsOutData[i] ) + vecsData[i] * pan );
} }
} }
} }
@ -1196,11 +1200,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
{ {
// left channel // left channel
vecsOutData[k] = Double2Short ( vecsOutData[k] = Double2Short (
vecsOutData[k] + vecsData[i] * dGain * dPanCoefL); vecsOutData[k] + vecsData[i] * dGain * dPanCoefL );
// right channel // right channel
vecsOutData[k + 1] = Double2Short ( vecsOutData[k + 1] = Double2Short (
vecsOutData[k + 1] + vecsData[i] * dGain * dPanCoefR); vecsOutData[k + 1] + vecsData[i] * dGain * dPanCoefR );
} }
} }
else else
@ -1208,10 +1212,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
// stereo // stereo
for ( i = 0; i < ( 2 * iServerFrameSizeSamples ); i++ ) for ( i = 0; i < ( 2 * iServerFrameSizeSamples ); i++ )
{ {
double pan = (i%2==0) ? dPanCoefL : dPanCoefR; // get the correct pan value for the current channel (left or right)
vecsOutData[i] = Double2Short ( double pan = ( i % 2 == 0 ) ? dPanCoefL : dPanCoefR;
vecsOutData[i] + vecsData[i] * dGain * pan );
vecsOutData[i] = Double2Short (
vecsOutData[i] + vecsData[i] * dGain * pan );
} }
} }
} }