[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/05: qtgui: corrected errors in qtgui fre
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/05: qtgui: corrected errors in qtgui frequency sink (f and c) sample ordering |
Date: |
Wed, 15 Oct 2014 14:06:03 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 7888bb7bb4f3299e9ca8e15776a89fe5f81a6d07
Author: Michael Ossmann <address@hidden>
Date: Sat Sep 20 20:54:22 2014 -0600
qtgui: corrected errors in qtgui frequency sink (f and c) sample ordering
---
gr-qtgui/lib/freq_sink_c_impl.cc | 34 +++++++++++++++++++---------------
gr-qtgui/lib/freq_sink_c_impl.h | 1 +
gr-qtgui/lib/freq_sink_f_impl.cc | 34 +++++++++++++++++++---------------
gr-qtgui/lib/freq_sink_f_impl.h | 1 +
4 files changed, 40 insertions(+), 30 deletions(-)
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index 11e8fc3..1782b58 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -82,20 +82,22 @@ namespace gr {
// this is usually desired when plotting
d_shift = true;
+ d_outputsize = (2 * (d_fftsize / 2)) + 1;
+
d_fft = new fft::fft_complex(d_fftsize, true);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
+ d_fbuf = (float*)volk_malloc(d_outputsize*sizeof(float),
volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ memset(d_fbuf, 0, d_outputsize*sizeof(float));
d_index = 0;
for(int i = 0; i < d_nconnections; i++) {
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
volk_get_alignment()));
- d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
+ d_magbufs.push_back((double*)volk_malloc(d_outputsize*sizeof(double),
volk_get_alignment()));
memset(d_residbufs[i], 0, d_fftsize*sizeof(gr_complex));
- memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
+ memset(d_magbufs[i], 0, d_outputsize*sizeof(double));
}
buildwindow();
@@ -156,7 +158,7 @@ namespace gr {
d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
set_fft_window(d_wintype);
- set_fft_size(d_fftsize);
+ set_fft_size(d_outputsize);
set_frequency_range(d_center_freq, d_bandwidth);
if(d_name.size() > 0)
@@ -399,10 +401,10 @@ namespace gr {
// Perform shift operation
unsigned int len = (unsigned int)(floor(size/2.0));
- float *tmp = (float*)malloc(sizeof(float)*len);
- memcpy(tmp, &data_out[0], sizeof(float)*len);
- memcpy(&data_out[0], &data_out[len], sizeof(float)*(size - len));
- memcpy(&data_out[size - len], tmp, sizeof(float)*len);
+ float *tmp = (float*)malloc(sizeof(float)*(len + 1));
+ memcpy(tmp, &data_out[0], sizeof(float)*(len + 1));
+ memcpy(&data_out[0], &data_out[size - len], sizeof(float)*(len));
+ memcpy(&data_out[len], tmp, sizeof(float)*(len + 1));
free(tmp);
}
@@ -434,6 +436,7 @@ namespace gr {
gr::thread::scoped_lock lock(d_setlock);
int newfftsize = d_main_gui->getFFTSize();
+ int newoutputsize = (2 * (newfftsize / 2)) + 1;
d_fftavg = d_main_gui->getFFTAverage();
if(newfftsize != d_fftsize) {
@@ -444,16 +447,17 @@ namespace gr {
d_residbufs[i] =
(gr_complex*)volk_malloc(newfftsize*sizeof(gr_complex),
volk_get_alignment());
- d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
+ d_magbufs[i] = (double*)volk_malloc(newoutputsize*sizeof(double),
volk_get_alignment());
memset(d_residbufs[i], 0, newfftsize*sizeof(gr_complex));
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
+ memset(d_magbufs[i], 0, newoutputsize*sizeof(double));
}
// Set new fft size and reset buffer index
// (throws away any currently held data, but who cares?)
d_fftsize = newfftsize;
+ d_outputsize = newoutputsize;
d_index = 0;
// Reset window to reflect new size
@@ -464,9 +468,9 @@ namespace gr {
d_fft = new fft::fft_complex(d_fftsize, true);
volk_free(d_fbuf);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
+ d_fbuf = (float*)volk_malloc(d_outputsize*sizeof(float),
volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ memset(d_fbuf, 0, d_outputsize*sizeof(float));
}
}
@@ -521,7 +525,7 @@ namespace gr {
memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
+ for(int x = 0; x < d_outputsize; x++) {
d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] +
(d_fftavg)*d_fbuf[x]);
}
//volk_32f_convert_64f_a(d_magbufs[n], d_fbuf, d_fftsize);
@@ -529,7 +533,7 @@ namespace gr {
d_last_time = gr::high_res_timer_now();
d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs,
d_fftsize));
+ new FreqUpdateEvent(d_magbufs,
d_outputsize));
}
d_index = 0;
diff --git a/gr-qtgui/lib/freq_sink_c_impl.h b/gr-qtgui/lib/freq_sink_c_impl.h
index dc985c1..0e8f2ce 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.h
+++ b/gr-qtgui/lib/freq_sink_c_impl.h
@@ -40,6 +40,7 @@ namespace gr {
void initialize();
int d_fftsize;
+ int d_outputsize;
float d_fftavg;
filter::firdes::win_type d_wintype;
std::vector<float> d_window;
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index c0a29be..fb98db2 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -82,20 +82,22 @@ namespace gr {
// this is usually desired when plotting
d_shift = true;
+ d_outputsize = (2 * (d_fftsize / 2)) + 1;
+
d_fft = new fft::fft_complex(d_fftsize, true);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
+ d_fbuf = (float*)volk_malloc(d_outputsize*sizeof(float),
volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ memset(d_fbuf, 0, d_outputsize*sizeof(float));
d_index = 0;
for(int i = 0; i < d_nconnections; i++) {
d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
volk_get_alignment()));
- d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
+ d_magbufs.push_back((double*)volk_malloc(d_outputsize*sizeof(double),
volk_get_alignment()));
memset(d_residbufs[i], 0, d_fftsize*sizeof(float));
- memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
+ memset(d_magbufs[i], 0, d_outputsize*sizeof(double));
}
buildwindow();
@@ -156,7 +158,7 @@ namespace gr {
d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
set_fft_window(d_wintype);
- set_fft_size(d_fftsize);
+ set_fft_size(d_outputsize);
set_frequency_range(d_center_freq, d_bandwidth);
if(d_name.size() > 0)
@@ -400,10 +402,10 @@ namespace gr {
// Perform shift operation
unsigned int len = (unsigned int)(floor(size/2.0));
- float *tmp = (float*)malloc(sizeof(float)*len);
- memcpy(tmp, &data_out[0], sizeof(float)*len);
- memcpy(&data_out[0], &data_out[len], sizeof(float)*(size - len));
- memcpy(&data_out[size - len], tmp, sizeof(float)*len);
+ float *tmp = (float*)malloc(sizeof(float)*(len + 1));
+ memcpy(tmp, &data_out[0], sizeof(float)*(len + 1));
+ memcpy(&data_out[0], &data_out[size - len], sizeof(float)*len);
+ memcpy(&data_out[len], tmp, sizeof(float)*(len + 1));
free(tmp);
}
@@ -435,6 +437,7 @@ namespace gr {
gr::thread::scoped_lock lock(d_setlock);
int newfftsize = d_main_gui->getFFTSize();
+ int newoutputsize = (2 * (newfftsize / 2)) + 1;
d_fftavg = d_main_gui->getFFTAverage();
if(newfftsize != d_fftsize) {
@@ -445,16 +448,17 @@ namespace gr {
d_residbufs[i] = (float*)volk_malloc(newfftsize*sizeof(float),
volk_get_alignment());
- d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
+ d_magbufs[i] = (double*)volk_malloc(newoutputsize*sizeof(double),
volk_get_alignment());
memset(d_residbufs[i], 0, newfftsize*sizeof(float));
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
+ memset(d_magbufs[i], 0, newoutputsize*sizeof(double));
}
// Set new fft size and reset buffer index
// (throws away any currently held data, but who cares?)
d_fftsize = newfftsize;
+ d_outputsize = newoutputsize;
d_index = 0;
// Reset window to reflect new size
@@ -465,9 +469,9 @@ namespace gr {
d_fft = new fft::fft_complex(d_fftsize, true);
volk_free(d_fbuf);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
+ d_fbuf = (float*)volk_malloc(d_outputsize*sizeof(float),
volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ memset(d_fbuf, 0, d_outputsize*sizeof(float));
}
}
@@ -522,7 +526,7 @@ namespace gr {
memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*resid);
fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
+ for(int x = 0; x < d_outputsize; x++) {
d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] +
(d_fftavg)*d_fbuf[x]);
}
//volk_32f_convert_64f_a(d_magbufs[n], d_fbuf, d_fftsize);
@@ -530,7 +534,7 @@ namespace gr {
d_last_time = gr::high_res_timer_now();
d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs,
d_fftsize));
+ new FreqUpdateEvent(d_magbufs,
d_outputsize));
}
d_index = 0;
diff --git a/gr-qtgui/lib/freq_sink_f_impl.h b/gr-qtgui/lib/freq_sink_f_impl.h
index 9c4e1e3..f2e82bb 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.h
+++ b/gr-qtgui/lib/freq_sink_f_impl.h
@@ -40,6 +40,7 @@ namespace gr {
void initialize();
int d_fftsize;
+ int d_outputsize;
float d_fftavg;
filter::firdes::win_type d_wintype;
std::vector<float> d_window;