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 );
plbrChannelLevel = new CMultiColorLEDBar ( pLevelsBox );
pFader = new QSlider ( Qt::Vertical, pLevelsBox );
pPan = new QSlider (Qt::Horizontal, pLevelsBox);
pPan = new QSlider ( Qt::Horizontal, pLevelsBox );
pMuteSoloBox = new QWidget ( pFrame );
pcbMute = new QCheckBox ( tr ( "Mute" ), pMuteSoloBox );
@ -67,9 +66,8 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 );
// setup panning slider
pPan->setRange( 0, AUD_MIX_PAN_MAX);
pPan->setValue(AUD_MIX_PAN_MAX/2);
pPan->setRange ( 0, AUD_MIX_PAN_MAX );
pPan->setValue ( AUD_MIX_PAN_MAX / 2 );
// setup fader tag label (black bold text which is centered)
plblLabel->setTextFormat ( Qt::PlainText );
@ -127,8 +125,9 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pFader->setAccessibleName ( tr ( "Local mix level setting of the current audio "
"channel at the server" ) );
pPan->setWhatsThis ( "<b>" + tr ( "Panning") + ":</b>" + tr ( "Sets the panning position from Left to Right of the channel. "
" Works only in stero or preferably mono in/stereo out mode." ) );
pPan->setWhatsThis ( "<b>" + tr ( "Panning" ) + ":</b>" + tr (
"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" ) );
pcbMute->setWhatsThis ( "<b>" + tr ( "Mute" ) + ":</b> " + tr (
@ -260,7 +259,7 @@ void CChannelFader::Reset()
{
// init gain and pan value -> maximum value as definition according to server
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
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
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
// server about the change
pPan->setValue ( iPan );
SendPanValueToServer( iPan );
SendPanValueToServer ( iPan );
}
}
@ -337,8 +336,7 @@ void CChannelFader::SendFaderLevelToServer ( const int iLevel )
void CChannelFader::SendPanValueToServer ( const int iPan )
{
double dPan = static_cast<double> ( iPan ) / AUD_MIX_PAN_MAX;
emit panValueChanged ( dPan );
emit panValueChanged ( static_cast<double> ( iPan ) / AUD_MIX_PAN_MAX );
}
void CChannelFader::OnMuteStateChanged ( int value )
@ -559,7 +557,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) :
QScrollArea ( parent ),
vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ),
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 ),
vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ),
iNewClientFaderLevel ( 100 ),
@ -839,7 +837,6 @@ void CAudioMixerBoard::UpdatePanValue ( const int iChannelIdx,
emit ChangeChanPan ( iChannelIdx, dValue );
}
void CAudioMixerBoard::StoreFaderSettings ( CChannelFader* pChanFader )
{
// if the fader was visible and the name is not empty, we store the old gain

View file

@ -65,7 +65,7 @@ public:
void SetFaderIsSolo ( const bool bIsSolo );
void SetFaderIsMute ( const bool bIsMute );
int GetFaderLevel() { return pFader->value(); }
int GetPanValue() {return pPan->value(); }
int GetPanValue() { return pPan->value(); }
void Reset();
void SetChannelLevel ( const uint16_t iLevel );
@ -98,12 +98,12 @@ protected:
public slots:
void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); }
void OnPanValueChanged ( int value ) {SendPanValueToServer ( value ); }
void OnPanValueChanged ( int value ) { SendPanValueToServer ( value ); }
void OnMuteStateChanged ( int value );
signals:
void gainValueChanged ( double value );
void panValueChanged (double value );
void panValueChanged ( double value );
void soloStateChanged ( int value );
};
@ -154,7 +154,7 @@ public:
int iNewClientFaderLevel;
protected:
bool GetStoredFaderSettings (const CChannelInfo& ChanInfo,
bool GetStoredFaderSettings ( const CChannelInfo& ChanInfo,
int& iStoredFaderLevel,
int& iStoredPanValue,
bool& bStoredFaderIsSolo,

View file

@ -28,7 +28,7 @@
// CChannel implementation *****************************************************
CChannel::CChannel ( const bool bNIsServer ) :
vecdGains ( MAX_NUM_CHANNELS, 1.0 ),
vecdPannings ( MAX_NUM_CHANNELS, 0.5),
vecdPannings ( MAX_NUM_CHANNELS, 0.5 ),
bDoAutoSockBufSize ( true ),
iFadeInCnt ( 0 ),
iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ),
@ -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 );
@ -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 );
@ -368,7 +369,7 @@ void CChannel::OnChangeChanGain ( int iChanID,
void CChannel::OnChangeChanPan ( int iChanID,
double dNewPan )
{
SetPan( iChanID, dNewPan );
SetPan ( iChanID, dNewPan );
}
void CChannel::OnChangeChanInfo ( CChannelCoreInfo ChanInfo )

View file

@ -197,7 +197,6 @@ protected:
// mixer and effect settings
CVector<double> vecdGains;
CVector<double> vecdPannings;
// network jitter-buffer

View file

@ -35,7 +35,7 @@ CClient::CClient ( const quint16 iPortNumber,
ChannelInfo (),
vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ),
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 ),
vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ),
iNewClientFaderLevel ( 100 ),

View file

@ -147,14 +147,10 @@ LED bar: lbr
// default network buffer size
#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
// audio mixer panning maximum value
#define AUD_MIX_PAN_MAX 100
// maximum number of recognized sound cards installed in the system,
// definition for "no device"
#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 );
}
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
int iPos = 0; // init position pointer
@ -822,7 +847,7 @@ void CProtocol::CreateChanPanMes(const int iChanID, const double dPan)
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
@ -833,39 +858,10 @@ bool CProtocol::EvaluateChanGainMes ( const CVector<uint8_t>& vecData )
}
// 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
}
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 ) );
const int iCurID = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
// pan (read integer value)
const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
const int iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// we convert the gain from integer to double with range 0..1
const double dNewPan = static_cast<double> ( iData ) / ( 1 << 15 );

View file

@ -843,11 +843,12 @@ JitterMeas.Measure();
// "vecChanIDsCurConChan" to query the IDs of the currently
// connected channels
vecvecdGains[i][j] = vecChannels[iCurChanID].GetGain ( vecChanIDsCurConChan[j] );
// consider audio fade-in
vecvecdGains[i][j] *= vecChannels[vecChanIDsCurConChan[j]].GetFadeInGain();
//panning
vecvecdPannings[i][j] = vecChannels[iCurChanID].GetPan( vecChanIDsCurConChan[j] ); //((double)rand() / (double)(RAND_MAX)); //vecChannels[iCurChanID].GetGain ( vecChanIDsCurConChan[j] ); //TODO: GetPanning
// panning
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
@ -1076,7 +1077,7 @@ opus_custom_encoder_ctl ( CurOpusEncoder,
}
/// @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>& vecdPannings,
const CVector<int>& vecNumAudioChannels,
@ -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
const CVector<int16_t>& vecsData = vecvecsData[j];
const double dGain = vecdGains[j];
// calculate pan coefficient, see http://write.flossmanuals.net/csound/b-panning-and-spatialization/ for better formula, if needed
const double dPan = vecdPannings[j];
const double dPanCoefL = sqrt(1-dPan); // faster: (1-dPan)
const double dPanCoefR = sqrt(dPan); // (dPan)
// 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 ( dGain == static_cast<double> ( 1.0 ) )
@ -1169,11 +1171,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
{
// left channel
vecsOutData[k] = Double2Short (
static_cast<double> ( vecsOutData[k] ) + vecsData[i] * dPanCoefL);
static_cast<double> ( vecsOutData[k] ) + vecsData[i] * dPanCoefL );
// right channel
vecsOutData[k + 1] = Double2Short (
static_cast<double> ( vecsOutData[k + 1] ) + vecsData[i] * dPanCoefR);
static_cast<double> ( vecsOutData[k + 1] ) + vecsData[i] * dPanCoefR );
}
}
else
@ -1181,7 +1183,9 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
// stereo
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 (
static_cast<double> ( vecsOutData[i] ) + vecsData[i] * pan );
}
@ -1196,11 +1200,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
{
// left channel
vecsOutData[k] = Double2Short (
vecsOutData[k] + vecsData[i] * dGain * dPanCoefL);
vecsOutData[k] + vecsData[i] * dGain * dPanCoefL );
// right channel
vecsOutData[k + 1] = Double2Short (
vecsOutData[k + 1] + vecsData[i] * dGain * dPanCoefR);
vecsOutData[k + 1] + vecsData[i] * dGain * dPanCoefR );
}
}
else
@ -1208,10 +1212,11 @@ void CServer::ProcessData (const CVector<CVector<int16_t> >& vecvecsData,
// stereo
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)
double pan = ( i % 2 == 0 ) ? dPanCoefL : dPanCoefR;
vecsOutData[i] = Double2Short (
vecsOutData[i] + vecsData[i] * dGain * pan );
}
}
}