Houston, we have a trunk.
[debian/gnuradio] / gr-atsc / src / lib / GrAtscSegSymSyncImpl.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <GrAtscSegSymSyncImpl.h>
24 #include <GrAtscSegSymSyncImpl_export.h>
25 #include <cmath>
26 #include <assert.h>
27
28 GrAtscSegSymSyncImpl::GrAtscSegSymSyncImpl (
29     double nominal_ratio_of_rx_clock_to_symbol_freq)
30   : d_interp (nominal_ratio_of_rx_clock_to_symbol_freq)
31 {
32   // set approximate decimation rate for superclass's benefit
33   decimation = (int) rint (nominal_ratio_of_rx_clock_to_symbol_freq);
34
35   history = 1500;       // spare input samples in case we need them.
36   
37   d_sssr.reset ();
38   d_interp.reset ();
39   d_next_input = 0;
40   d_rx_clock_to_symbol_freq = nominal_ratio_of_rx_clock_to_symbol_freq;
41 }
42
43 GrAtscSegSymSyncImpl::~GrAtscSegSymSyncImpl ()
44 {
45   // Nop
46 }
47
48 void
49 GrAtscSegSymSyncImpl::pre_initialize ()
50 {
51   setSamplingFrequency (
52      getInputSamplingFrequencyN (0) / d_rx_clock_to_symbol_freq);
53 }
54
55 int
56 GrAtscSegSymSyncImpl::forecast (VrSampleRange output,
57                                 VrSampleRange inputs[])
58 {
59   assert (numberInputs == 1);   // I hate these free references to
60                                 // superclass's instance variables...
61
62   inputs[0].index = d_next_input;
63   inputs[0].size =
64     ((long unsigned int) (output.size * d_rx_clock_to_symbol_freq)
65      + history - 1);
66
67   return 0;
68 }
69
70 int
71 GrAtscSegSymSyncImpl::work (VrSampleRange output, void *ao[],
72                             VrSampleRange inputs[], void *ai[])
73 {
74 #if 0
75   float         *input_samples  = ((float **) ai)[0];
76   float         *output_samples = ((float **) ao)[0];
77   atsc::syminfo *output_info    = ((atsc::syminfo **) ao)[1];
78
79   // FIXME finish...
80 #endif
81   assert (0);
82
83   return output.size;
84 }
85
86 void
87 GrAtscSegSymSyncImpl::reset ()
88 {
89   d_sssr.reset ();
90   d_interp.reset ();
91 }
92
93
94 /*
95  * Exported constructor.
96  * Doesn't expose any of the internals or our compile time dependencies.
97  */
98
99 GrAtscSegSymSync *
100 create_GrAtscSegSymSyncImpl (double nominal_ratio_of_rx_clock_to_symbol_freq)
101 {
102   return new GrAtscSegSymSyncImpl (nominal_ratio_of_rx_clock_to_symbol_freq);
103 }