summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorTom2009-10-09 11:10:15 -0700
committerTom2009-10-09 11:10:15 -0700
commit80841156673ff0e7eff376bceeeac9119f0e9493 (patch)
treec68a01490ab86b58f2b1233d48c6a1e35d7ad9a4 /gnuradio-core/src
parent90b8b4cc8c53c963f8b0cf4bbc50277c031c3213 (diff)
downloadgnuradio-80841156673ff0e7eff376bceeeac9119f0e9493.tar.gz
gnuradio-80841156673ff0e7eff376bceeeac9119f0e9493.tar.bz2
gnuradio-80841156673ff0e7eff376bceeeac9119f0e9493.zip
wip
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc29
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h10
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i4
3 files changed, 25 insertions, 18 deletions
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc
index a75b20d38..08ab949d0 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc
@@ -33,7 +33,7 @@
#include <gr_io_signature.h>
#include <gr_math.h>
-gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size,
float init_phase,
@@ -47,7 +47,7 @@ gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)};
std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
-gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (double sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size,
float init_phase,
@@ -58,6 +58,7 @@ gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
d_updated (false), d_sps(sps), d_nfilters(filter_size),
d_max_dev(max_rate_deviation), d_start_count(0)
{
+ printf("SPS: %f\n", d_sps);
d_nfilters = filter_size;
// Store the last filter between calls to work
@@ -240,14 +241,6 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items,
// produce output as long as we can and there are enough input samples
while((i < noutput_items) && (count < nrequired)) {
- out[i] = d_filters[d_filtnum]->filter(&in[count]);
- gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]);
- error_r = out[i].real() * diff.real();
- error_i = out[i].imag() * diff.imag();
- error = error_i + error_r;
-
- d_k = d_k + d_alpha*error + d_rate;
- d_rate = d_rate + d_beta*error;
d_filtnum = (int)floor(d_k);
// Keep the current filter number in [0, d_nfilters]
@@ -264,18 +257,32 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items,
d_sample_num -= 1.0;
}
+ out[i] = d_filters[d_filtnum]->filter(&in[count]);
+ gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]);
+ error_r = out[i].real() * diff.real();
+ error_i = out[i].imag() * diff.imag();
+ error = error_i + error_r;
+
+ d_k = d_k + d_alpha*error + d_rate;
+ d_rate = d_rate + d_beta*error;
+
// Keep our rate within a good range
d_rate = gr_branchless_clip(d_rate, d_max_dev);
i++;
+ int a = (int)floor(d_sample_num);
d_sample_num += d_sps;
+ int b = a + (int)floor(d_sps);
count = (int)floor(d_sample_num);
if(output_items.size() > 2) {
err[i] = error;
- outrate[i] = d_rate;
outk[i] = d_k;
}
+ if(b != count) {
+ outrate[i] = 1;
+ }
+
}
// Set the start index at the next entrance to the work function
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
index 84e174b19..73bd7d6e6 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
@@ -28,7 +28,7 @@
class gr_pfb_clock_sync_ccf;
typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr;
-gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size=32,
float init_phase=0,
@@ -51,17 +51,17 @@ class gr_pfb_clock_sync_ccf : public gr_block
/*!
* Build the polyphase filterbank timing synchronizer.
*/
- friend gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+ friend gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size,
float init_phase,
float max_rate_deviation);
bool d_updated;
- float d_sps;
+ double d_sps;
+ double d_sample_num;
float d_alpha;
float d_beta;
- float d_sample_num;
int d_nfilters;
std::vector<gr_fir_ccf*> d_filters;
std::vector<gr_fir_ccf*> d_diff_filters;
@@ -77,7 +77,7 @@ class gr_pfb_clock_sync_ccf : public gr_block
/*!
* Build the polyphase filterbank timing synchronizer.
*/
- gr_pfb_clock_sync_ccf (float sps, float gain,
+ gr_pfb_clock_sync_ccf (double sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size,
float init_phase,
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
index 9957c33b7..197984287 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
@@ -22,7 +22,7 @@
GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_ccf);
-gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size=32,
float init_phase=0,
@@ -31,7 +31,7 @@ gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
class gr_pfb_clock_sync_ccf : public gr_block
{
private:
- gr_pfb_clock_sync_ccf (float sps, float gain,
+ gr_pfb_clock_sync_ccf (double sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size,
float init_phase,