SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
HilbertTransformer.hxx
Go to the documentation of this file.
1/*
2 Copyright (c) 2012,2013,2014,2025 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#pragma once
29
30#include <fstream>
31#include <complex>
32#include <stdio.h>
33#include <fcntl.h>
34#include <sys/types.h>
35#include <sys/stat.h>
36#include <fftw3.h>
37#include "SoDaBase.hxx"
38namespace SoDa {
54 typedef std::shared_ptr<HilbertTransformer> HilbertTransformerPtr;
55
57 protected:
63 HilbertTransformer(unsigned int inout_buffer_length, unsigned int filter_length = 256);
64
65 public:
66 static HilbertTransformerPtr make(unsigned int inout_buffer_length, unsigned int filter_length = 256) {
67 auto ret = std::shared_ptr<HilbertTransformer>(new HilbertTransformer(inout_buffer_length,
68 filter_length));
69
70 ret->registerSelf(ret);
71 return ret;
72 }
73
83 unsigned int applyIQ(std::vector<std::complex<float>> & inbuf,
84 std::vector<std::complex<float>> & outbuf,
85 float gain = 1.0);
86
97 unsigned int apply(std::vector<std::complex<float>> & inbuf,
98 std::vector<std::complex<float>> & outbuf, bool pos_sided = true, float gain = 1.0);
99
109 unsigned int apply(std::vector<float> & inbuf,
110 std::vector<std::complex<float>> & outbuf,
111 bool pos_sided = true, float gain = 1.0);
112
113 std::ostream & dump(std::ostream & os);
114 private:
119 unsigned int M;
120 unsigned int Q;
121 unsigned int N;
122
123 // these are the intermediate buffers
124 std::complex<float> * fft_I_input, * fft_Q_input;
125 std::complex<float> * fft_I_output, * fft_Q_output;
126 std::complex<float> * ifft_I_input, * ifft_Q_input;
127 std::complex<float> * ifft_I_output, * ifft_Q_output;
128
129 // each filter needs two plans, a forward and backward
130 // plan for the FFT and IFFT
132
133 std::complex<float> * HTu_filter;
134 std::complex<float> * HTl_filter;
135 std::complex<float> * Pass_U_filter;
136 std::complex<float> * Pass_L_filter;
137 // we need to correct for "gain" in the fftw forward /backward transform pair.
140 };
141}
142
The Baseclass for all SoDa objects, and useful commonly used classes.
The SoDa Base class.
Definition SoDaBase.hxx:105
In several places we have a real valued signal x(t) that needs to be converted to an analytic signal ...
unsigned int apply(std::vector< std::complex< float > > &inbuf, std::vector< std::complex< float > > &outbuf, bool pos_sided=true, float gain=1.0)
Perform a hilbert transform on the INPHASE signal in the input buffer.
std::complex< float > * Pass_L_filter
The DFT image of a Q/2 delay transform – used in LSB.
std::complex< float > * fft_I_output
std::complex< float > * HTu_filter
The DFT image of the hilbert transform – upper sideband.
float passthrough_gain
the gain of the direct passthrough path.
HilbertTransformer(unsigned int inout_buffer_length, unsigned int filter_length=256)
constructor – build a Hilbert Transformer
unsigned int applyIQ(std::vector< std::complex< float > > &inbuf, std::vector< std::complex< float > > &outbuf, float gain=1.0)
Perform a hilbert transform on the QUADRATURE signal in the input buffer.
std::complex< float > * ifft_I_input
std::complex< float > * ifft_Q_output
std::ostream & dump(std::ostream &os)
unsigned int M
these are the salient dimensions for this Overlap/Save widget (for terminology, see Lyons pages 719ff
std::complex< float > * fft_I_input
unsigned int Q
the filter length
std::complex< float > * Pass_U_filter
The DFT image of a Q/2 delay transform – used in USB.
unsigned int N
the total length of the transform N > (M + Q-1)
float H_transform_gain
the gain of the Hilbert Transform path
std::complex< float > * fft_Q_input
static HilbertTransformerPtr make(unsigned int inout_buffer_length, unsigned int filter_length=256)
std::complex< float > * fft_Q_output
unsigned int apply(std::vector< float > &inbuf, std::vector< std::complex< float > > &outbuf, bool pos_sided=true, float gain=1.0)
Perform a hilbert transform on the signal in the floating point input buffer.
std::complex< float > * ifft_Q_input
std::complex< float > * ifft_I_output
std::complex< float > * HTl_filter
The DFT image of the hilbert transform – lower sideband.
std::shared_ptr< HilbertTransformer > HilbertTransformerPtr