From 1cca53ad6e53745c9b0a6d5945f1fafe958096c1 Mon Sep 17 00:00:00 2001 From: David Freese Date: Wed, 30 Oct 2013 07:21:19 -0500 Subject: [PATCH] WF latency * Restore latency adjustment for WF display --- src/dialogs/confdialog.cxx | 27 +++++++++++++++++++++++++++ src/dialogs/confdialog.fl | 11 +++++++++++ src/include/confdialog.h | 1 + src/include/configuration.h | 3 +++ src/waterfall/waterfall.cxx | 11 ++++++++--- 5 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/dialogs/confdialog.cxx b/src/dialogs/confdialog.cxx index ce363334..138892f0 100644 --- a/src/dialogs/confdialog.cxx +++ b/src/dialogs/confdialog.cxx @@ -2036,6 +2036,13 @@ progdefaults.changed = true; setwfrange(); } +Fl_Counter2 *wf_latency=(Fl_Counter2 *)0; + +static void cb_wf_latency(Fl_Counter2* o, void*) { + progdefaults.wf_latency = (int)o->value(); +progdefaults.changed = true; +} + Fl_Counter2 *cntrWfheight=(Fl_Counter2 *)0; static void cb_cntrWfheight(Fl_Counter2* o, void*) { @@ -6308,6 +6315,26 @@ ab and newline are automatically included.")); o->value(progdefaults.HighFreqCutoff); o->labelsize(FL_NORMAL_SIZE); } // Fl_Counter2* cntrWfwidth + { Fl_Counter2* o = wf_latency = new Fl_Counter2(295, 124, 95, 22, _("Latency")); + wf_latency->tooltip(_("Signal averaging over time\n0 - least\n4 - greatest")); + wf_latency->type(1); + wf_latency->box(FL_UP_BOX); + wf_latency->color(FL_BACKGROUND_COLOR); + wf_latency->selection_color(FL_INACTIVE_COLOR); + wf_latency->labeltype(FL_NORMAL_LABEL); + wf_latency->labelfont(0); + wf_latency->labelsize(14); + wf_latency->labelcolor(FL_FOREGROUND_COLOR); + wf_latency->minimum(1); + wf_latency->maximum(16); + wf_latency->step(1); + wf_latency->value(8); + wf_latency->callback((Fl_Callback*)cb_wf_latency); + wf_latency->align(Fl_Align(FL_ALIGN_RIGHT)); + wf_latency->when(FL_WHEN_CHANGED); + o->value(progdefaults.wf_latency); + o->labelsize(FL_NORMAL_SIZE); + } // Fl_Counter2* wf_latency o->end(); } // Fl_Group* o { Fl_Group* o = new Fl_Group(27, 221, 490, 80, _("Changes take effect on next program startup")); diff --git a/src/dialogs/confdialog.fl b/src/dialogs/confdialog.fl index 8b50e478..d3ccfca8 100644 --- a/src/dialogs/confdialog.fl +++ b/src/dialogs/confdialog.fl @@ -2438,6 +2438,17 @@ setwfrange();} code1 {o->labelsize(FL_NORMAL_SIZE);} class Fl_Counter2 } + Fl_Counter wf_latency { + label Latency + callback {progdefaults.wf_latency = (int)o->value(); +progdefaults.changed = true;} + tooltip {Signal averaging over time +0 - least +4 - greatest} xywh {295 124 95 22} type Simple align 8 minimum 1 maximum 16 step 1 value 8 + code0 {o->value(progdefaults.wf_latency);} + code1 {o->labelsize(FL_NORMAL_SIZE);} + class Fl_Counter2 + } } Fl_Group {} { label {Changes take effect on next program startup} open diff --git a/src/include/confdialog.h b/src/include/confdialog.h index a3d18949..05c48f1a 100644 --- a/src/include/confdialog.h +++ b/src/include/confdialog.h @@ -229,6 +229,7 @@ extern Fl_Counter2 *cntLowFreqCutoff; extern Fl_Check_Button *btnWFaveraging; extern Fl_Choice *mnuFFTPrefilter; extern Fl_Counter2 *cntrWfwidth; +extern Fl_Counter2 *wf_latency; extern Fl_Counter2 *cntrWfheight; extern Fl_Check_Button *btnWaterfallHistoryDefault; extern Fl_Check_Button *btnWaterfallQSY; diff --git a/src/include/configuration.h b/src/include/configuration.h index 11cd4d26..4b4f38b5 100644 --- a/src/include/configuration.h +++ b/src/include/configuration.h @@ -639,6 +639,9 @@ ELEM_(bool, WFaveraging, "WFAVERAGING", \ "Use FFT averaging to decrease waterfall noise", \ false) \ + ELEM_(int, wf_latency, "WF_LATENCY", \ + "Waterfal latency, 1...16", \ + 8) \ ELEM_(bool, UseCursorLines, "USECURSORLINES", \ "Draw cursor with vertical lines", \ true) \ diff --git a/src/waterfall/waterfall.cxx b/src/waterfall/waterfall.cxx index 7a083c4d..dabecd31 100644 --- a/src/waterfall/waterfall.cxx +++ b/src/waterfall/waterfall.cxx @@ -503,14 +503,19 @@ void WFdisp::processFFT() { if (--dispcnt == 0) { static const int log2disp100 = log2disp(-100); - static const double vscale = 2.0 / FFT_LEN; + double vscale = 2.0 / FFT_LEN; memset(wfbuf, 0, FFT_LEN * sizeof(*wfbuf)); void *pv = static_cast(wfbuf); wf_fft_type *pbuf = static_cast(pv); - for (int i = 0; i < FFT_LEN; i++) - pbuf[i] = fftwindow[i] * circbuff[i] * vscale; + int latency = progdefaults.wf_latency; + if (latency < 1) latency = 1; + if (latency > 16) latency = 16; + int nsamples = FFT_LEN * latency / 16; + vscale *= sqrt(16.0 / latency); + for (int i = 0; i < nsamples; i++) + pbuf[i] = fftwindow[i * 16 / latency] * circbuff[i] * vscale; wfft->RealFFT(wfbuf);