Added "Use High Quality Audio" check box in settings dialog (this changes the CELT bit rate actually)
This commit is contained in:
parent
9b2c0b13aa
commit
cb097793f0
6 changed files with 713 additions and 636 deletions
|
@ -37,7 +37,9 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
bOpenChatOnNewMessage ( true ),
|
||||
bDoAutoSockBufSize ( true ),
|
||||
iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ),
|
||||
iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT )
|
||||
iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ),
|
||||
iCeltNumCodedBytes ( CELT_NUM_BYTES_NORMAL_QUALITY ),
|
||||
bCeltDoHighQuality ( false )
|
||||
{
|
||||
// init audio endocder/decoder (mono)
|
||||
CeltMode = celt_mode_create (
|
||||
|
@ -157,7 +159,7 @@ bool CClient::SetServerAddr ( QString strNAddr )
|
|||
|
||||
void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
|
||||
{
|
||||
// right now we simply set the internal value
|
||||
// first check new input parameter
|
||||
if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) ||
|
||||
( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
||||
( iNewFactor == FRAME_SIZE_FACTOR_SAFE ) )
|
||||
|
@ -183,6 +185,28 @@ void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
|
|||
}
|
||||
}
|
||||
|
||||
void CClient::SetCELTHighQuality ( const bool bNCeltHighQualityFlag )
|
||||
{
|
||||
// init with new parameter, if client was running then first
|
||||
// stop it and restart again after new initialization
|
||||
const bool bWasRunning = Sound.IsRunning();
|
||||
if ( bWasRunning )
|
||||
{
|
||||
Sound.Stop();
|
||||
}
|
||||
|
||||
// set new parameter
|
||||
bCeltDoHighQuality = bNCeltHighQualityFlag;
|
||||
|
||||
// init with new block size index parameter
|
||||
Init();
|
||||
|
||||
if ( bWasRunning )
|
||||
{
|
||||
Sound.Start();
|
||||
}
|
||||
}
|
||||
|
||||
QString CClient::SetSndCrdDev ( const int iNewDev )
|
||||
{
|
||||
// if client was running then first
|
||||
|
@ -289,7 +313,6 @@ void CClient::Init()
|
|||
iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES;
|
||||
|
||||
|
||||
|
||||
vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam );
|
||||
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
|
||||
vecdAudioStereo.Init ( iStereoBlockSizeSam );
|
||||
|
@ -303,10 +326,15 @@ iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES;
|
|||
// init reverberation
|
||||
AudioReverb.Init ( SYSTEM_SAMPLE_RATE );
|
||||
|
||||
// 22: low/normal quality 150 kbsp (128) / 108 kbps (256)
|
||||
// 44: high quality 216 kbps (128) / 174 kbps (256)
|
||||
iCeltNumCodedBytes = 22;
|
||||
|
||||
// inits for CELT coding
|
||||
if ( bCeltDoHighQuality )
|
||||
{
|
||||
iCeltNumCodedBytes = CELT_NUM_BYTES_HIGH_QUALITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
iCeltNumCodedBytes = CELT_NUM_BYTES_NORMAL_QUALITY;
|
||||
}
|
||||
vecCeltData.Init ( iCeltNumCodedBytes );
|
||||
|
||||
// init network buffers
|
||||
|
|
10
src/client.h
10
src/client.h
|
@ -55,6 +55,12 @@
|
|||
// audio reverberation range
|
||||
#define AUD_REVERB_MAX 100
|
||||
|
||||
// CELT number of coded bytes per audio packet
|
||||
// 22: low/normal quality 150 kbsp (128) / 108 kbps (256)
|
||||
// 44: high quality 216 kbps (128) / 174 kbps (256)
|
||||
#define CELT_NUM_BYTES_NORMAL_QUALITY 22
|
||||
#define CELT_NUM_BYTES_HIGH_QUALITY 44
|
||||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
class CClient : public QObject
|
||||
|
@ -78,6 +84,9 @@ public:
|
|||
bool GetOpenChatOnNewMessage() { return bOpenChatOnNewMessage; }
|
||||
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
|
||||
|
||||
bool GetCELTHighQuality() { return bCeltDoHighQuality; }
|
||||
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
|
||||
|
||||
int GetAudioInFader() { return iAudioInFader; }
|
||||
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
|
||||
|
||||
|
@ -159,6 +168,7 @@ protected:
|
|||
CELTEncoder* CeltEncoder;
|
||||
CELTDecoder* CeltDecoder;
|
||||
int iCeltNumCodedBytes;
|
||||
bool bCeltDoHighQuality;
|
||||
CVector<unsigned char> vecCeltData;
|
||||
|
||||
CSocket Socket;
|
||||
|
|
|
@ -83,6 +83,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
|||
cbOpenChatOnNewMessage->setCheckState ( Qt::Unchecked );
|
||||
}
|
||||
|
||||
// "High Quality Audio" check box
|
||||
if ( pClient->GetCELTHighQuality() )
|
||||
{
|
||||
cbUseHighQualityAudio->setCheckState ( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
cbUseHighQualityAudio->setCheckState ( Qt::Unchecked );
|
||||
}
|
||||
|
||||
// set text for sound card buffer delay radio buttons
|
||||
rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString (
|
||||
FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
|
@ -117,6 +127,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
|||
// check boxes
|
||||
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
|
||||
this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) );
|
||||
QObject::connect ( cbUseHighQualityAudio, SIGNAL ( stateChanged ( int ) ),
|
||||
this, SLOT ( OnUseHighQualityAudioStateChanged ( int ) ) );
|
||||
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
|
||||
this, SLOT ( OnAutoJitBuf ( int ) ) );
|
||||
|
||||
|
@ -269,6 +281,12 @@ void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
|
|||
UpdateDisplay();
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::OnUseHighQualityAudioStateChanged ( int value )
|
||||
{
|
||||
pClient->SetCELTHighQuality ( value == Qt::Checked );
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
|
||||
{
|
||||
if ( button == rButBufferDelayPreferred )
|
||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
|||
void OnSliderSndCrdBufferDelay ( int value );
|
||||
void OnAutoJitBuf ( int value );
|
||||
void OnOpenChatOnNewMessageStateChanged ( int value );
|
||||
void OnUseHighQualityAudioStateChanged ( int value );
|
||||
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
|
||||
void OnPingTimeResult ( int iPingTime );
|
||||
void OnSoundCrdSelection ( int iSndDevIdx );
|
||||
|
|
|
@ -297,7 +297,17 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="cbOpenChatOnNewMessage" >
|
||||
<property name="text" >
|
||||
<string>Open chat on new message</string>
|
||||
<string>Open Chat on New Message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbUseHighQualityAudio" >
|
||||
<property name="windowModality" >
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Use High Quality Audio</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -309,7 +319,7 @@
|
|||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>201</width>
|
||||
<height>16</height>
|
||||
<height>41</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
|
|
@ -140,6 +140,12 @@ void CSettings::ReadIniFile ( const QString& sFileName )
|
|||
{
|
||||
pClient->SetOpenChatOnNewMessage ( bValue );
|
||||
}
|
||||
|
||||
// flag whether using high quality audio or not
|
||||
if ( GetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio", bValue ) )
|
||||
{
|
||||
pClient->SetCELTHighQuality ( bValue );
|
||||
}
|
||||
}
|
||||
|
||||
void CSettings::WriteIniFile ( const QString& sFileName )
|
||||
|
@ -193,6 +199,10 @@ void CSettings::WriteIniFile ( const QString& sFileName )
|
|||
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",
|
||||
pClient->GetOpenChatOnNewMessage() );
|
||||
|
||||
// flag whether using high quality audio or not
|
||||
SetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio",
|
||||
pClient->GetCELTHighQuality() );
|
||||
|
||||
// prepare file name for storing initialization data in XML file
|
||||
QString sCurFileName = sFileName;
|
||||
if ( sCurFileName.isEmpty() )
|
||||
|
|
Loading…
Reference in a new issue