2015-08-27 12:49:14 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* 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; either version 2, 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CHANNEL_DECIMATOR_H__
|
|
|
|
#define __CHANNEL_DECIMATOR_H__
|
|
|
|
|
|
|
|
#include "buffer.hpp"
|
|
|
|
#include "complex.hpp"
|
|
|
|
|
|
|
|
#include "dsp_decimate.hpp"
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
|
|
|
class ChannelDecimator {
|
|
|
|
public:
|
|
|
|
enum class DecimationFactor {
|
2015-11-19 15:24:20 -05:00
|
|
|
By2,
|
2015-08-27 12:49:14 -04:00
|
|
|
By4,
|
|
|
|
By8,
|
|
|
|
By16,
|
|
|
|
By32,
|
|
|
|
};
|
|
|
|
|
2015-11-10 17:04:50 -05:00
|
|
|
constexpr ChannelDecimator(
|
2015-11-19 15:24:20 -05:00
|
|
|
) : decimation_factor { DecimationFactor::By32 },
|
|
|
|
fs_over_4_downconvert { true }
|
2015-11-10 17:04:50 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr ChannelDecimator(
|
2015-11-19 15:24:20 -05:00
|
|
|
const DecimationFactor decimation_factor,
|
|
|
|
const bool fs_over_4_downconvert = true
|
|
|
|
) : decimation_factor { decimation_factor },
|
|
|
|
fs_over_4_downconvert { fs_over_4_downconvert }
|
2015-11-10 17:04:50 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-08-27 12:49:14 -04:00
|
|
|
void set_decimation_factor(const DecimationFactor f) {
|
|
|
|
decimation_factor = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer_c16_t execute(buffer_c8_t buffer) {
|
|
|
|
auto decimated = execute_decimation(buffer);
|
|
|
|
|
|
|
|
return decimated;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::array<complex16_t, 1024> work_baseband;
|
|
|
|
|
|
|
|
dsp::decimate::TranslateByFSOver4AndDecimateBy2CIC3 translate;
|
2015-11-19 15:24:20 -05:00
|
|
|
dsp::decimate::Complex8DecimateBy2CIC3 cic_0;
|
2015-08-27 12:49:14 -04:00
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_1;
|
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_2;
|
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_3;
|
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_4;
|
|
|
|
|
2015-11-10 17:04:50 -05:00
|
|
|
DecimationFactor decimation_factor;
|
2015-11-19 15:24:20 -05:00
|
|
|
const bool fs_over_4_downconvert;
|
2015-08-27 12:49:14 -04:00
|
|
|
|
|
|
|
buffer_c16_t execute_decimation(buffer_c8_t buffer);
|
2015-11-19 15:24:20 -05:00
|
|
|
|
|
|
|
buffer_c16_t execute_stage_0(
|
|
|
|
buffer_c8_t buffer,
|
|
|
|
buffer_c16_t work_baseband_buffer
|
|
|
|
);
|
2015-08-27 12:49:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif/*__CHANNEL_DECIMATOR_H__*/
|