2021-03-21 21:11:40 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Belousov Oleg
|
|
|
|
*
|
|
|
|
* 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 __DSP_MODULATE_H__
|
|
|
|
#define __DSP_MODULATE_H__
|
|
|
|
|
|
|
|
#include "dsp_types.hpp"
|
|
|
|
#include "dsp_hilbert.hpp"
|
2022-05-06 19:43:14 -04:00
|
|
|
#include "tone_gen.hpp"
|
|
|
|
#include "baseband_processor.hpp"
|
2021-03-21 21:11:40 -04:00
|
|
|
|
|
|
|
namespace dsp {
|
|
|
|
namespace modulate {
|
|
|
|
|
|
|
|
enum class Mode {
|
2023-05-18 16:16:05 -04:00
|
|
|
None,
|
|
|
|
AM,
|
|
|
|
DSB,
|
|
|
|
LSB,
|
|
|
|
USB,
|
|
|
|
FM
|
2021-03-21 21:11:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
class Modulator {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer, bool& configured_in, uint32_t& new_beep_index, uint32_t& new_beep_timer, TXProgressMessage& new_txprogress_message, AudioLevelReportMessage& new_level_message, uint32_t& new_power_acc_count, uint32_t& new_divider) = 0;
|
|
|
|
virtual ~Modulator();
|
2021-03-21 21:11:40 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
Mode get_mode();
|
|
|
|
void set_mode(Mode new_mode);
|
2021-03-21 21:11:40 -04:00
|
|
|
|
|
|
|
void set_over(uint32_t new_over);
|
2023-05-18 16:16:05 -04:00
|
|
|
void set_gain_shiftbits_vumeter_beep(float new_audio_gain, uint8_t new_audio_shift_bits_s16, bool new_play_beep);
|
|
|
|
int32_t apply_beep(int32_t sample_in, bool& configured_in, uint32_t& new_beep_index, uint32_t& new_beep_timer, TXProgressMessage& new_txprogress_message);
|
|
|
|
float audio_gain{};
|
|
|
|
uint8_t audio_shift_bits_s16_FM{}; // shift bits factor to the captured ADC S16 audio sample.
|
|
|
|
uint8_t audio_shift_bits_s16_AM_DSB_SSB{};
|
|
|
|
bool play_beep{false};
|
|
|
|
uint32_t power_acc_count{0}; // this var it is initialized from Proc_mictx.cpp
|
|
|
|
uint32_t divider{}; // this var it is initialized from Proc_mictx.cpp
|
|
|
|
uint64_t power_acc{0}; // it is aux Accumulated sum (Absolute sample signal) , initialitzed to zero.
|
|
|
|
AudioLevelReportMessage level_message{};
|
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr size_t baseband_fs = 1536000U;
|
|
|
|
TXProgressMessage txprogress_message{};
|
|
|
|
ToneGen beep_gen{};
|
|
|
|
uint32_t beep_index{}, beep_timer{};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t over = 1;
|
|
|
|
Mode mode = Mode::None;
|
2021-03-21 21:11:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
class SSB : public Modulator {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
SSB();
|
2021-03-21 21:11:40 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer, bool& configured_in, uint32_t& new_beep_index, uint32_t& new_beep_timer, TXProgressMessage& new_txprogress_message, AudioLevelReportMessage& new_level_message, uint32_t& new_power_acc_count, uint32_t& new_divider);
|
2024-07-06 07:34:09 -04:00
|
|
|
void set_fs_div_factor(float new_bw_ssb);
|
2021-03-21 21:11:40 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
private:
|
|
|
|
dsp::HilbertTransform hilbert;
|
2024-07-06 07:34:09 -04:00
|
|
|
float new_bw_ssb{3.0};
|
|
|
|
int fs_div_factor{128};
|
2021-03-21 21:11:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
class FM : public Modulator {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
FM();
|
2021-03-21 21:11:40 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer, bool& configured_in, uint32_t& new_beep_index, uint32_t& new_beep_timer, TXProgressMessage& new_txprogress_message, AudioLevelReportMessage& new_level_message, uint32_t& new_power_acc_count, uint32_t& new_divider);
|
|
|
|
void set_fm_delta(uint32_t new_delta);
|
|
|
|
void set_tone_gen_configure(const uint32_t delta, const float tone_mix_weight);
|
2021-03-21 21:11:40 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
///
|
2022-05-06 19:43:14 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
private:
|
|
|
|
uint32_t fm_delta{0};
|
|
|
|
uint32_t phase{0}, sphase{0};
|
|
|
|
int32_t sample{0}, delta{};
|
|
|
|
ToneGen tone_gen{};
|
2021-03-21 21:11:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class AM : public Modulator {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
AM();
|
2021-03-21 21:11:40 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer, bool& configured_in, uint32_t& new_beep_index, uint32_t& new_beep_timer, TXProgressMessage& new_txprogress_message, AudioLevelReportMessage& new_level_message, uint32_t& new_power_acc_count, uint32_t& new_divider);
|
2021-03-21 21:11:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace modulate */
|
|
|
|
} /* namespace dsp */
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
#endif /*__DSP_MODULATE_H__*/
|