From 7362dae22957cd1bfac7eae0b6da94d210438d66 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 24 Mar 2010 20:10:25 +0000 Subject: [PATCH] fixes for reverberation in stereo mode (disable channel selection and apply reverb on both channels) --- src/client.cpp | 32 ++++++++++++++---- src/client.h | 6 ++-- src/clientsettingsdlg.cpp | 1 + src/clientsettingsdlg.h | 1 + src/llconclientdlg.cpp | 68 +++++++++++++++++++++++++++++++-------- src/llconclientdlg.h | 42 +++++++++++++----------- 6 files changed, 109 insertions(+), 41 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index b73d0d10..a2fd7f4e 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -524,7 +524,8 @@ void CClient::Init() CycleTimeVariance.Reset(); // init reverberation - AudioReverb.Init ( SYSTEM_SAMPLE_RATE ); + AudioReverbL.Init ( SYSTEM_SAMPLE_RATE ); + AudioReverbR.Init ( SYSTEM_SAMPLE_RATE ); // inits for CELT coding if ( bCeltDoHighQuality ) @@ -634,22 +635,39 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) const double dRevLev = static_cast ( iReverbLevel ) / AUD_REVERB_MAX / 2; - if ( bReverbOnLeftChan ) + if ( bUseStereo ) { + // for stereo always apply reverberation effect on both channels for ( i = 0; i < iStereoBlockSizeSam; i += 2 ) { // left channel vecdAudioStereo[i] += - dRevLev * AudioReverb.ProcessSample ( vecdAudioStereo[i] ); + dRevLev * AudioReverbL.ProcessSample ( vecdAudioStereo[i] ); + + // right channel + vecdAudioStereo[i + 1] += + dRevLev * AudioReverbR.ProcessSample ( vecdAudioStereo[i + 1] ); } } else { - for ( i = 1; i < iStereoBlockSizeSam; i += 2 ) + if ( bReverbOnLeftChan ) { - // right channel - vecdAudioStereo[i] += - dRevLev * AudioReverb.ProcessSample ( vecdAudioStereo[i] ); + for ( i = 0; i < iStereoBlockSizeSam; i += 2 ) + { + // left channel + vecdAudioStereo[i] += + dRevLev * AudioReverbL.ProcessSample ( vecdAudioStereo[i] ); + } + } + else + { + for ( i = 1; i < iStereoBlockSizeSam; i += 2 ) + { + // right channel + vecdAudioStereo[i] += + dRevLev * AudioReverbR.ProcessSample ( vecdAudioStereo[i] ); + } } } } diff --git a/src/client.h b/src/client.h index 1ff1cdc2..82564975 100755 --- a/src/client.h +++ b/src/client.h @@ -117,7 +117,8 @@ public: void SetReverbOnLeftChan ( const bool bIL ) { bReverbOnLeftChan = bIL; - AudioReverb.Clear(); + AudioReverbL.Clear(); + AudioReverbR.Clear(); } void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; } @@ -251,7 +252,8 @@ protected: int iAudioInFader; bool bReverbOnLeftChan; int iReverbLevel; - CAudioReverb AudioReverb; + CAudioReverb AudioReverbL; + CAudioReverb AudioReverbR; int iSndCrdPrefFrameSizeFactor; int iSndCrdFrameSizeFactor; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 9805965a..b50cfd20 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -600,6 +600,7 @@ void CClientSettingsDlg::OnUseHighQualityAudioStateChanged ( int value ) void CClientSettingsDlg::OnUseStereoStateChanged ( int value ) { pClient->SetUseStereo ( value == Qt::Checked ); + emit StereoCheckBoxChanged(); UpdateDisplay(); // upload rate will be changed } diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index dc6c0f95..92ad1959 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -102,4 +102,5 @@ protected: signals: void GUIDesignChanged(); + void StereoCheckBoxChanged(); }; diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 367f473f..1e1d5d3a 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -254,14 +254,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, // set radio buttons --- // reverb channel - if ( pClient->IsReverbOnLeftChan() ) - { - RadioButtonRevSelL->setChecked ( true ); - } - else - { - RadioButtonRevSelR->setChecked ( true ); - } + RevSelectionButtonGroup.addButton ( RadioButtonRevSelL ); + RevSelectionButtonGroup.addButton ( RadioButtonRevSelR ); + UpdateRevSelection(); // connect on startup --- @@ -340,11 +335,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, this, SLOT ( OnSliderAudReverb ( int ) ) ); // radio buttons - QObject::connect ( RadioButtonRevSelL, SIGNAL ( clicked() ), - this, SLOT ( OnRevSelL() ) ); - - QObject::connect ( RadioButtonRevSelR, SIGNAL ( clicked() ), - this, SLOT ( OnRevSelR() ) ); + QObject::connect ( &RevSelectionButtonGroup, + SIGNAL ( buttonClicked ( QAbstractButton* ) ), this, + SLOT ( OnRevSelectionButtonGroupClicked ( QAbstractButton* ) ) ); // line edits QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ), @@ -376,6 +369,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ), this, SLOT ( OnGUIDesignChanged() ) ); + QObject::connect ( &ClientSettingsDlg, SIGNAL ( StereoCheckBoxChanged() ), + this, SLOT ( OnStereoCheckBoxChanged() ) ); + QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanGain ( int, double ) ), this, SLOT ( OnChangeChanGain ( int, double ) ) ); @@ -446,6 +442,39 @@ void CLlconClientDlg::UpdateAudioFaderSlider() } } +void CLlconClientDlg::UpdateRevSelection() +{ + if ( pClient->GetUseStereo() ) + { + // for stereo set both channels checked and disable all settings + RevSelectionButtonGroup.setExclusive ( false ); + + // to be able to set both checks, exclusive has to be disabled + RadioButtonRevSelL->setChecked ( true ); + RadioButtonRevSelR->setChecked ( true ); + + // enable exclusive again, since this is required for mono mode + RevSelectionButtonGroup.setExclusive ( true ); + + // the user shall not modify the radio buttons in stereo mode + RadioButtonRevSelL->setEnabled ( false ); + RadioButtonRevSelR->setEnabled ( false ); + } + else + { + // mono case, enable all radio buttons and set to current value + RadioButtonRevSelL->setEnabled ( true ); + RadioButtonRevSelR->setEnabled ( true ); + + // first reset and then set correct selection + RadioButtonRevSelL->setChecked ( false ); + RadioButtonRevSelR->setChecked ( false ); + + RadioButtonRevSelL->setChecked ( pClient->IsReverbOnLeftChan() ); + RadioButtonRevSelR->setChecked ( !pClient->IsReverbOnLeftChan() ); + } +} + void CLlconClientDlg::OnSliderAudInFader ( int value ) { pClient->SetAudioInFader ( value ); @@ -535,6 +564,19 @@ void CLlconClientDlg::OnNumClientsChanged ( int iNewNumClients ) SetMyWindowTitle ( iNewNumClients ); } +void CLlconClientDlg::OnRevSelectionButtonGroupClicked ( QAbstractButton* button ) +{ + if ( button == RadioButtonRevSelL ) + { + pClient->SetReverbOnLeftChan ( true ); + } + + if ( button == RadioButtonRevSelR ) + { + pClient->SetReverbOnLeftChan ( false ); + } +} + void CLlconClientDlg::SetMyWindowTitle ( const int iNumClients ) { // show number of connected clients in window title (and therefore also in diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index de7535d3..236fc58f 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include "global.h" @@ -75,27 +76,30 @@ public: QWidget* parent = 0, Qt::WindowFlags f = 0 ); protected: - void SetGUIDesign ( const EGUIDesign eNewDesign ); - void SetMyWindowTitle ( const int iNumClients ); - void ShowChatWindow(); - void UpdateAudioFaderSlider(); - void ConnectDisconnect ( const bool bDoStart ); + void SetGUIDesign ( const EGUIDesign eNewDesign ); + void SetMyWindowTitle ( const int iNumClients ); + void ShowChatWindow(); + void UpdateAudioFaderSlider(); + void UpdateRevSelection(); + void ConnectDisconnect ( const bool bDoStart ); - CClient* pClient; - bool bConnected; - bool bUnreadChatMessage; - QTimer TimerSigMet; - QTimer TimerStatus; + CClient* pClient; + bool bConnected; + bool bUnreadChatMessage; + QTimer TimerSigMet; + QTimer TimerStatus; - virtual void customEvent ( QEvent* Event ); - virtual void closeEvent ( QCloseEvent* Event ); - void UpdateDisplay(); + virtual void customEvent ( QEvent* Event ); + virtual void closeEvent ( QCloseEvent* Event ); + void UpdateDisplay(); - QMenu* pViewMenu; - QMenuBar* pMenu; + QMenu* pViewMenu; + QMenuBar* pMenu; - CClientSettingsDlg ClientSettingsDlg; - CChatDlg ChatDlg; + QButtonGroup RevSelectionButtonGroup; + + CClientSettingsDlg ClientSettingsDlg; + CChatDlg ChatDlg; public slots: void OnConnectDisconBut(); @@ -105,8 +109,7 @@ public slots: void OnOpenChatDialog() { ShowChatWindow(); } void OnSliderAudInFader ( int value ); void OnSliderAudReverb ( int value ) { pClient->SetReverbLevel ( value ); } - void OnRevSelL() { pClient->SetReverbOnLeftChan ( true ); } - void OnRevSelR() { pClient->SetReverbOnLeftChan ( false ); } + void OnRevSelectionButtonGroupClicked ( QAbstractButton* button ); void OnConClientListMesReceived ( CVector vecChanInfo ); void OnChangeChanGain ( int iId, double dGain ) { pClient->SetRemoteChanGain ( iId, dGain ); } @@ -119,5 +122,6 @@ public slots: void OnDisconnected(); void OnStopped(); void OnGUIDesignChanged() { SetGUIDesign ( pClient->GetGUIDesign() ); } + void OnStereoCheckBoxChanged() { UpdateRevSelection(); } void OnNumClientsChanged ( int iNewNumClients ); };