forked from gqrx-sdr/gqrx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Step gqrx-sdr#5: First FM stereo implementation works!
- Loading branch information
Showing
9 changed files
with
363 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2011 Alexandru Csete OZ9AEC. | ||
* | ||
* Gqrx 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. | ||
* | ||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
#include <cmath> | ||
#include <gr_io_signature.h> | ||
#include <gr_firdes.h> | ||
#include "dsp/lpf.h" | ||
|
||
static const int MIN_IN = 1; /* Mininum number of input streams. */ | ||
static const int MAX_IN = 1; /* Maximum number of input streams. */ | ||
static const int MIN_OUT = 1; /* Minimum number of output streams. */ | ||
static const int MAX_OUT = 1; /* Maximum number of output streams. */ | ||
|
||
|
||
/* | ||
* Create a new instance of lpf and return | ||
* a boost shared_ptr. This is effectively the public constructor. | ||
*/ | ||
lpf_ff_sptr make_lpf_ff(double sample_rate, double cutoff_freq, | ||
double trans_width, double gain) | ||
{ | ||
return gnuradio::get_initial_sptr(new lpf_ff(sample_rate, cutoff_freq, | ||
trans_width, gain)); | ||
} | ||
|
||
|
||
lpf_ff::lpf_ff(double sample_rate, double cutoff_freq, | ||
double trans_width, double gain) | ||
: gr_hier_block2("lpf_ff", | ||
gr_make_io_signature(MIN_IN, MAX_IN, sizeof (float)), | ||
gr_make_io_signature(MIN_OUT, MAX_OUT, sizeof (float))), | ||
d_sample_rate(sample_rate), | ||
d_cutoff_freq(cutoff_freq), | ||
d_trans_width(trans_width), | ||
d_gain(gain) | ||
{ | ||
/* generate taps */ | ||
d_taps = gr_firdes::low_pass(d_gain, d_sample_rate, | ||
d_cutoff_freq, d_trans_width); | ||
|
||
/* create low-pass filter (decimation=1) */ | ||
lpf = gr_make_fir_filter_fff(1, d_taps); | ||
|
||
/* connect filter */ | ||
connect(self(), 0, lpf, 0); | ||
connect(lpf, 0, self(), 0); | ||
} | ||
|
||
|
||
lpf_ff::~lpf_ff() | ||
{ | ||
|
||
} | ||
|
||
|
||
void lpf_ff::set_param(double cutoff_freq, double trans_width) | ||
{ | ||
d_cutoff_freq = cutoff_freq; | ||
d_trans_width = trans_width; | ||
|
||
/* generate new taps */ | ||
d_taps = gr_firdes::low_pass(d_gain, d_sample_rate, | ||
d_cutoff_freq, d_trans_width); | ||
|
||
lpf->set_taps(d_taps); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2011 Alexandru Csete OZ9AEC. | ||
* | ||
* Gqrx 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. | ||
* | ||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
#ifndef LPF_H | ||
#define LPF_H | ||
|
||
#include <gr_hier_block2.h> | ||
#include <gr_firdes.h> | ||
#include <gr_fir_filter_fff.h> | ||
|
||
|
||
class lpf_ff; | ||
|
||
typedef boost::shared_ptr<lpf_ff> lpf_ff_sptr; | ||
|
||
|
||
/*! \brief Return a shared_ptr to a new instance of lpf. | ||
* \param sample_rate The sample rate (Hz). | ||
* \param cutoff_freq Center of transition band (Hz). | ||
* \param transition_width Width of transition band (Hz). | ||
* \param . | ||
* \param gain Overall gain of filter (typically 1.0). | ||
* | ||
* This is effectively the public constructor. To avoid accidental use | ||
* of raw pointers, lpf's constructor is private. | ||
* make_lpf is the public interface for creating new instances. | ||
*/ | ||
lpf_ff_sptr make_lpf_ff(double sample_rate=48000., | ||
double cutoff_freq=5000., | ||
double trans_width=1000., | ||
double gain=1.0); | ||
|
||
/*! \brief low-pass filter (LPF) with float taps. | ||
* \ingroup DSP | ||
* | ||
* This class encapsulates a low-pass FIR filter and the code | ||
* required to generate filter taps. It provides a simple | ||
* interface to set the filter parameters. | ||
* | ||
* The user of this class is expected to provide valid parameters and no checks are | ||
* performed by the accessors (though the taps generator from gr_firdes does perform | ||
* some sanity checks and throws std::out_of_range in case of bad parameter). | ||
*/ | ||
class lpf_ff : public gr_hier_block2 | ||
{ | ||
friend lpf_ff_sptr make_lpf_ff(double sample_rate, double cutoff_freq, | ||
double trans_width, double gain); | ||
protected: | ||
lpf_ff(double sample_rate, double cutoff_freq, | ||
double trans_width, double gain); | ||
|
||
public: | ||
~lpf_ff(); | ||
|
||
void set_param(double cutoff_freq, double trans_width); | ||
|
||
private: | ||
/* GR blocks */ | ||
gr_fir_filter_fff_sptr lpf; | ||
|
||
/* other parameters */ | ||
std::vector<float> d_taps; | ||
double d_sample_rate; | ||
double d_cutoff_freq; | ||
double d_trans_width; | ||
double d_gain; | ||
}; | ||
|
||
|
||
#endif // LPF_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.