Skip to content

Commit b3b8a1f

Browse files
committed
filter: fixed issue with resampler using buffer size information (always a mistake).
The intent was to ask the scheduler for the maximum amount of data. Now, it plays it safe by asking for just enough the next time. Performance tests show it works well.
1 parent 756b9bb commit b3b8a1f

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

gr-filter/lib/pfb_arb_resampler_ccf_impl.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace gr {
6767
unsigned ninputs = ninput_items_required.size();
6868
if(noutput_items / relative_rate() < 1) {
6969
for(unsigned i = 0; i < ninputs; i++)
70-
ninput_items_required[i] = max_output_buffer(i)-1;
70+
ninput_items_required[i] = relative_rate() + history() - 1;
7171
}
7272
else {
7373
for(unsigned i = 0; i < ninputs; i++)

gr-filter/python/filter/qa_pfb_arb_resampler.py

+39-2
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,52 @@ def test_ccf_000(self):
9595
snk = blocks.vector_sink_c()
9696

9797
self.tb.connect(signal, pfb, snk)
98-
self.tb.run()
98+
self.tb.run()
9999

100100
Ntest = 50
101101
L = len(snk.data())
102102

103103
# Get group delay and estimate of phase offset from the filter itself.
104104
delay = pfb.group_delay()
105105
phase = pfb.phase_offset(freq, fs)
106-
106+
107+
# Create a timeline offset by the filter's group delay
108+
t = map(lambda x: float(x)/(fs*rrate), xrange(delay, L+delay))
109+
110+
# Data of the sinusoid at frequency freq with the delay and phase offset.
111+
expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
112+
1j*math.sin(2.*math.pi*freq*x+phase), t)
113+
114+
dst_data = snk.data()
115+
116+
self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 2)
117+
118+
def test_ccf_001(self):
119+
N = 50000 # number of samples to use
120+
fs = 5000.0 # baseband sampling rate
121+
rrate = 0.75 # resampling rate
122+
123+
nfilts = 32
124+
taps = filter.firdes.low_pass_2(nfilts, nfilts*fs, fs/4, fs/10,
125+
attenuation_dB=80,
126+
window=filter.firdes.WIN_BLACKMAN_hARRIS)
127+
128+
freq = 211.123
129+
data = sig_source_c(fs, freq, 1, N)
130+
signal = blocks.vector_source_c(data)
131+
pfb = filter.pfb_arb_resampler_ccf(rrate, taps, nfilts)
132+
snk = blocks.vector_sink_c()
133+
134+
self.tb.connect(signal, pfb, snk)
135+
self.tb.run()
136+
137+
Ntest = 50
138+
L = len(snk.data())
139+
140+
# Get group delay and estimate of phase offset from the filter itself.
141+
delay = pfb.group_delay()
142+
phase = pfb.phase_offset(freq, fs)
143+
107144
# Create a timeline offset by the filter's group delay
108145
t = map(lambda x: float(x)/(fs*rrate), xrange(delay, L+delay))
109146

0 commit comments

Comments
 (0)