diff --git a/Source/Receiver.cpp b/Source/Receiver.cpp index 3dc07ea..a1ae816 100644 --- a/Source/Receiver.cpp +++ b/Source/Receiver.cpp @@ -1,6 +1,7 @@ #include #include "Receiver.h" #include "MinMaxLemire.h" +#include "radio/Interpolation.hpp" #include #if 0 @@ -54,8 +55,6 @@ Receiver::Receiver(LogHandler *pLogHandler) , m_pSymMapper(0) , m_pPolyphaseInterpolator(0) , m_pLagrangeInterpolator(0) - , m_pFarrowInterpolator(0) - { m_stateArm_I = nullptr; m_stateArm_Q = nullptr; @@ -895,13 +894,6 @@ void Receiver::free() } m_pLagrangeInterpolator = nullptr; - if (m_pFarrowInterpolator) - { - FarrowPPIPCpxFree(m_pFarrowInterpolator); - delete m_pFarrowInterpolator; - } - m_pFarrowInterpolator = nullptr; - NCO_Free(&m_nco_ddc); NCO_Free(&m_nco_cpr); @@ -1096,7 +1088,7 @@ void Receiver::processBaseband(cpx_t *pIF, uint32_t len) if (RCF_TYPE == RCF_TYPE_POLYPHASE_FARROW) { // Matched filtering and interpolation - FarrowPPIPCpxFeed(m_pFarrowInterpolator, 1, pIF[n]); + m_farrow.feed(toComplexScalar(pIF[n]), 1); } do @@ -1115,7 +1107,8 @@ void Receiver::processBaseband(cpx_t *pIF, uint32_t len) if (RCF_TYPE == RCF_TYPE_POLYPHASE_FARROW) { - IQ_mf = FarrowPPIPCpxInterpolate(m_pFarrowInterpolator, !TimingCorrectorIsStuff(&m_timing_corrector), TimingCorrectorGetMu(&m_timing_corrector)); + ComplexScalar __IQ_mf = m_farrow.process(TimingCorrectorGetMu(&m_timing_corrector), !TimingCorrectorIsStuff(&m_timing_corrector)); + IQ_mf = toCpx(__IQ_mf); } // AGC Blind process samples @@ -1336,31 +1329,6 @@ cpx_t Receiver::processMatchedFilter(cpx_t x, int32_t m, radio_float_t mu) return y; } -int Receiver::Farrow_open_coeff(ppip_farrow_cpx_t *pObj, const char *filename) -{ - int i; - FILE *pFile; - ml_farrow_coef_hdr_t hdr; - radio_float_t *pCoeff; - pFile = fopen(filename, "rb"); - if (!pFile) - { - m_log.log("Can't open %s\n", filename); - return -1; - } - fread(&hdr, sizeof(hdr), 1, pFile); - FarrowPPIPCpxInit(pObj, hdr.M, hdr.N); -// pCoeff = (radio_float_t*)malloc(hdr.M*hdr.N*sizeof(radio_float_t)); - - for (i=0; i < (int)hdr.M; i++) - { - fread(pObj->ppCoeff[i], sizeof(radio_float_t), hdr.N, pFile); - pCoeff = pObj->ppCoeff[i]; - } - - return 0; -} - void Receiver::initDDC() { NCO_Init(&m_nco_ddc, m_params.ddc_freq/m_params.samplerate, 0); @@ -1457,15 +1425,7 @@ void Receiver::initFilterRcf() { // Fixed at symbol duration 2/fs // -> RCF_ROLLOFF and symbol rate parameter have no influence - if (m_pFarrowInterpolator) - { - FarrowPPIPCpxFree(m_pFarrowInterpolator); - delete m_pFarrowInterpolator; - } - - m_pFarrowInterpolator = new ppip_farrow_cpx_t(); - Farrow_open_coeff(m_pFarrowInterpolator, "/home/jens/farrow_coeff.dat"); - m_log.log("Farrow filter coefficients loaded (L=%d, M=%d, N=%d)", m_pFarrowInterpolator->L, m_pFarrowInterpolator->M, m_pFarrowInterpolator->N); + m_farrow.load("/home/jens/farrow_coeff.dat"); } } diff --git a/Source/Receiver.h b/Source/Receiver.h index bd17d26..7f2df3f 100644 --- a/Source/Receiver.h +++ b/Source/Receiver.h @@ -16,6 +16,7 @@ #include #include +#include using namespace Radio; @@ -95,12 +96,6 @@ enum str_state str_state_track }; -typedef struct _ml_farrow_coef_hdr_t -{ - uint32_t M; - uint32_t N; -} ml_farrow_coef_hdr_t; - typedef struct _minmax_t { float min, max; @@ -316,7 +311,7 @@ private: // Interpolators ppip_cpx_t *m_pPolyphaseInterpolator; lgip_cpx_t *m_pLagrangeInterpolator; - ppip_farrow_cpx_t *m_pFarrowInterpolator; + Interpolation::Farrow m_farrow; // NCOs nco_t m_nco_ddc, m_nco_cpr;