From 0705461d8ae8137aba3f6a46a973e4c798f7fe4d Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 10 Dec 2015 08:54:57 +0100 Subject: [PATCH] BFM demod: added RDS demodulator class --- plugins/channel/bfm/rdsdemod.cpp | 57 ++++++++++++++++++++++++++++++++ plugins/channel/bfm/rdsdemod.h | 41 +++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 plugins/channel/bfm/rdsdemod.cpp create mode 100644 plugins/channel/bfm/rdsdemod.h diff --git a/plugins/channel/bfm/rdsdemod.cpp b/plugins/channel/bfm/rdsdemod.cpp new file mode 100644 index 000000000..f82707023 --- /dev/null +++ b/plugins/channel/bfm/rdsdemod.cpp @@ -0,0 +1,57 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2015 F4EXB // +// written by Edouard Griffiths // +// // +// This program 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 as version 3 of the License, or // +// // +// 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 General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include "rdsdemod.h" + +RDSDemod::RDSDemod() +{ + m_rdsBB = 0.0; + m_rdsBB_1 = 0.0; + m_rdsClockPhase = 0.0; + m_rdsClockOffset = 0.0; + m_rdsClockLO = 0.0; +} + +RDSDemod::~RDSDemod() +{ +} + +void RDSDemod::process(Real rdsSample, Real pilotSample) +{ + m_rdsBB = filter_lp_2400_iq(rdsSample, 0); // working on real part only + + // 1187.5 Hz clock + m_rdsClockPhase = (pilotSample / 48.0) + m_rdsClockOffset; + m_rdsClockLO = (fmod(m_rdsClockPhase, 2 * M_PI) < M_PI ? 1 : -1); +} + +Real RDSDemod::filter_lp_2400_iq(Real input, int iqIndex) +{ + /* Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher + Command line: /www/usr/fisher/helpers/mkfilter -Bu -Lp -o 10 + -a 4.8000000000e-03 0.0000000000e+00 -l */ + + m_xv[iqIndex][0] = m_xv[iqIndex][1]; m_xv[iqIndex][1] = m_xv[iqIndex][2]; + m_xv[iqIndex][2] = input / 4.491730007e+03; + m_yv[iqIndex][0] = m_yv[iqIndex][1]; m_yv[iqIndex][1] = m_yv[iqIndex][2]; + m_yv[iqIndex][2] = (m_xv[iqIndex][0] + m_xv[iqIndex][2]) + 2 * m_xv[iqIndex][1] + + ( -0.9582451124 * m_yv[iqIndex][0]) + ( 1.9573545869 * m_yv[iqIndex][1]); + + return m_yv[iqIndex][2]; +} + diff --git a/plugins/channel/bfm/rdsdemod.h b/plugins/channel/bfm/rdsdemod.h new file mode 100644 index 000000000..1accd64ec --- /dev/null +++ b/plugins/channel/bfm/rdsdemod.h @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2015 F4EXB // +// written by Edouard Griffiths // +// // +// This program 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 as version 3 of the License, or // +// // +// 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 General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PLUGINS_CHANNEL_BFM_RDSDEMOD_H_ +#define PLUGINS_CHANNEL_BFM_RDSDEMOD_H_ + +class RDSDemod +{ +public: + RDSDemod(); + ~RDSDemod(); + + void process(Real rdsSample, Real pilotSample); + Real filter_lp_2400_iq(Real in, int iqIndex); + +private: + Real m_xv[2][2+1]; + Real m_yv[2][2+1]; + Real m_rdsBB; + Real m_rdsBB_1; + Real m_rdsClockPhase; + Real m_rdsClockOffset; + Real m_rdsClockLO; +}; + +#endif /* PLUGINS_CHANNEL_BFM_RDSDEMOD_H_ */