From a0318d3a0a8f7cade781d40bc3f852af03a5149c Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 23 Feb 2016 19:37:38 +0000 Subject: [PATCH] Calibration of the "Degrade S/N of .wav file" requires knowledge of receiver bandwidth. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6491 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.cpp | 6 ++++++ Configuration.hpp | 1 + Configuration.ui | 39 +++++++++++++++++++++++++++++++++++---- lib/degrade_snr.f90 | 7 +++++-- mainwindow.cpp | 5 +++-- 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index f539759a5..312eea7fb 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -524,6 +524,7 @@ private: qint32 id_interval_; qint32 ntrials_; qint32 aggressive_; + qint32 RxBandwidth_; double degrade_; bool id_after_73_; bool tx_QSY_allowed_; @@ -606,6 +607,7 @@ qint32 Configuration::id_interval () const {return m_->id_interval_;} qint32 Configuration::ntrials() const {return m_->ntrials_;} qint32 Configuration::aggressive() const {return m_->aggressive_;} double Configuration::degrade() const {return m_->degrade_;} +qint32 Configuration::RxBandwidth() const {return m_->RxBandwidth_;} bool Configuration::id_after_73 () const {return m_->id_after_73_;} bool Configuration::tx_QSY_allowed () const {return m_->tx_QSY_allowed_;} bool Configuration::spot_to_psk_reporter () const {return m_->spot_to_psk_reporter_;} @@ -1051,6 +1053,7 @@ void Configuration::impl::initialize_models () ui_->sbNtrials->setValue (ntrials_); ui_->sbAggressive->setValue (aggressive_); ui_->sbDegrade->setValue (degrade_); + ui_->sbBandwidth->setValue (RxBandwidth_); ui_->PTT_method_button_group->button (rig_params_.ptt_type)->setChecked (true); ui_->save_path_display_label->setText (save_directory_.absolutePath ()); ui_->azel_path_display_label->setText (azel_directory_.absolutePath ()); @@ -1181,6 +1184,7 @@ void Configuration::impl::read_settings () id_interval_ = settings_->value ("IDint", 0).toInt (); ntrials_ = settings_->value ("nTrials", 6).toInt (); aggressive_ = settings_->value ("Aggressive", 0).toInt (); + RxBandwidth_ = settings_->value ("RxBandwidth", 2500).toInt (); save_directory_ = settings_->value ("SaveDir", default_save_directory_.absolutePath ()).toString (); azel_directory_ = settings_->value ("AzElDir", default_azel_directory_.absolutePath ()).toString (); @@ -1335,6 +1339,7 @@ void Configuration::impl::write_settings () settings_->setValue ("IDint", id_interval_); settings_->setValue ("nTrials", ntrials_); settings_->setValue ("Aggressive", aggressive_); + settings_->setValue ("RxBandwidth", RxBandwidth_); settings_->setValue ("PTTMethod", QVariant::fromValue (rig_params_.ptt_type)); settings_->setValue ("PTTport", rig_params_.ptt_port); settings_->setValue ("SaveDir", save_directory_.absolutePath ()); @@ -1768,6 +1773,7 @@ void Configuration::impl::accept () ntrials_ = ui_->sbNtrials->value (); aggressive_ = ui_->sbAggressive->value (); degrade_ = ui_->sbDegrade->value (); + RxBandwidth_ = ui_->sbBandwidth->value (); id_after_73_ = ui_->CW_id_after_73_check_box->isChecked (); tx_QSY_allowed_ = ui_->tx_QSY_check_box->isChecked (); monitor_off_at_startup_ = ui_->monitor_off_check_box->isChecked (); diff --git a/Configuration.hpp b/Configuration.hpp index b011d5cf5..68ac18160 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -93,6 +93,7 @@ public: qint32 id_interval () const; qint32 ntrials() const; qint32 aggressive() const; + qint32 RxBandwidth() const; double degrade() const; bool id_after_73 () const; bool tx_QSY_allowed () const; diff --git a/Configuration.ui b/Configuration.ui index 1155cb92b..b34ca57be 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -2,6 +2,14 @@ configuration_dialog + + + 0 + 0 + 545 + 614 + + Settings @@ -2296,6 +2304,29 @@ Right click for insert and delete options. + + + + Receiver bandwidth: + + + + + + + Hz + + + 6000 + + + 100 + + + 2500 + + + @@ -2496,12 +2527,12 @@ soundcard changes - - + - + + - + diff --git a/lib/degrade_snr.f90 b/lib/degrade_snr.f90 index 8e6efb35a..b6cbf786d 100644 --- a/lib/degrade_snr.f90 +++ b/lib/degrade_snr.f90 @@ -1,10 +1,11 @@ -subroutine degrade_snr(d2,npts,db) +subroutine degrade_snr(d2,npts,db,bw) integer*2 d2(npts) real dat(60*12000) dat(1:npts)=d2 p0=dot_product(dat(1:npts),dat(1:npts))/npts + if(bw.gt.0.0) p0=p0*6000.0/bw s=sqrt(p0*(10.0**(0.1*db) - 1.0)) do i=1,npts d2(i)=nint(dat(i) + s*gran()) @@ -12,7 +13,9 @@ subroutine degrade_snr(d2,npts,db) ! dat(1:npts)=d2 ! p1=dot_product(dat(1:npts),dat(1:npts))/npts -! print*,db,p0,s,10.0*log10(p1/p0) +! if(bw.gt.0.0) p1=p1*6000.0/bw +! write(*,3001) db,bw,p0,s,10.0*log10(p1/p0) +!3001 format(5f10.3) return end subroutine degrade_snr diff --git a/mainwindow.cpp b/mainwindow.cpp index ddcad7901..75dafb7e1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -98,7 +98,7 @@ extern "C" { void fast_decode_(short id2[], int narg[], char msg[], int len); void hash_calls_(char calls[], int* ih9, int len); - void degrade_snr_(short d2[], int* n, float* db); + void degrade_snr_(short d2[], int* n, float* db, float* bandwidth); void wav12_(short d2[], short d1[], int* nbytes, short* nbitsam2); } @@ -1662,7 +1662,8 @@ void MainWindow::diskDat() //diskDat() m_diskData=true; float db=m_config.degrade(); - if(db > 0.0) degrade_snr_(dec_data.d2,&dec_data.params.kin,&db); + float bw=m_config.RxBandwidth(); + if(db > 0.0) degrade_snr_(dec_data.d2,&dec_data.params.kin,&db,&bw); for(int n=1; n<=m_hsymStop; n++) { // Do the waterfall spectra k=(n+1)*kstep;