gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size,
float init_phase)
: gr_block ("pfb_clock_sync_ccf",
gr_make_io_signature (1, 1, sizeof(gr_complex)),
gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
const std::vector<float> &taps,
unsigned int filter_size,
float init_phase)
: gr_block ("pfb_clock_sync_ccf",
gr_make_io_signature (1, 1, sizeof(gr_complex)),
- gr_make_io_signature2 (2, 2, sizeof(gr_complex), sizeof(float))),
- d_updated (false), d_sps(sps), d_alpha(gain)
+ gr_make_io_signaturev (1, 4, iosig)),
+ d_updated (false), d_sps(sps)
// The accumulator keeps track of overflow to increment the stride correctly.
// set it here to the fractional difference based on the initial phaes
// assert(init_phase <= 2*M_PI);
// The accumulator keeps track of overflow to increment the stride correctly.
// set it here to the fractional difference based on the initial phaes
// assert(init_phase <= 2*M_PI);
- float x = init_phase / (2*M_PI); //normalize initial phase
- d_acc = x*(d_nfilters-1);
- d_last_filter = (int)floor(d_acc);
- d_acc = fmodf(d_acc, 1);
+ set_alpha(gain);
+ set_beta(0.25*gain*gain);
+ d_k = d_nfilters / 2;
+ d_filtnum = (int)floor(d_k);
+ d_rate = 0;
// Partition the filter
for(i = 0; i < d_nfilters; i++) {
// Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out
// Partition the filter
for(i = 0; i < d_nfilters; i++) {
// Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out
- ourtaps[i] = std::vector<float>(d_taps_per_filter, 0);
+ //ourtaps[i] = std::vector<float>(d_taps_per_filter, 0);
+ ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0);
gr_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps,
std::vector<float> &difftaps)
{
gr_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps,
std::vector<float> &difftaps)
{
for(j = 1; j < d_taps_per_filter-1; j++) {
printf("%.4e,", d_taps[i][j]);
}
for(j = 1; j < d_taps_per_filter-1; j++) {
printf("%.4e,", d_taps[i][j]);
}
for(j = 1; j < d_taps_per_filter-1; j++) {
printf("%.4e,", d_dtaps[i][j]);
}
for(j = 1; j < d_taps_per_filter-1; j++) {
printf("%.4e,", d_dtaps[i][j]);
}
- float *err = (float *) output_items[1];
+
+ float *err, *outrate, *outk;
+ if(output_items.size() > 2) {
+ err = (float *) output_items[1];
+ outrate = (float*)output_items[2];
+ outk = (float*)output_items[3];
+ }
int nrequired = ninput_items[0] - d_taps_per_filter;
int i = 0, count = d_start_count;
int nrequired = ninput_items[0] - d_taps_per_filter;
int i = 0, count = d_start_count;
// produce output as long as we can and there are enough input samples
while((i < noutput_items) && (count < nrequired)) {
// produce output as long as we can and there are enough input samples
while((i < noutput_items) && (count < nrequired)) {
- d_acc += d_alpha*error;
- gr_branchless_clip(d_acc, 1);
+ // FIXME: prevent this from asserting
+ assert(d_filtnum < d_nfilters);
+ out[i] = d_filters[d_filtnum]->filter(&in[count]);
+ error_r = out[i].real() * d_diff_filters[d_filtnum]->filter(&in[count]).real();
+ error_i = out[i].imag() * d_diff_filters[d_filtnum]->filter(&in[count]).imag();
+ error = error_i + error_r;
- int newfilter;
- newfilter = (int)((float)d_last_filter + d_acc);
- if(newfilter != (int)d_last_filter)
- d_acc = 0.5;
+ d_k = d_k + d_alpha*error + d_rate;
+ d_rate = d_rate + d_beta*error;
+ d_filtnum = (int)floor(d_k);