From 292cf13a2168139d97112da9c3277eabf26c75e6 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 24 Feb 2014 19:51:57 +0000 Subject: [PATCH] finished #43 Hybrid Mono/Stereo mode --- src/client.cpp | 11 +----- src/client.h | 4 +- src/clientdlg.cpp | 6 +-- src/clientdlg.h | 2 +- src/clientsettingsdlg.cpp | 71 ++++++++++++++++++++---------------- src/clientsettingsdlg.h | 4 +- src/clientsettingsdlgbase.ui | 20 +++++++--- src/settings.cpp | 21 ++++++----- 8 files changed, 74 insertions(+), 65 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 615a0035..a3e79f46 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -472,7 +472,7 @@ void CClient::SetAudioQuality ( const EAudioQuality eNAudioQuality ) } } -void CClient::SetUseStereo ( const bool bNUseStereo ) +void CClient::SetAudioChannels ( const EAudChanConf eNAudChanConf ) { // init with new parameter, if client was running then first // stop it and restart again after new initialization @@ -483,14 +483,7 @@ void CClient::SetUseStereo ( const bool bNUseStereo ) } // set new parameter - if ( bNUseStereo ) - { - eAudioChannelConf = CC_STEREO; - } - else - { - eAudioChannelConf = CC_MONO; - } + eAudioChannelConf = eNAudChanConf; Init(); if ( bWasRunning ) diff --git a/src/client.h b/src/client.h index 6c5d7532..9c9185db 100755 --- a/src/client.h +++ b/src/client.h @@ -129,8 +129,8 @@ public: EAudioQuality GetAudioQuality() const { return eAudioQuality; } void SetAudioQuality ( const EAudioQuality eNAudioQuality ); - bool GetUseStereo() const { return ( eAudioChannelConf == CC_STEREO ); } - void SetUseStereo ( const bool bNUseStereo ); + EAudChanConf GetAudioChannels() const { return eAudioChannelConf; } + void SetAudioChannels ( const EAudChanConf eNAudChanConf ); void SetServerListCentralServerAddress ( const QString& sNCentServAddr ) { strCentralServerAddress = sNCentServAddr; } diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 04eab665..96d07a53 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -511,8 +511,8 @@ CClientDlg::CClientDlg ( CClient* pNCliP, QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ), this, SLOT ( OnGUIDesignChanged() ) ); - QObject::connect ( &ClientSettingsDlg, SIGNAL ( StereoCheckBoxChanged() ), - this, SLOT ( OnStereoCheckBoxChanged() ) ); + QObject::connect ( &ClientSettingsDlg, SIGNAL ( AudioChannelsChanged() ), + this, SLOT ( OnAudioChannelsChanged() ) ); QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanGain ( int, double ) ), this, SLOT ( OnChangeChanGain ( int, double ) ) ); @@ -611,7 +611,7 @@ void CClientDlg::UpdateAudioFaderSlider() void CClientDlg::UpdateRevSelection() { - if ( pClient->GetUseStereo() ) + if ( pClient->GetAudioChannels() == CC_STEREO ) { // for stereo make channel selection invisible since // reverberation effect is always applied to both channels diff --git a/src/clientdlg.h b/src/clientdlg.h index ee84dd9b..658a50ca 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -189,6 +189,6 @@ public slots: void OnGUIDesignChanged() { SetGUIDesign ( pClient->GetGUIDesign() ); } - void OnStereoCheckBoxChanged() { UpdateRevSelection(); } + void OnAudioChannelsChanged() { UpdateRevSelection(); } void OnNumClientsChanged ( int iNewNumClients ); }; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 82a880fe..e658c050 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -192,6 +192,28 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, chbGUIDesignFancy->setAccessibleName ( tr ( "Fancy skin check box" ) ); + // audio channels + QString strAudioChannels = tr ( "Audio Channels: " + "Select the number of audio channels to be used. There are three " + "modes available. The mono and stereo modes use one and two " + "audio channels respectively. In the mono-in/stereo-out mode " + "the audio signal which is sent to the server is mono but the " + "return signal is stereo. This is useful for the case that the " + "sound card puts the instrument on one input channel and the " + "microphone on the other channel. In that case the two input signals " + "can be mixed to one mono channel but the server mix can be heard in " + "stereo.
" + "Enabling the stereo streaming mode will increase the " + "stream data rate. Make sure that the current upload rate does not " + "exceed the available bandwidth of your internet connection.
" + "In case of the stereo streaming mode, no audio channel selection " + "for the reverberation effect will be available on the main window " + "since the effect is applied on both channels in this case." ); + + lblAudioChannels->setWhatsThis ( strAudioChannels ); + cbxAudioChannels->setWhatsThis ( strAudioChannels ); + cbxAudioChannels->setAccessibleName ( tr ( "Audio channels combo box" ) ); + // audio quality QString strAudioQuality = tr ( "Audio Quality: " "Select the desired audio quality. A low, normal or high audio " @@ -204,18 +226,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, cbxAudioQuality->setWhatsThis ( strAudioQuality ); cbxAudioQuality->setAccessibleName ( tr ( "Audio quality combo box" ) ); - // use stereo - chbUseStereo->setWhatsThis ( tr ( "Stereo Streaming " - "Enables the stereo streaming mode. If not checked, a mono streaming " - "mode is used. Enabling the stereo streaming mode will increase the " - "stream data rate. Make sure that the current upload rate does not " - "exceed the available bandwidth of your internet connection.
" - "In case of the stereo streaming mode, no audio channel selection " - "for the reverberation effect will be available on the main window " - "since the effect is applied on both channels in this case." ) ); - - chbUseStereo->setAccessibleName ( tr ( "Stereo check box" ) ); - // central server address QString strCentrServAddr = tr ( "Central Server Address: The " "central server address is the IP address or URL of the central server " @@ -313,6 +323,13 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, chbGUIDesignFancy->setCheckState ( Qt::Checked ); } + // "Audio Channels" combo box + cbxAudioChannels->clear(); + cbxAudioChannels->addItem ( "Mono" ); // CC_MONO + cbxAudioChannels->addItem ( "Mono-in/Stereo-out" ); // CC_MONO_IN_STEREO_OUT + cbxAudioChannels->addItem ( "Stereo" ); // CC_STEREO + cbxAudioChannels->setCurrentIndex ( static_cast ( pClient->GetAudioChannels() ) ); + // "Audio Quality" combo box cbxAudioQuality->clear(); cbxAudioQuality->addItem ( "Low" ); // AQ_LOW @@ -320,16 +337,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, cbxAudioQuality->addItem ( "High" ); // AQ_HIGH cbxAudioQuality->setCurrentIndex ( static_cast ( pClient->GetAudioQuality() ) ); - // "Stereo" check box - if ( pClient->GetUseStereo() ) - { - chbUseStereo->setCheckState ( Qt::Checked ); - } - else - { - chbUseStereo->setCheckState ( Qt::Unchecked ); - } - // update default central server address check box if ( pClient->GetUseDefaultCentralServerAddress() ) { @@ -379,9 +386,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, QObject::connect ( chbGUIDesignFancy, SIGNAL ( stateChanged ( int ) ), this, SLOT ( OnGUIDesignFancyStateChanged ( int ) ) ); - QObject::connect ( chbUseStereo, SIGNAL ( stateChanged ( int ) ), - this, SLOT ( OnUseStereoStateChanged ( int ) ) ); - QObject::connect ( chbAutoJitBuf, SIGNAL ( stateChanged ( int ) ), this, SLOT ( OnAutoJitBufStateChanged ( int ) ) ); @@ -408,6 +412,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, QObject::connect ( cbxROutChan, SIGNAL ( activated ( int ) ), this, SLOT ( OnROutChanActivated ( int ) ) ); + QObject::connect ( cbxAudioChannels, SIGNAL ( activated ( int ) ), + this, SLOT ( OnAudioChannelsActivated ( int ) ) ); + QObject::connect ( cbxAudioQuality, SIGNAL ( activated ( int ) ), this, SLOT ( OnAudioQualityActivated ( int ) ) ); @@ -630,6 +637,13 @@ void CClientSettingsDlg::OnROutChanActivated ( int iChanIdx ) UpdateSoundChannelSelectionFrame(); } +void CClientSettingsDlg::OnAudioChannelsActivated ( int iChanIdx ) +{ + pClient->SetAudioChannels ( static_cast ( iChanIdx ) ); + emit AudioChannelsChanged(); + UpdateDisplay(); // upload rate will be changed +} + void CClientSettingsDlg::OnAudioQualityActivated ( int iQualityIdx ) { pClient->SetAudioQuality ( static_cast ( iQualityIdx ) ); @@ -662,13 +676,6 @@ void CClientSettingsDlg::OnGUIDesignFancyStateChanged ( int value ) UpdateDisplay(); } -void CClientSettingsDlg::OnUseStereoStateChanged ( int value ) -{ - pClient->SetUseStereo ( value == Qt::Checked ); - emit StereoCheckBoxChanged(); - UpdateDisplay(); // upload rate will be changed -} - void CClientSettingsDlg::OnDefaultCentralServerStateChanged ( int value ) { // apply new setting to the client diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index a59b934d..f5af98f9 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -91,7 +91,6 @@ protected: void OnAutoJitBufStateChanged ( int value ); void OnOpenChatOnNewMessageStateChanged ( int value ); void OnGUIDesignFancyStateChanged ( int value ); - void OnUseStereoStateChanged ( int value ); void OnDefaultCentralServerStateChanged ( int value ); void OnCentralServerAddressEditingFinished(); void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button ); @@ -100,10 +99,11 @@ protected: void OnRInChanActivated ( int iChanIdx ); void OnLOutChanActivated ( int iChanIdx ); void OnROutChanActivated ( int iChanIdx ); + void OnAudioChannelsActivated ( int iChanIdx ); void OnAudioQualityActivated ( int iQualityIdx ); void OnDriverSetupClicked(); signals: void GUIDesignChanged(); - void StereoCheckBoxChanged(); + void AudioChannelsChanged(); }; diff --git a/src/clientsettingsdlgbase.ui b/src/clientsettingsdlgbase.ui index 71d216ae..43125280 100755 --- a/src/clientsettingsdlgbase.ui +++ b/src/clientsettingsdlgbase.ui @@ -482,11 +482,18 @@ - - - Stereo Streaming - - + + + + + Audio Channels + + + + + + + @@ -683,7 +690,8 @@ sldNetBufServer chbOpenChatOnNewMessage chbGUIDesignFancy - chbUseStereo + cbxAudioChannels + cbxAudioQuality chbDefaultCentralServer edtCentralServerAddress diff --git a/src/settings.cpp b/src/settings.cpp index a3eb39be..8df3d6df 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -223,6 +223,13 @@ void CSettings::Load() pClient->SetGUIDesign ( static_cast ( iValue ) ); } + // audio channels + if ( GetNumericIniSet ( IniXMLDocument, "client", "audiochannels", + 0, 2 /* CC_STEREO */, iValue ) ) + { + pClient->SetAudioChannels ( static_cast ( iValue ) ); + } + // audio quality if ( GetNumericIniSet ( IniXMLDocument, "client", "audioquality", 0, 2 /* AQ_HIGH */, iValue ) ) @@ -230,12 +237,6 @@ void CSettings::Load() pClient->SetAudioQuality ( static_cast ( iValue ) ); } - // flag whether stereo mode is used - if ( GetFlagIniSet ( IniXMLDocument, "client", "stereoaudio", bValue ) ) - { - pClient->SetUseStereo ( bValue ); - } - // central server address pClient->SetServerListCentralServerAddress ( GetIniSetting ( IniXMLDocument, "client", "centralservaddr" ) ); @@ -432,14 +433,14 @@ void CSettings::Save() SetNumericIniSet ( IniXMLDocument, "client", "guidesign", static_cast ( pClient->GetGUIDesign() ) ); + // audio channels + SetNumericIniSet ( IniXMLDocument, "client", "audiochannels", + static_cast ( pClient->GetAudioChannels() ) ); + // audio quality SetNumericIniSet ( IniXMLDocument, "client", "audioquality", static_cast ( pClient->GetAudioQuality() ) ); - // flag whether stereo mode is used - SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio", - pClient->GetUseStereo() ); - // central server address PutIniSetting ( IniXMLDocument, "client", "centralservaddr", pClient->GetServerListCentralServerAddress() );