diff --git a/gnuradio/Makefile.am b/gnuradio/Makefile.am index 731aa00da..b29c8092d 100644 --- a/gnuradio/Makefile.am +++ b/gnuradio/Makefile.am @@ -9,7 +9,7 @@ hamlib_gnuradio_la_LDFLAGS = -no-undefined -module -avoid-version # requires libgnuradio, libfftw and c++ hamlib_gnuradio_la_LIBADD = $(top_builddir)/src/libhamlib.la @GNURADIO_LIBS@ -lstdc++ -lpthread -noinst_HEADERS = gnuradio.h gr_priv.h demod.h nfm.h am.h +noinst_HEADERS = gnuradio.h gr_priv.h demod.h nfm.h am.h ssb.h wfm.h check_PROGRAMS = testgr diff --git a/gnuradio/ssb.h b/gnuradio/ssb.h new file mode 100644 index 000000000..79bd9e914 --- /dev/null +++ b/gnuradio/ssb.h @@ -0,0 +1,83 @@ +/* + * Hamlib GNUradio backend - SSB class + * Copyright (c) 2003 by Stephane Fillod + * + * $Id: ssb.h,v 1.1 2003-10-01 19:38:34 fillods Exp $ + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program 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 Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef _SSB_H +#define _SSB_H 1 + +#include "demod.h" + +#include /* SSB */ + + +class USBDemodChainCF : public DemodChainCF { + private: + GrSSBMod *s_demod; + float low_cutoff; + + public: + // float rf_gain = chan->levels[rig_setting2idx(RIG_LEVEL_RF)].f; + USBDemodChainCF (VrSource *src, VrSink *snk, rmode_t mode, pbwidth_t width, int input_rate, freq_t centerfreq = 0, float rf_gain = 1.0) : + DemodChainCF(src, snk, mode, width, input_rate, centerfreq, rf_gain) { + + low_cutoff = 300; + // centerfreq, relative to IF_center_freq + centerfreq += (freq_t)(low_cutoff + width/2); + + s_demod = new GrSSBMod(2*M_PI*(low_cutoff+width/2)/(double)input_rate,rf_gain); + + demod_in = demod_out = s_demod; + } + ~USBDemodChainCF() { delete s_demod; } + + //void setWidth(pbwidth_t width) { } /* TODO */ + void setFreq(freq_t centerfreq) { s_demod->set_freq(centerfreq); } + void setRFgain(float gain) { s_demod->set_gain(gain); } +}; + +class LSBDemodChainCF : public DemodChainCF { + private: + GrSSBMod *s_demod; + float low_cutoff; + + public: + // float rf_gain = chan->levels[rig_setting2idx(RIG_LEVEL_RF)].f; + LSBDemodChainCF (VrSource *src, VrSink *snk, rmode_t mode, pbwidth_t width, int input_rate, freq_t centerfreq = 0, float rf_gain = 1.0) : + DemodChainCF(src, snk, mode, width, input_rate, centerfreq, rf_gain) { + + float low_cutoff = 300; + // centerfreq, relative to IF_center_freq + centerfreq += (freq_t)(-low_cutoff - width/2); + + s_demod = new GrSSBMod(-2*M_PI*(low_cutoff+width/2)/(double)input_rate,rf_gain); + + demod_in = demod_out = s_demod; + } + ~LSBDemodChainCF() { delete s_demod; } + + //void setWidth(pbwidth_t width) { } /* TODO */ + void setFreq(freq_t centerfreq) { s_demod->set_freq(centerfreq); } + void setRFgain(float gain) { s_demod->set_gain(gain); } +}; + + +#endif /* _SSB_H */ + diff --git a/gnuradio/wfm.h b/gnuradio/wfm.h new file mode 100644 index 000000000..7bb956433 --- /dev/null +++ b/gnuradio/wfm.h @@ -0,0 +1,93 @@ +/* + * Hamlib GNUradio backend - Wide FM class + * Copyright (c) 2003 by Stephane Fillod + * + * $Id: wfm.h,v 1.1 2003-10-01 19:38:34 fillods Exp $ + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program 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 Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef _WFM_H +#define _WFM_H 1 + +#include "demod.h" + +#include /* WFM */ +#include + + +class WFMDemodChainCF : public DemodChainCF { + private: + VrQuadratureDemod *q_demod; + int RFIRdecimate; + GrFIRfilterFFF *audio_filter; + + public: + WFMDemodChainCF (VrSource *src, VrSink *snk, rmode_t mode, pbwidth_t width, int input_rate, freq_t centerfreq = 0, float rf_gain = 1.0) : + DemodChainCF(src, snk, mode, width, input_rate, centerfreq, rf_gain) { + + CFIRdecimate = 125; + RFIRdecimate = 5; + + const int quadRate = input_rate / CFIRdecimate; + const int audioRate = quadRate / RFIRdecimate; + + rig_debug(RIG_DEBUG_VERBOSE, "Input Sampling Rate: %d\n", input_rate); + rig_debug(RIG_DEBUG_VERBOSE, "Complex FIR decimation factor: %d\n", CFIRdecimate); + rig_debug(RIG_DEBUG_VERBOSE, "QuadDemod Sampling Rate: %d\n", quadRate); + rig_debug(RIG_DEBUG_VERBOSE, "Real FIR decimation factor: %d\n", RFIRdecimate); + rig_debug(RIG_DEBUG_VERBOSE, "Audio Sampling Rate: %d\n", audioRate); + + + // build channel filter + // + // note that the totally bogus transition width is because + // we don't have enough mips right now to really do the right thing. + // This results in a filter with 83 taps, which is just a few + // more than the original 75 in microtune_fm_demo. + + if_width_of_transition_band = 8*100e3; + + // float --> float + double width_of_transition_band = audioRate / 32; + vector audio_coeffs = + gr_firdes::low_pass (rf_gain, // gain + quadRate, // sampling rate + audioRate/2 - width_of_transition_band, // low-pass cutoff freq + width_of_transition_band, + gr_firdes::WIN_HAMMING); + + rig_debug(RIG_DEBUG_VERBOSE, "Number of audio_coeffs: %d\n", audio_coeffs.size ()); + rig_debug(RIG_DEBUG_VERBOSE, "Low-pass cutoff freq: %d\n", audioRate/2 - (int)width_of_transition_band); + + audio_filter = new GrFIRfilterFFF(RFIRdecimate, audio_coeffs); + + q_demod = new VrQuadratureDemod(rf_gain); + + demod_in = q_demod; + demod_out = audio_filter; + NWO_CONNECT(demod_in, audio_filter); + } + + ~WFMDemodChainCF() { delete q_demod; delete audio_filter; } + + + //void setWidth(pbwidth_t width) { } + //void setFreq(freq_t centerfreq) { } + void setRFgain(float gain) { q_demod->setGain(gain); } +}; + +#endif /* _WFM_H */