Skip to content

Commit

Permalink
WF latency
Browse files Browse the repository at this point in the history
  * Restore latency adjustment for WF display
  • Loading branch information
David Freese committed Oct 30, 2013
1 parent 665f195 commit 1cca53a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
27 changes: 27 additions & 0 deletions src/dialogs/confdialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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*) {
Expand Down Expand Up @@ -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"));
Expand Down
11 changes: 11 additions & 0 deletions src/dialogs/confdialog.fl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/include/confdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/include/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
11 changes: 8 additions & 3 deletions src/waterfall/waterfall.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*>(wfbuf);
wf_fft_type *pbuf = static_cast<wf_fft_type*>(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);

Expand Down

0 comments on commit 1cca53a

Please sign in to comment.