Skip to content

Commit 65dbd67

Browse files
committed
filter: fixing having the delay of the resampler as a negative number, which I think I backed into from making the other computations work.
1 parent a2107f7 commit 65dbd67

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

gr-filter/lib/pfb_arb_resampler.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ namespace gr {
6969

7070
// Delay is based on number of taps per filter arm. Round to
7171
// the nearest integer.
72-
float delay = -rate * (taps_per_filter() - 1.0) / 2.0;
72+
float delay = rate * (taps_per_filter() - 1.0) / 2.0;
7373
d_delay = static_cast<int>(boost::math::iround(delay));
7474

7575
// This calculation finds the phase offset induced by the
7676
// arbitrary resampling. It's based on which filter arm we are
7777
// at the filter's group delay plus the fractional offset
7878
// between the samples. Calculated here based on the rotation
7979
// around nfilts starting at start_filter.
80-
float accum = -d_delay * d_flt_rate;
80+
float accum = d_delay * d_flt_rate;
8181
int accum_int = static_cast<int>(accum);
8282
float accum_frac = accum - accum_int;
8383
int end_filter = static_cast<int>
84-
(boost::math::iround(fmodf(d_last_filter - d_delay * d_dec_rate + accum_int, \
84+
(boost::math::iround(fmodf(d_last_filter + d_delay * d_dec_rate + accum_int, \
8585
static_cast<float>(d_int_rate))));
8686

8787
d_est_phase_change = d_last_filter - (end_filter + accum_frac);
@@ -280,19 +280,19 @@ namespace gr {
280280

281281
// Delay is based on number of taps per filter arm. Round to
282282
// the nearest integer.
283-
float delay = -rate * (taps_per_filter() - 1.0) / 2.0;
283+
float delay = rate * (taps_per_filter() - 1.0) / 2.0;
284284
d_delay = static_cast<int>(boost::math::iround(delay));
285285

286286
// This calculation finds the phase offset induced by the
287287
// arbitrary resampling. It's based on which filter arm we are
288288
// at the filter's group delay plus the fractional offset
289289
// between the samples. Calculated here based on the rotation
290290
// around nfilts starting at start_filter.
291-
float accum = -d_delay * d_flt_rate;
291+
float accum = d_delay * d_flt_rate;
292292
int accum_int = static_cast<int>(accum);
293293
float accum_frac = accum - accum_int;
294294
int end_filter = static_cast<int>
295-
(boost::math::iround(fmodf(d_last_filter - d_delay * d_dec_rate + accum_int, \
295+
(boost::math::iround(fmodf(d_last_filter + d_delay * d_dec_rate + accum_int, \
296296
static_cast<float>(d_int_rate))));
297297

298298
d_est_phase_change = d_last_filter - (end_filter + accum_frac);
@@ -491,19 +491,19 @@ namespace gr {
491491

492492
// Delay is based on number of taps per filter arm. Round to
493493
// the nearest integer.
494-
float delay = -rate * (taps_per_filter() - 1.0) / 2.0;
494+
float delay = rate * (taps_per_filter() - 1.0) / 2.0;
495495
d_delay = static_cast<int>(boost::math::iround(delay));
496496

497497
// This calculation finds the phase offset induced by the
498498
// arbitrary resampling. It's based on which filter arm we are
499499
// at the filter's group delay plus the fractional offset
500500
// between the samples. Calculated here based on the rotation
501501
// around nfilts starting at start_filter.
502-
float accum = -d_delay * d_flt_rate;
502+
float accum = d_delay * d_flt_rate;
503503
int accum_int = static_cast<int>(accum);
504504
float accum_frac = accum - accum_int;
505505
int end_filter = static_cast<int>
506-
(boost::math::iround(fmodf(d_last_filter - d_delay * d_dec_rate + accum_int, \
506+
(boost::math::iround(fmodf(d_last_filter + d_delay * d_dec_rate + accum_int, \
507507
static_cast<float>(d_int_rate))));
508508

509509
d_est_phase_change = d_last_filter - (end_filter + accum_frac);

gr-filter/python/filter/qa_pfb_arb_resampler.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_fff_000(self):
6969
phase = pfb.phase_offset(freq, fs)
7070

7171
# Create a timeline offset by the filter's group delay
72-
t = map(lambda x: float(x)/(fs*rrate), xrange(delay, L+delay))
72+
t = map(lambda x: float(x)/(fs*rrate), xrange(-delay, L-delay))
7373

7474
# Data of the sinusoid at frequency freq with the delay and phase offset.
7575
expected_data = map(lambda x: math.sin(2.*math.pi*freq*x+phase), t)
@@ -105,7 +105,7 @@ def test_ccf_000(self):
105105
phase = pfb.phase_offset(freq, fs)
106106

107107
# Create a timeline offset by the filter's group delay
108-
t = map(lambda x: float(x)/(fs*rrate), xrange(delay, L+delay))
108+
t = map(lambda x: float(x)/(fs*rrate), xrange(-delay, L-delay))
109109

110110
# Data of the sinusoid at frequency freq with the delay and phase offset.
111111
expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
@@ -142,7 +142,7 @@ def test_ccf_001(self):
142142
phase = pfb.phase_offset(freq, fs)
143143

144144
# Create a timeline offset by the filter's group delay
145-
t = map(lambda x: float(x)/(fs*rrate), xrange(delay, L+delay))
145+
t = map(lambda x: float(x)/(fs*rrate), xrange(-delay, L-delay))
146146

147147
# Data of the sinusoid at frequency freq with the delay and phase offset.
148148
expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
@@ -179,7 +179,7 @@ def test_ccc_000(self):
179179
phase = pfb.phase_offset(freq, fs)
180180

181181
# Create a timeline offset by the filter's group delay
182-
t = map(lambda x: float(x)/(fs*rrate), xrange(delay, L+delay))
182+
t = map(lambda x: float(x)/(fs*rrate), xrange(-delay, L-delay))
183183

184184
# Data of the sinusoid at frequency freq with the delay and phase offset.
185185
expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
@@ -216,7 +216,7 @@ def test_ccc_001(self):
216216
phase = pfb.phase_offset(freq, fs)
217217

218218
# Create a timeline offset by the filter's group delay
219-
t = map(lambda x: float(x)/(fs*rrate), xrange(delay, L+delay))
219+
t = map(lambda x: float(x)/(fs*rrate), xrange(-delay, L-delay))
220220

221221
# Data of the sinusoid at frequency freq with the delay and phase offset.
222222
expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \

0 commit comments

Comments
 (0)