From: Ramakrishnan Muthukrishnan Date: Sun, 30 Jul 2023 08:42:49 +0000 (+0530) Subject: read vfo frequency only once per waterfall rendering X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/bcase//%22%22.?a=commitdiff_plain;h=cb5e73f665523a1847a8b4d70c7d43d2dfa84a95;p=pihpsdr.git read vfo frequency only once per waterfall rendering --- diff --git a/waterfall.c b/waterfall.c index f17224b..58d883d 100644 --- a/waterfall.c +++ b/waterfall.c @@ -121,14 +121,15 @@ void waterfall_update(RECEIVER *rx) { int rowstride = gdk_pixbuf_get_rowstride(rx->pixbuf); hz_per_pixel = (double)rx->sample_rate / (double)display_width; + int vfo_freq = vfo[rx->id].frequency; if (rx->waterfall_frequency != 0 && (rx->sample_rate == rx->waterfall_sample_rate)) { - if (rx->waterfall_frequency != vfo[rx->id].frequency) { + if (rx->waterfall_frequency != vfo_freq) { // scrolled or band change long long half = (long long)(rx->sample_rate / 2); - if (rx->waterfall_frequency < (vfo[rx->id].frequency - half) || - rx->waterfall_frequency > (vfo[rx->id].frequency + half)) { + if (rx->waterfall_frequency < (vfo_freq - half) || + rx->waterfall_frequency > (vfo_freq + half)) { // outside of the range - blank waterfall // fprintf(stderr,"waterfall_update: clear waterfall from // %lld to @@ -137,7 +138,7 @@ void waterfall_update(RECEIVER *rx) { } else { // rotate waterfall int rotate_pixels = (int)((double)(rx->waterfall_frequency - - vfo[rx->id].frequency) / + vfo_freq) / hz_per_pixel); // fprintf(stderr,"waterfall_update: rotate waterfall from // %lld to %lld @@ -174,7 +175,7 @@ void waterfall_update(RECEIVER *rx) { memset(pixels, 0, display_width * display_height * 3); } - rx->waterfall_frequency = vfo[rx->id].frequency; + rx->waterfall_frequency = vfo_freq; rx->waterfall_sample_rate = rx->sample_rate; memmove(&pixels[rowstride], pixels, (height - 1) * rowstride);