1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
|
/* -*- c++ -*- */
/*
* Copyright (C) 2017 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_DIGITAL_INTERPOLATING_RESAMPLER_H
#define INCLUDED_DIGITAL_INTERPOLATING_RESAMPLER_H
#include <gnuradio/gr_complex.h>
#include <gnuradio/digital/interpolating_resampler_type.h>
#include <vector>
#include <gnuradio/filter/mmse_fir_interpolator_cc.h>
#include <gnuradio/filter/mmse_fir_interpolator_ff.h>
#include <gnuradio/filter/mmse_interp_differentiator_cc.h>
#include <gnuradio/filter/mmse_interp_differentiator_ff.h>
namespace gr {
namespace digital {
/*!
* \brief Base class for the composite interpolating resampler objects
* used by the symbol_synchronizer_xx blocks.
* \ingroup internal
*
* \details
* This is the base class for the composite interpolating resampler
* objects used by the symbol_synchronizer_xx blocks to provide a
* user selectable interpolating resampler type.
*
* This base class provides the enumeration type for the available
* types of interpolating resamplers.
*
* This base class also provides methods to to update, manage, and
* store the sample phase state of the interpolating resampler.
* The sample phase increments and phase state are assumed to be in
* units of samples, and a complete sample phase cycle is one sample.
*/
class interpolating_resampler
{
public:
virtual ~interpolating_resampler() {}
/*!
* \brief Return the number of taps used in any single FIR filtering
* operation
*/
virtual unsigned int ntaps() const = 0;
/*!
* \brief Return the current unwrapped interpolator samples phase in
* units of samples
*/
virtual float phase() { return d_phase; }
/*!
* \brief Return the integral part of the current unwrapped
* interpolator sample phase in units of (whole) samples
*/
virtual int phase_n() { return d_phase_n; }
/*!
* \brief Returns the fractional part of the current wrapped
* interpolator sample phase in units of samples from [0.0, 1.0).
*/
virtual float phase_wrapped() { return d_phase_wrapped; }
/*!
* \brief Return the fractional part of the previous wrapped
* interpolator sample phase in units of samples from [0.0, 1.0).
*/
virtual float prev_phase_wrapped() { return d_prev_phase_wrapped; }
/*!
* \brief Compute the next interpolator sample phase.
* \param increment The sample phase increment to the next interpolation
* point, in units of samples.
* \param phase The new interpolator sample phase, in units of
* samples.
* \param phase_n The integral part of the new interpolator sample
* phase, in units of samples.
* \param phase_wrapped The new wrapped interpolator sample phase,
* in units of samples.
*/
virtual void next_phase(float increment,
float &phase,
int &phase_n,
float &phase_wrapped);
/*!
* \brief Advance the phase state to the next interpolator sample phase.
* \param increment The sample phase increment to the next interpolation
* point, in units of samples.
*/
virtual void advance_phase(float increment);
/*!
* \brief Revert the phase state to the previous interpolator sample
* phase.
*/
virtual void revert_phase();
/*!
* \brief Reset the phase state to the specified interpolator sample
* phase.
* \param phase The interpolator sample phase to which to reset,
* in units of samples.
*/
virtual void sync_reset(float phase);
private:
enum ir_type d_type;
protected:
interpolating_resampler(enum ir_type type, bool derivative = false);
bool d_derivative;
float d_phase;
float d_phase_wrapped;
int d_phase_n;
float d_prev_phase;
float d_prev_phase_wrapped;
int d_prev_phase_n;
};
/*************************************************************************/
/*!
* \brief A complex input, complex output, composite interpolating resampler
* object used by the symbol_synchronizer_cc block.
* \ingroup internal
*
* \details
* This is the complex input, complex output composite interpolating
* resampler object used by the symbol_synchronizer_cc block to provide a
* user selectable interpolating resampler type.
*
* This class abstracts away the underlying interpolating resampler
* type implementation, so the the symbol_synchronizer_cc block need not
* be bothered with the underlying implementation after the object is
* instantiated.
*/
class interpolating_resampler_ccf : public interpolating_resampler
{
public:
/*!
* \brief Create a complex input, complex output interpolating
* resampler object.
* \param type The underlying type implementation of the interpolating
* resampler.
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
* \param nfilts The number of polyphase filter bank arms. Only needed
* for some types.
* \param taps Prototype filter for the polyphase filter bank. Only
* needed for some types.
*/
static interpolating_resampler_ccf *make(enum ir_type type,
bool derivative = false,
int nfilts = 32,
const std::vector<float> &taps
= std::vector<float>());
virtual ~interpolating_resampler_ccf() {};
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
virtual gr_complex interpolate(const gr_complex input[],
float mu) const = 0;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
virtual gr_complex differentiate(const gr_complex input[],
float mu) const = 0;
protected:
interpolating_resampler_ccf(enum ir_type type,
bool derivative = false)
: interpolating_resampler(type, derivative) {}
};
/*************************************************************************/
/*!
* \brief A float input, float output, composite interpolating resampler
* object used by the symbol_synchronizer_ff block.
* \ingroup internal
*
* \details
* This is the float input, float output composite interpolating
* resampler object used by the symbol_synchronizer_ff block to provide a
* user selectable interpolating resampler type.
*
* This class abstracts away the underlying interpolating resampler
* type implementation, so the the symbol_synchronizer_ff block need not
* be bothered with the underlying implementation after the object is
* instantiated.
*/
class interpolating_resampler_fff : public interpolating_resampler
{
public:
/*!
* \brief Create a float input, float output interpolating
* resampler object.
* \param type The underlying type implementation of the interpolating
* resampler.
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
* \param nfilts The number of polyphase filter bank arms. Only needed
* for some types.
* \param taps Prototype filter for the polyphase filter bank. Only
* needed for some types.
*/
static interpolating_resampler_fff *make(enum ir_type type,
bool derivative = false,
int nfilts = 32,
const std::vector<float> &taps
= std::vector<float>());
virtual ~interpolating_resampler_fff() {};
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
virtual float interpolate(const float input[], float mu) const = 0;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
virtual float differentiate(const float input[], float mu) const = 0;
protected:
interpolating_resampler_fff(enum ir_type type,
bool derivative = false)
: interpolating_resampler(type, derivative) {}
};
/*************************************************************************/
/*!
* \brief A complex input, complex output, interpolating resampler
* object using the MMSE interpolator filter bank.
* \ingroup internal
*
* \details
* This is the complex input, complex output, interpolating resampler
* object using the MMSE interpolator filter bank as its underlying
* polyphase filterbank interpolator.
*/
class interp_resampler_mmse_8tap_cc : public interpolating_resampler_ccf
{
public:
/*!
* \brief Create a complex input, complex output, polyphase filter bank
* using the MMSE filter bank, interpolating resampler object.
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
*/
interp_resampler_mmse_8tap_cc(bool derivative = false);
~interp_resampler_mmse_8tap_cc();
/*!
* \brief Return the number of taps used in any single FIR filtering
* operation
*/
unsigned int ntaps() const;
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
gr_complex interpolate(const gr_complex input[], float mu) const;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
gr_complex differentiate(const gr_complex input[], float mu) const;
private:
filter::mmse_fir_interpolator_cc *d_interp;
filter::mmse_interp_differentiator_cc *d_interp_diff;
};
/*!
* \brief A float input, float output, interpolating resampler
* object using the MMSE interpolator filter bank.
* \ingroup internal
*
* \details
* This is the float input, float output, interpolating resampler
* object using the MMSE interpolator filter bank as its underlying
* polyphase filterbank interpolator.
*/
class interp_resampler_mmse_8tap_ff : public interpolating_resampler_fff
{
public:
/*!
* \brief Create a float input, float output, polyphase filter bank
* using the MMSE filter bank, interpolating resampler object.
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
*/
interp_resampler_mmse_8tap_ff(bool derivative = false);
~interp_resampler_mmse_8tap_ff();
/*!
* \brief Return the number of taps used in any single FIR filtering
* operation
*/
unsigned int ntaps() const;
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
float interpolate(const float input[], float mu) const;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
float differentiate(const float input[], float mu) const;
private:
filter::mmse_fir_interpolator_ff *d_interp;
filter::mmse_interp_differentiator_ff *d_interp_diff;
};
/*************************************************************************/
/*!
* \brief A complex input, complex output, interpolating resampler
* object with a polyphase filter bank which uses the MMSE interpolator
* filter arms.
* \ingroup internal
*
* \details
* This is the complex input, complex output, interpolating resampler
* object with a polyphase filter bank which uses the MMSE interpolator
* filter arms. This class has the "advantage" that the number of arms
* used can be reduced from 128 (default) to 64, 32, 16, 8, 4, or 2.
*/
class interp_resampler_pfb_no_mf_cc : public interpolating_resampler_ccf
{
public:
/*!
* \brief Create a complex input, complex output, polyphase filter bank
* using the MMSE filter bank, interpolating resampler object.
* \param nfilts The number of polyphase filter bank arms. Must be in
* {2, 4, 8, 16, 32, 64, 128 (default)}
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
*/
interp_resampler_pfb_no_mf_cc(bool derivative = false,
int nfilts = 128);
~interp_resampler_pfb_no_mf_cc();
/*!
* \brief Return the number of taps used in any single FIR filtering
* operation
*/
unsigned int ntaps() const;
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
gr_complex interpolate(const gr_complex input[], float mu) const;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
gr_complex differentiate(const gr_complex input[], float mu) const;
private:
int d_nfilters;
std::vector<filter::kernel::fir_filter_ccf*> d_filters;
std::vector<filter::kernel::fir_filter_ccf*> d_diff_filters;
};
/*!
* \brief A float input, float output, interpolating resampler
* object with a polyphase filter bank which uses the MMSE interpolator
* filter arms.
* \ingroup internal
*
* \details
* This is the float input, float output, interpolating resampler
* object with a polyphase filter bank which uses the MMSE interpolator
* filter arms. This class has the "advantage" that the number of arms
* used can be reduced from 128 (default) to 64, 32, 16, 8, 4, or 2.
*/
class interp_resampler_pfb_no_mf_ff : public interpolating_resampler_fff
{
public:
/*!
* \brief Create a float input, float output, polyphase filter bank
* using the MMSE filter bank, interpolating resampler object.
* \param nfilts The number of polyphase filter bank arms. Must be in
* {2, 4, 8, 16, 32, 64, 128 (default)}
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
*/
interp_resampler_pfb_no_mf_ff(bool derivative = false,
int nfilts = 128);
~interp_resampler_pfb_no_mf_ff();
/*!
* \brief Return the number of taps used in any single FIR filtering
* operation
*/
unsigned int ntaps() const;
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
float interpolate(const float input[], float mu) const;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
float differentiate(const float input[], float mu) const;
private:
int d_nfilters;
std::vector<filter::kernel::fir_filter_fff*> d_filters;
std::vector<filter::kernel::fir_filter_fff*> d_diff_filters;
};
/*************************************************************************/
/*!
* \brief A complex input, complex output, interpolating resampler
* object with a polyphase filter bank with a user provided prototype
* matched filter.
* \ingroup internal
*
* \details
* This is the complex input, complex output, interpolating resampler
* object with a polyphase filter bank with a user provided protoype
* matched filter. The prototype matched filter must be designed at a
* rate of nfilts times the output rate.
*/
class interp_resampler_pfb_mf_ccf : public interpolating_resampler_ccf
{
public:
/*!
* \brief Create a complex input, complex output, polyphase filter bank,
* with matched filter, interpolating resampler object.
* \param taps Prototype filter for the polyphase filter bank.
* \param nfilts The number of polyphase filter bank arms.
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
*/
interp_resampler_pfb_mf_ccf(const std::vector<float> &taps,
int nfilts = 32,
bool derivative = false);
~interp_resampler_pfb_mf_ccf();
/*!
* \brief Return the number of taps used in any single FIR filtering
* operation
*/
unsigned int ntaps() const;
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
gr_complex interpolate(const gr_complex input[], float mu) const;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
gr_complex differentiate(const gr_complex input[], float mu) const;
private:
int d_nfilters;
const unsigned int d_taps_per_filter;
std::vector<filter::kernel::fir_filter_ccf*> d_filters;
std::vector<filter::kernel::fir_filter_ccf*> d_diff_filters;
std::vector< std::vector<float> > d_taps;
std::vector< std::vector<float> > d_diff_taps;
};
/*!
* \brief A float input, float output, interpolating resampler
* object with a polyphase filter bank with a user provided prototype
* matched filter.
* \ingroup internal
*
* \details
* This is the float input, float output, interpolating resampler
* object with a polyphase filter bank with a user provided protoype
* matched filter. The prototype matched filter must be designed at a
* rate of nfilts times the output rate.
*/
class interp_resampler_pfb_mf_fff : public interpolating_resampler_fff
{
public:
/*!
* \brief Create a float input, float output, polyphase filter bank,
* with matched filter, interpolating resampler object.
* \param taps Prototype filter for the polyphase filter bank.
* \param nfilts The number of polyphase filter bank arms.
* \param derivative True if an interpolating differentitator is
* requested to be initialized to obtain interpolated
* derivative samples as well.
*/
interp_resampler_pfb_mf_fff(const std::vector<float> &taps,
int nfilts = 32,
bool derivative = false);
~interp_resampler_pfb_mf_fff();
/*!
* \brief Return the number of taps used in any single FIR filtering
* operation
*/
unsigned int ntaps() const;
/*!
* \brief Return an interpolated sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
float interpolate(const float input[], float mu) const;
/*!
* \brief Return an interpolated derivative sample.
* \param input Array of input samples of length ntaps().
* \param mu Intersample phase in the range [0.0, 1.0] samples.
*/
float differentiate(const float input[], float mu) const;
private:
int d_nfilters;
const unsigned int d_taps_per_filter;
std::vector<filter::kernel::fir_filter_fff*> d_filters;
std::vector<filter::kernel::fir_filter_fff*> d_diff_filters;
std::vector< std::vector<float> > d_taps;
std::vector< std::vector<float> > d_diff_taps;
};
} /* namespace digital */
} /* namespace gr */
#endif /* INCLUDED_DIGITAL_INTERPOLATING_RESAMPLER_H */
|