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 ),
|
bOpenChatOnNewMessage ( true ),
|
||||||
bDoAutoSockBufSize ( true ),
|
bDoAutoSockBufSize ( true ),
|
||||||
iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ),
|
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)
|
// init audio endocder/decoder (mono)
|
||||||
CeltMode = celt_mode_create (
|
CeltMode = celt_mode_create (
|
||||||
|
@ -157,7 +159,7 @@ bool CClient::SetServerAddr ( QString strNAddr )
|
||||||
|
|
||||||
void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
|
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 ) ||
|
if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) ||
|
||||||
( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
||||||
( iNewFactor == FRAME_SIZE_FACTOR_SAFE ) )
|
( 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 )
|
QString CClient::SetSndCrdDev ( const int iNewDev )
|
||||||
{
|
{
|
||||||
// if client was running then first
|
// if client was running then first
|
||||||
|
@ -289,7 +313,6 @@ void CClient::Init()
|
||||||
iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES;
|
iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam );
|
vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam );
|
||||||
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
|
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
|
||||||
vecdAudioStereo.Init ( iStereoBlockSizeSam );
|
vecdAudioStereo.Init ( iStereoBlockSizeSam );
|
||||||
|
@ -303,10 +326,15 @@ iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES;
|
||||||
// init reverberation
|
// init reverberation
|
||||||
AudioReverb.Init ( SYSTEM_SAMPLE_RATE );
|
AudioReverb.Init ( SYSTEM_SAMPLE_RATE );
|
||||||
|
|
||||||
// 22: low/normal quality 150 kbsp (128) / 108 kbps (256)
|
// inits for CELT coding
|
||||||
// 44: high quality 216 kbps (128) / 174 kbps (256)
|
if ( bCeltDoHighQuality )
|
||||||
iCeltNumCodedBytes = 22;
|
{
|
||||||
|
iCeltNumCodedBytes = CELT_NUM_BYTES_HIGH_QUALITY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iCeltNumCodedBytes = CELT_NUM_BYTES_NORMAL_QUALITY;
|
||||||
|
}
|
||||||
vecCeltData.Init ( iCeltNumCodedBytes );
|
vecCeltData.Init ( iCeltNumCodedBytes );
|
||||||
|
|
||||||
// init network buffers
|
// init network buffers
|
||||||
|
|
18
src/client.h
18
src/client.h
|
@ -48,12 +48,18 @@
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
// audio in fader range
|
// audio in fader range
|
||||||
#define AUD_FADER_IN_MIN 0
|
#define AUD_FADER_IN_MIN 0
|
||||||
#define AUD_FADER_IN_MAX 100
|
#define AUD_FADER_IN_MAX 100
|
||||||
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )
|
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )
|
||||||
|
|
||||||
// audio reverberation range
|
// audio reverberation range
|
||||||
#define AUD_REVERB_MAX 100
|
#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 ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
|
@ -78,6 +84,9 @@ public:
|
||||||
bool GetOpenChatOnNewMessage() { return bOpenChatOnNewMessage; }
|
bool GetOpenChatOnNewMessage() { return bOpenChatOnNewMessage; }
|
||||||
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
|
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
|
||||||
|
|
||||||
|
bool GetCELTHighQuality() { return bCeltDoHighQuality; }
|
||||||
|
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
|
||||||
|
|
||||||
int GetAudioInFader() { return iAudioInFader; }
|
int GetAudioInFader() { return iAudioInFader; }
|
||||||
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
|
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
|
||||||
|
|
||||||
|
@ -159,6 +168,7 @@ protected:
|
||||||
CELTEncoder* CeltEncoder;
|
CELTEncoder* CeltEncoder;
|
||||||
CELTDecoder* CeltDecoder;
|
CELTDecoder* CeltDecoder;
|
||||||
int iCeltNumCodedBytes;
|
int iCeltNumCodedBytes;
|
||||||
|
bool bCeltDoHighQuality;
|
||||||
CVector<unsigned char> vecCeltData;
|
CVector<unsigned char> vecCeltData;
|
||||||
|
|
||||||
CSocket Socket;
|
CSocket Socket;
|
||||||
|
|
|
@ -83,6 +83,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
cbOpenChatOnNewMessage->setCheckState ( Qt::Unchecked );
|
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
|
// set text for sound card buffer delay radio buttons
|
||||||
rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString (
|
rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString (
|
||||||
FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES,
|
FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES,
|
||||||
|
@ -117,6 +127,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
// check boxes
|
// check boxes
|
||||||
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) );
|
this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) );
|
||||||
|
QObject::connect ( cbUseHighQualityAudio, SIGNAL ( stateChanged ( int ) ),
|
||||||
|
this, SLOT ( OnUseHighQualityAudioStateChanged ( int ) ) );
|
||||||
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnAutoJitBuf ( int ) ) );
|
this, SLOT ( OnAutoJitBuf ( int ) ) );
|
||||||
|
|
||||||
|
@ -269,6 +281,12 @@ void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CClientSettingsDlg::OnUseHighQualityAudioStateChanged ( int value )
|
||||||
|
{
|
||||||
|
pClient->SetCELTHighQuality ( value == Qt::Checked );
|
||||||
|
UpdateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
|
void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
|
||||||
{
|
{
|
||||||
if ( button == rButBufferDelayPreferred )
|
if ( button == rButBufferDelayPreferred )
|
||||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
||||||
void OnSliderSndCrdBufferDelay ( int value );
|
void OnSliderSndCrdBufferDelay ( int value );
|
||||||
void OnAutoJitBuf ( int value );
|
void OnAutoJitBuf ( int value );
|
||||||
void OnOpenChatOnNewMessageStateChanged ( int value );
|
void OnOpenChatOnNewMessageStateChanged ( int value );
|
||||||
|
void OnUseHighQualityAudioStateChanged ( int value );
|
||||||
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
|
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
|
||||||
void OnPingTimeResult ( int iPingTime );
|
void OnPingTimeResult ( int iPingTime );
|
||||||
void OnSoundCrdSelection ( int iSndDevIdx );
|
void OnSoundCrdSelection ( int iSndDevIdx );
|
||||||
|
|
|
@ -297,7 +297,17 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="cbOpenChatOnNewMessage" >
|
<widget class="QCheckBox" name="cbOpenChatOnNewMessage" >
|
||||||
<property name="text" >
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -309,7 +319,7 @@
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" >
|
||||||
<size>
|
<size>
|
||||||
<width>201</width>
|
<width>201</width>
|
||||||
<height>16</height>
|
<height>41</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
|
|
@ -140,6 +140,12 @@ void CSettings::ReadIniFile ( const QString& sFileName )
|
||||||
{
|
{
|
||||||
pClient->SetOpenChatOnNewMessage ( bValue );
|
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 )
|
void CSettings::WriteIniFile ( const QString& sFileName )
|
||||||
|
@ -193,6 +199,10 @@ void CSettings::WriteIniFile ( const QString& sFileName )
|
||||||
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",
|
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",
|
||||||
pClient->GetOpenChatOnNewMessage() );
|
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
|
// prepare file name for storing initialization data in XML file
|
||||||
QString sCurFileName = sFileName;
|
QString sCurFileName = sFileName;
|
||||||
if ( sCurFileName.isEmpty() )
|
if ( sCurFileName.isEmpty() )
|
||||||
|
|
Loading…
Add table
Reference in a new issue