SoDaRadio-5.0.3-master:8901fb5
HilbertTransformer.hxx
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012,2013,2014 Matthew H. Reilly (kb1vc)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 #ifndef HILBERT_HDR
29 #define HILBERT_HDR
30 
31 #include <fstream>
32 #include <complex>
33 #include <stdio.h>
34 #include <fcntl.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <fftw3.h>
38 #include "SoDaBase.hxx"
39 namespace SoDa {
54  class HilbertTransformer : public SoDaBase {
55  public:
61  HilbertTransformer(unsigned int inout_buffer_length, unsigned int filter_length = 256);
62 
72  unsigned int applyIQ(std::complex<float> * inbuf, std::complex<float> * outbuf, float gain = 1.0);
73 
84  unsigned int apply(std::complex<float> * inbuf, std::complex<float> * outbuf, bool pos_sided = true, float gain = 1.0);
85 
95  unsigned int apply(float * inbuf, std::complex<float> * outbuf, bool pos_sided = true, float gain = 1.0);
96 
97  std::ostream & dump(std::ostream & os);
98  private:
103  unsigned int M;
104  unsigned int Q;
105  unsigned int N;
106 
107  // these are the intermediate buffers
108  std::complex<float> * fft_I_input, * fft_Q_input;
109  std::complex<float> * fft_I_output, * fft_Q_output;
110  std::complex<float> * ifft_I_input, * ifft_Q_input;
111  std::complex<float> * ifft_I_output, * ifft_Q_output;
112 
113  // each filter needs two plans, a forward and backward
114  // plan for the FFT and IFFT
116 
117  std::complex<float> * HTu_filter;
118  std::complex<float> * HTl_filter;
119  std::complex<float> * Pass_U_filter;
120  std::complex<float> * Pass_L_filter;
121  // we need to correct for "gain" in the fftw forward /backward transform pair.
124  };
125 }
126 
127 #endif
std::complex< float > * Pass_U_filter
The DFT image of a Q/2 delay transform – used in USB.
The Baseclass for all SoDa objects, and useful commonly used classes.
std::complex< float > * Pass_L_filter
The DFT image of a Q/2 delay transform – used in LSB.
std::complex< float > * ifft_I_output
unsigned int N
the total length of the transform N > (M + Q-1)
In several places we have a real valued signal x(t) that needs to be converted to an analytic signal ...
std::complex< float > * HTu_filter
The DFT image of the hilbert transform – upper sideband.
std::complex< float > * ifft_I_input
unsigned int applyIQ(std::complex< float > *inbuf, std::complex< float > *outbuf, float gain=1.0)
Perform a hilbert transform on the QUADRATURE signal in the input buffer.
std::complex< float > * ifft_Q_output
std::complex< float > * HTl_filter
The DFT image of the hilbert transform – lower sideband.
std::complex< float > * fft_Q_input
unsigned int apply(std::complex< float > *inbuf, std::complex< float > *outbuf, bool pos_sided=true, float gain=1.0)
Perform a hilbert transform on the INPHASE signal in the input buffer.
HilbertTransformer(unsigned int inout_buffer_length, unsigned int filter_length=256)
constructor – build a Hilbert Transformer
std::complex< float > * fft_I_input
float H_transform_gain
the gain of the Hilbert Transform path
std::complex< float > * ifft_Q_input
float passthrough_gain
the gain of the direct passthrough path.
unsigned int Q
the filter length
unsigned int M
these are the salient dimensions for this Overlap/Save widget (for terminology, see Lyons pages 719ff...
The SoDa Base class.
Definition: SoDaBase.hxx:167
std::complex< float > * fft_Q_output
std::complex< float > * fft_I_output
std::ostream & dump(std::ostream &os)