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 {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
enum class DecimationFactor {
|
|
|
|
By2,
|
|
|
|
By4,
|
|
|
|
By8,
|
|
|
|
By16,
|
|
|
|
By32,
|
|
|
|
};
|
2015-11-10 17:04:50 -05:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
constexpr ChannelDecimator(
|
|
|
|
const DecimationFactor decimation_factor,
|
|
|
|
const bool fs_over_4_downconvert = true)
|
|
|
|
: decimation_factor{decimation_factor},
|
|
|
|
fs_over_4_downconvert{fs_over_4_downconvert} {
|
|
|
|
}
|
2015-08-27 12:49:14 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
void set_decimation_factor(const DecimationFactor f) {
|
|
|
|
decimation_factor = f;
|
|
|
|
}
|
2015-08-27 12:49:14 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
buffer_c16_t execute(const buffer_c8_t& buffer) {
|
|
|
|
auto decimated = execute_decimation(buffer);
|
2015-08-27 12:49:14 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
return decimated;
|
|
|
|
}
|
2015-08-27 12:49:14 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
private:
|
|
|
|
std::array<complex16_t, 1024> work_baseband{};
|
2015-08-27 12:49:14 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
dsp::decimate::TranslateByFSOver4AndDecimateBy2CIC3 translate{};
|
|
|
|
dsp::decimate::Complex8DecimateBy2CIC3 cic_0{};
|
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_1{};
|
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_2{};
|
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_3{};
|
|
|
|
dsp::decimate::DecimateBy2CIC3 cic_4{};
|
2015-08-27 12:49:14 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
DecimationFactor decimation_factor{DecimationFactor::By32};
|
|
|
|
const bool fs_over_4_downconvert{true};
|
2015-11-19 15:24:20 -05:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
buffer_c16_t execute_decimation(const buffer_c8_t& buffer);
|
|
|
|
|
|
|
|
buffer_c16_t execute_stage_0(
|
|
|
|
const buffer_c8_t& buffer,
|
|
|
|
const buffer_c16_t& work_baseband_buffer);
|
2015-08-27 12:49:14 -04:00
|
|
|
};
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
#endif /*__CHANNEL_DECIMATOR_H__*/
|