From a06bf93546b06d1df9df4c131db5308496e755ce Mon Sep 17 00:00:00 2001 From: David Freese Date: Fri, 22 Jan 2010 16:43:46 -0600 Subject: [PATCH] S/N evaluators RTTY - added s/n evaluator, decreased metric sensitivity - changed b/w indicator to agree with b/w config slider DOMEX - corrected s/n evaluator. --- src/cw_rtty/rtty.cxx | 37 +++++++++++++++++++++++-------------- src/dominoex/dominoex.cxx | 7 ++++++- src/waterfall/waterfall.cxx | 4 ++-- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/cw_rtty/rtty.cxx b/src/cw_rtty/rtty.cxx index 02db29a6..b158403d 100644 --- a/src/cw_rtty/rtty.cxx +++ b/src/cw_rtty/rtty.cxx @@ -164,22 +164,22 @@ void rtty::restart() symbollen = (int) (samplerate / rtty_baud + 0.5); set_bandwidth(shift); - rtty_BW = 0.75 * rtty_baud; + rtty_BW = 1.5 * rtty_baud; progdefaults.RTTY_BW = rtty_BW; sldrRTTYbandwidth->value(rtty_BW); wf->redraw_marker(); - bp_filt_lo = (shift/2.0 - rtty_BW) / samplerate; + bp_filt_lo = (shift/2.0 - rtty_BW/2.0) / samplerate; if (bp_filt_lo < 0) bp_filt_lo = 0; - bp_filt_hi = (shift/2.0 + rtty_BW) / samplerate; + bp_filt_hi = (shift/2.0 + rtty_BW/2.0) / samplerate; if (bpfilt) bpfilt->create_filter(bp_filt_lo, bp_filt_hi); else bpfilt = new fftfilt(bp_filt_lo, bp_filt_hi, 1024); - bflen = symbollen/2; + bflen = symbollen/3;///2; if (bitfilt) bitfilt->setLength(bflen); else @@ -408,16 +408,25 @@ int rtty::rx(bool bit) return flag; } +char snrmsg[80]; void rtty::Metric() { - double delta = rtty_baud/4.0; - noisepwr = wf->powerDensity(frequency - shift * 1.5, delta) + - wf->powerDensity(frequency + shift * 1.5, delta) + 1e-10; - sigpwr = wf->powerDensity(frequency - shift/2, delta) + - wf->powerDensity(frequency + shift/2, delta) + 1e-10; - double snr = sigpwr / noisepwr; - metric = decayavg( metric, snr, 8);//16); - metric = CLAMP(metric, 0.0, 100.0); + double delta = rtty_baud/2.0; + double np = + wf->powerDensity(frequency - shift * 1.5, delta) + + wf->powerDensity(frequency + shift * 1.5, delta) + 1e-10; + double sp = + wf->powerDensity(frequency - shift/2, delta) + + wf->powerDensity(frequency + shift/2, delta) + 1e-10; + double snr = 0; + + sigpwr = decayavg( sigpwr, sp, sp - sigpwr > 0 ? 4 : 16); + noisepwr = decayavg( noisepwr, np, 64 ); + snr = 10*log10(sigpwr / ( noisepwr * (2400 / (2*delta)))); + + snprintf(snrmsg, sizeof(snrmsg), "s/n %3.0f dB", snr); + put_Status1(snrmsg); + metric = CLAMP(4 * sigpwr/noisepwr, 0.0, 100.0); display_metric(metric); } @@ -472,9 +481,9 @@ int rtty::rx_process(const double *buf, int len) if (progdefaults.RTTY_BW != rtty_BW) { rtty_BW = progdefaults.RTTY_BW; - bp_filt_lo = (shift/2.0 - rtty_BW) / samplerate; + bp_filt_lo = (shift/2.0 - rtty_BW/2.0) / samplerate; if (bp_filt_lo < 0) bp_filt_lo = 0; - bp_filt_hi = (shift/2.0 + rtty_BW) / samplerate; + bp_filt_hi = (shift/2.0 + rtty_BW/2.0) / samplerate; bpfilt->create_filter(bp_filt_lo, bp_filt_hi); wf->redraw_marker(); } diff --git a/src/dominoex/dominoex.cxx b/src/dominoex/dominoex.cxx index 607bf7d3..712cf4a8 100644 --- a/src/dominoex/dominoex.cxx +++ b/src/dominoex/dominoex.cxx @@ -520,7 +520,12 @@ void dominoex::eval_s2n() else s2n = 0; - metric = 4 * s2n; +// metric = 4 * s2n; + // To partially offset the increase of noise by (THORNUMTONES -1) + // in the noise calculation above, + // add 15*log10(THORNUMTONES -1) = 18.4, and multiply by 6 + metric = 6 * (s2n + 18.4); + metric = metric < 0 ? 0 : metric > 100 ? 100 : metric; display_metric(metric); diff --git a/src/waterfall/waterfall.cxx b/src/waterfall/waterfall.cxx index 21368a4b..858e023f 100644 --- a/src/waterfall/waterfall.cxx +++ b/src/waterfall/waterfall.cxx @@ -203,8 +203,8 @@ inline void WFdisp::makeMarker_(int width, const RGB* color, int freq, const RGB if (active_modem->get_mode() == MODE_RTTY) { // rtty has two bandwidth indicators on the waterfall // upper and lower frequency - int bw_limit_hi = (int)((_SHIFT[progdefaults.rtty_shift]/2 + progdefaults.RTTY_BW)); - int bw_limit_lo = (int)((_SHIFT[progdefaults.rtty_shift]/2 - progdefaults.RTTY_BW)); + int bw_limit_hi = (int)((_SHIFT[progdefaults.rtty_shift]/2 + progdefaults.RTTY_BW / 2.0)); + int bw_limit_lo = (int)((_SHIFT[progdefaults.rtty_shift]/2 - progdefaults.RTTY_BW / 2.0)); int bw_freq = static_cast(freq + 0.5); int bw_lower1 = -bw_limit_hi; int bw_upper1 = -bw_limit_lo;