Support for three audio quality settings (a new high quality rate is introduced)

This commit is contained in:
Volker Fischer 2013-08-15 19:15:01 +00:00
parent 2856626523
commit c22c264123
8 changed files with 287 additions and 284 deletions

View file

@ -6,6 +6,8 @@ TODO: This feature is disabled for now since it does not work as expected (we
DISABLED: - the connection setup dialog can now be opened during a connection
- support for three audio quality settings: low, normal and high
3.3.1

View file

@ -33,8 +33,8 @@ CClient::CClient ( const quint16 iPortNumber ) :
vecStoredFaderLevels ( MAX_NUM_STORED_FADER_LEVELS, AUD_MIX_FADER_MAX ),
Channel ( false ), /* we need a client channel -> "false" */
eAudioCompressionType ( CT_OPUS ),
iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ),
bCeltDoHighQuality ( false ),
iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_LOW_QUALITY ),
eAudioQuality ( AQ_LOW ),
bUseStereo ( false ),
bIsInitializationPhase ( true ),
Socket ( &Channel, iPortNumber ),
@ -424,7 +424,7 @@ void CClient::SetAudoCompressiontype ( const EAudComprType eNAudCompressionType
}
}
void CClient::SetCELTHighQuality ( const bool bNCeltHighQualityFlag )
void CClient::SetAudioQuality ( const EAudioQuality eNAudioQuality )
{
// init with new parameter, if client was running then first
// stop it and restart again after new initialization
@ -435,7 +435,7 @@ void CClient::SetCELTHighQuality ( const bool bNCeltHighQualityFlag )
}
// set new parameter
bCeltDoHighQuality = bNCeltHighQualityFlag;
eAudioQuality = eNAudioQuality;
Init();
if ( bWasRunning )
@ -744,54 +744,66 @@ void CClient::Init()
AudioReverbL.Init ( SYSTEM_SAMPLE_RATE_HZ );
AudioReverbR.Init ( SYSTEM_SAMPLE_RATE_HZ );
// inits for CELT coding
if ( bCeltDoHighQuality )
// inits for audio coding
if ( eAudioCompressionType == CT_CELT )
{
if ( bUseStereo )
{
if ( eAudioCompressionType == CT_CELT )
if ( eAudioQuality == AQ_LOW )
{
iCeltNumCodedBytes = CELT_NUM_BYTES_STEREO_HIGH_QUALITY;
iCeltNumCodedBytes = CELT_NUM_BYTES_STEREO_LOW_QUALITY;
}
else
{
iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_HIGH_QUALITY;
}
}
else
{
if ( eAudioCompressionType == CT_CELT )
{
iCeltNumCodedBytes = CELT_NUM_BYTES_MONO_HIGH_QUALITY;
}
else
{
iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_HIGH_QUALITY;
}
}
}
else
{
if ( bUseStereo )
{
if ( eAudioCompressionType == CT_CELT )
{
iCeltNumCodedBytes = CELT_NUM_BYTES_STEREO_NORMAL_QUALITY;
}
else
{
iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY;
}
}
else
{
if ( eAudioCompressionType == CT_CELT )
if ( eAudioQuality == AQ_LOW )
{
iCeltNumCodedBytes = CELT_NUM_BYTES_MONO_LOW_QUALITY;
}
else
{
iCeltNumCodedBytes = CELT_NUM_BYTES_MONO_NORMAL_QUALITY;
}
}
}
else
{
if ( bUseStereo )
{
switch ( eAudioQuality )
{
case AQ_LOW:
iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_LOW_QUALITY;
break;
case AQ_NORMAL:
iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY;
break;
case AQ_HIGH:
iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_HIGH_QUALITY;
break;
}
}
else
{
switch ( eAudioQuality )
{
case AQ_LOW:
iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_LOW_QUALITY;
break;
case AQ_NORMAL:
iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_NORMAL_QUALITY;
break;
case AQ_HIGH:
iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_HIGH_QUALITY;
break;
}
}
}

View file

@ -65,17 +65,16 @@
#define AUD_REVERB_MAX 100
// CELT number of coded bytes per audio packet
// 24: mono low/normal quality 156 kbps (128) / 114 kbps (256)
// 44: mono high quality 216 kbps (128) / 174 kbps (256)
// 24: mono low quality 156 kbps (128) / 114 kbps (256)
// 44: mono normal quality 216 kbps (128) / 174 kbps (256)
// NOTE: Must be > CELT_MINIMUM_NUM_BYTES (greater, not equal to!)
#define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 24
#define CELT_NUM_BYTES_MONO_HIGH_QUALITY 44
// 46: stereo low/normal quality 222 kbps (128) / 180 kbps (256)
// 70: stereo high quality 294 kbps (128) / 252 kbps (256)
#define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 46
#define CELT_NUM_BYTES_STEREO_HIGH_QUALITY 70
#define CELT_NUM_BYTES_MONO_LOW_QUALITY 24
#define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 44
// 46: stereo low quality 222 kbps (128) / 180 kbps (256)
// 70: stereo normal quality 294 kbps (128) / 252 kbps (256)
#define CELT_NUM_BYTES_STEREO_LOW_QUALITY 46
#define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 70
// OPUS number of coded bytes per audio packet
// TODO we have to use new numbers for OPUS to avoid that old CELT packets
@ -88,11 +87,13 @@
// Fs: sampling rate (SYSTEM_SAMPLE_RATE_HZ)
// L: number of samples per packet (SYSTEM_FRAME_SIZE_SAMPLES)
// N: number of bytes per packet (values below)
#define OPUS_NUM_BYTES_MONO_LOW_QUALITY 25
#define OPUS_NUM_BYTES_MONO_NORMAL_QUALITY 45
#define OPUS_NUM_BYTES_MONO_HIGH_QUALITY 71
#define OPUS_NUM_BYTES_MONO_NORMAL_QUALITY 25
#define OPUS_NUM_BYTES_MONO_HIGH_QUALITY 45
#define OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY 47
#define OPUS_NUM_BYTES_STEREO_HIGH_QUALITY 71
#define OPUS_NUM_BYTES_STEREO_LOW_QUALITY 47
#define OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY 71
#define OPUS_NUM_BYTES_STEREO_HIGH_QUALITY 142
/* Classes ********************************************************************/
@ -115,10 +116,10 @@ public:
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
EGUIDesign GetGUIDesign() const { return eGUIDesign; }
void SetGUIDesign ( const EGUIDesign bNGD ) { eGUIDesign = bNGD; }
void SetGUIDesign ( const EGUIDesign eNGD ) { eGUIDesign = eNGD; }
bool GetCELTHighQuality() const { return bCeltDoHighQuality; }
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
EAudioQuality GetAudioQuality() const { return eAudioQuality; }
void SetAudioQuality ( const EAudioQuality eNAudioQuality );
bool GetUseStereo() const { return bUseStereo; }
void SetUseStereo ( const bool bNUseStereo );
@ -303,7 +304,7 @@ void SetAudoCompressiontype ( const EAudComprType eNAudCompressionType );
OpusCustomDecoder* OpusDecoderStereo;
EAudComprType eAudioCompressionType;
int iCeltNumCodedBytes;
bool bCeltDoHighQuality;
EAudioQuality eAudioQuality;
bool bUseStereo;
bool bIsInitializationPhase;
CVector<unsigned char> vecCeltData;

View file

@ -192,15 +192,17 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
chbGUIDesignFancy->setAccessibleName ( tr ( "Fancy skin check box" ) );
// use high quality audio
chbUseHighQualityAudio->setWhatsThis ( tr ( "<b>Use High Quality Audio:</b> "
"If enabled, it will improve the audio quality "
"by increasing the audio stream data rate. Make sure that the current "
// audio quality
QString strAudioQuality = tr ( "<b>Audio Quality:</b> "
"Select the desired audio quality. A low, normal or high audio "
"quality can be selected. The higher the audio quality, the higher "
"the audio stream data rate. Make sure that the current "
"upload rate does not exceed the available bandwidth of your "
"internet connection." ) );
"internet connection." );
chbUseHighQualityAudio->setAccessibleName ( tr ( "Use high quality audio "
"check box" ) );
lblAudioQuality->setWhatsThis ( strAudioQuality );
cbxAudioQuality->setWhatsThis ( strAudioQuality );
cbxAudioQuality->setAccessibleName ( tr ( "Audio quality combo box" ) );
// use stereo
chbUseStereo->setWhatsThis ( tr ( "<b>Stereo Streaming</b> "
@ -311,15 +313,12 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
chbGUIDesignFancy->setCheckState ( Qt::Checked );
}
// "High Quality Audio" check box
if ( pClient->GetCELTHighQuality() )
{
chbUseHighQualityAudio->setCheckState ( Qt::Checked );
}
else
{
chbUseHighQualityAudio->setCheckState ( Qt::Unchecked );
}
// "Audio Quality" combo box
cbxAudioQuality->clear();
cbxAudioQuality->addItem ( "Low" ); // AQ_LOW
cbxAudioQuality->addItem ( "Normal" ); // AQ_NORMAL
cbxAudioQuality->addItem ( "High" ); // AQ_HIGH
cbxAudioQuality->setCurrentIndex ( static_cast<int> ( pClient->GetAudioQuality() ) );
// "Stereo" check box
if ( pClient->GetUseStereo() )
@ -380,9 +379,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( chbGUIDesignFancy, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnGUIDesignFancyStateChanged ( int ) ) );
QObject::connect ( chbUseHighQualityAudio, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnUseHighQualityAudioStateChanged ( int ) ) );
QObject::connect ( chbUseStereo, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnUseStereoStateChanged ( int ) ) );
@ -412,6 +408,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( cbxROutChan, SIGNAL ( activated ( int ) ),
this, SLOT ( OnROutChanActivated ( int ) ) );
QObject::connect ( cbxAudioQuality, SIGNAL ( activated ( int ) ),
this, SLOT ( OnAudioQualityActivated ( int ) ) );
// buttons
QObject::connect ( butDriverSetup, SIGNAL ( clicked() ),
this, SLOT ( OnDriverSetupClicked() ) );
@ -631,6 +630,12 @@ void CClientSettingsDlg::OnROutChanActivated ( int iChanIdx )
UpdateSoundChannelSelectionFrame();
}
void CClientSettingsDlg::OnAudioQualityActivated ( int iQualityIdx )
{
pClient->SetAudioQuality ( static_cast<EAudioQuality> ( iQualityIdx ) );
UpdateDisplay(); // upload rate will be changed
}
void CClientSettingsDlg::OnAutoJitBufStateChanged ( int value )
{
pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
@ -657,12 +662,6 @@ void CClientSettingsDlg::OnGUIDesignFancyStateChanged ( int value )
UpdateDisplay();
}
void CClientSettingsDlg::OnUseHighQualityAudioStateChanged ( int value )
{
pClient->SetCELTHighQuality ( value == Qt::Checked );
UpdateDisplay(); // upload rate will be changed
}
void CClientSettingsDlg::OnUseStereoStateChanged ( int value )
{
pClient->SetUseStereo ( value == Qt::Checked );

View file

@ -83,7 +83,6 @@ protected:
void OnAutoJitBufStateChanged ( int value );
void OnOpenChatOnNewMessageStateChanged ( int value );
void OnGUIDesignFancyStateChanged ( int value );
void OnUseHighQualityAudioStateChanged ( int value );
void OnUseStereoStateChanged ( int value );
void OnDefaultCentralServerStateChanged ( int value );
void OnCentralServerAddressEditingFinished();
@ -93,6 +92,7 @@ protected:
void OnRInChanActivated ( int iChanIdx );
void OnLOutChanActivated ( int iChanIdx );
void OnROutChanActivated ( int iChanIdx );
void OnAudioQualityActivated ( int iQualityIdx );
void OnDriverSetupClicked();
signals:

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CClientSettingsDlgBase</class>
<widget class="QDialog" name="CClientSettingsDlgBase">
@ -13,7 +14,8 @@
<string>General Settings</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc" >:/png/main/res/mainicon.png</iconset>
<iconset resource="resources.qrc">
<normaloff>:/png/main/res/mainicon.png</normaloff>:/png/main/res/mainicon.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
@ -35,7 +37,7 @@
<item>
<widget class="QComboBox" name="cbxSoundcard">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -51,7 +53,7 @@
<item>
<widget class="QFrame" name="FrameSoundcardChannelSelection">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -63,16 +65,7 @@
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout">
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin">
<number>0</number>
</property>
<item>
@ -92,7 +85,7 @@
<item>
<widget class="QLabel" name="lblLInChan">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -105,7 +98,7 @@
<item>
<widget class="QLabel" name="lblRInChan">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -149,7 +142,7 @@
<item>
<widget class="QLabel" name="lblLOutChan">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -162,7 +155,7 @@
<item>
<widget class="QLabel" name="lblROutChan">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -197,7 +190,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>153</width>
<height>0</height>
@ -347,21 +340,6 @@
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation">
@ -370,7 +348,7 @@
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
@ -399,7 +377,7 @@
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
@ -432,7 +410,7 @@
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
@ -441,9 +419,9 @@
</spacer>
</item>
<item>
<widget class="CMultiColorLED" native="1" name="ledNetw" >
<widget class="CMultiColorLED" name="ledNetw" native="true">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -470,7 +448,7 @@
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
@ -488,7 +466,7 @@
<property name="title">
<string>Misc</string>
</property>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="chbOpenChatOnNewMessage">
<property name="text">
@ -503,26 +481,27 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chbUseHighQualityAudio" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<property name="text" >
<string>Use High Quality Audio</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chbUseStereo">
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<property name="text">
<string>Stereo Streaming</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="lblAudioQuality">
<property name="text">
<string>Audio Quality</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbxAudioQuality"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
@ -544,7 +523,7 @@
<item>
<widget class="QLineEdit" name="edtCentralServerAddress">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -556,7 +535,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>201</width>
<height>21</height>
@ -600,7 +579,7 @@
<item>
<widget class="QLabel" name="lblPingTimeValue">
<property name="sizePolicy">
<sizepolicy vsizetype="Maximum" hsizetype="Preferred" >
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -635,7 +614,7 @@
<item>
<widget class="QLabel" name="lblOverallDelayValue">
<property name="sizePolicy">
<sizepolicy vsizetype="Maximum" hsizetype="Preferred" >
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -652,9 +631,9 @@
</widget>
</item>
<item>
<widget class="CMultiColorLED" native="1" name="ledOverallDelay" >
<widget class="CMultiColorLED" name="ledOverallDelay" native="true">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -704,7 +683,6 @@
<tabstop>sldNetBufServer</tabstop>
<tabstop>chbOpenChatOnNewMessage</tabstop>
<tabstop>chbGUIDesignFancy</tabstop>
<tabstop>chbUseHighQualityAudio</tabstop>
<tabstop>chbUseStereo</tabstop>
<tabstop>chbDefaultCentralServer</tabstop>
<tabstop>edtCentralServerAddress</tabstop>

View file

@ -212,10 +212,11 @@ void CSettings::Load()
pClient->SetGUIDesign ( static_cast<EGUIDesign> ( iValue ) );
}
// flag whether using high quality audio or not
if ( GetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio", bValue ) )
// audio quality
if ( GetNumericIniSet ( IniXMLDocument, "client", "audioquality",
0, 2 /* AQ_HIGH */, iValue ) )
{
pClient->SetCELTHighQuality ( bValue );
pClient->SetAudioQuality ( static_cast<EAudioQuality> ( iValue ) );
}
// flag whether stereo mode is used
@ -376,9 +377,9 @@ void CSettings::Save()
SetNumericIniSet ( IniXMLDocument, "client", "guidesign",
static_cast<int> ( pClient->GetGUIDesign() ) );
// flag whether using high quality audio or not
SetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio",
pClient->GetCELTHighQuality() );
// audio quality
SetNumericIniSet ( IniXMLDocument, "client", "audioquality",
static_cast<int> ( pClient->GetAudioQuality() ) );
// flag whether stereo mode is used
SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio",

View file

@ -450,6 +450,16 @@ enum EAudComprType
};
// Audio quality enum ----------------------------------------------------------
enum EAudioQuality
{
// used for settings and the comobo box index -> enum values must be fixed!
AQ_LOW = 0,
AQ_NORMAL = 1,
AQ_HIGH = 2
};
// Get data status enum --------------------------------------------------------
enum EGetDataStat
{