satdump/src-core/modules/module_bpsk_demod.h

80 lines
2.3 KiB
C
Raw Normal View History

2021-02-15 18:37:53 +01:00
#pragma once
#include "module.h"
#include <complex>
#include <thread>
#include <fstream>
#include "common/dsp/agc.h"
#include "common/dsp/fir.h"
#include "common/dsp/costas_loop.h"
#include "common/dsp/clock_recovery_mm.h"
#include "common/dsp/file_source.h"
#include "common/dsp/dc_blocker.h"
#include "common/dsp/rational_resampler.h"
2021-10-09 14:57:07 +02:00
#include "common/dsp/snr_estimator.h"
#include "common/widgets/constellation.h"
#include "common/widgets/snr_plot.h"
2021-02-15 18:37:53 +01:00
class BPSKDemodModule : public ProcessingModule
{
protected:
2021-03-12 17:56:29 +01:00
std::shared_ptr<dsp::FileSourceBlock> file_source;
2021-03-12 18:17:00 +01:00
std::shared_ptr<dsp::DCBlockerBlock> dcb;
std::shared_ptr<dsp::CCRationalResamplerBlock> res;
2021-03-12 17:56:29 +01:00
std::shared_ptr<dsp::AGCBlock> agc;
std::shared_ptr<dsp::CCFIRBlock> rrc;
std::shared_ptr<dsp::CostasLoopBlock> pll;
std::shared_ptr<dsp::CCMMClockRecoveryBlock> rec;
2021-02-15 18:37:53 +01:00
const float d_agc_rate;
const int d_samplerate;
const int d_symbolrate;
const float d_rrc_alpha;
const int d_rrc_taps;
const float d_loop_bw;
/*const*/ int d_buffer_size;
2021-02-17 20:07:49 +01:00
const bool d_dc_block;
2021-02-15 18:37:53 +01:00
const int MAX_SPS = 3; // Maximum sample per symbol the demodulator will accept before resampling the input
bool resample = false;
2021-02-15 18:37:53 +01:00
int8_t *sym_buffer;
int8_t clamp(float x)
{
if (x < -128.0)
return -127;
if (x > 127.0)
return 127;
return x;
}
std::ofstream data_out;
std::atomic<uint64_t> filesize;
std::atomic<uint64_t> progress;
2021-02-17 20:07:49 +01:00
2021-04-22 18:32:05 +02:00
M2M4SNREstimator snr_estimator;
2021-07-26 11:25:36 +02:00
float snr, peak_snr;
2021-04-22 18:32:05 +02:00
// UI Stuff
widgets::ConstellationViewer constellation;
widgets::SNRPlotViewer snr_plot;
2021-04-22 18:32:05 +02:00
2021-02-15 18:37:53 +01:00
public:
BPSKDemodModule(std::string input_file, std::string output_file_hint, std::map<std::string, std::string> parameters);
~BPSKDemodModule();
2021-04-03 17:13:37 +02:00
void init();
2021-05-22 16:36:09 +02:00
void stop();
2021-02-15 18:37:53 +01:00
void process();
2021-03-31 18:15:26 +02:00
void drawUI(bool window);
2021-02-20 01:47:21 +01:00
std::vector<ModuleDataType> getInputTypes();
std::vector<ModuleDataType> getOutputTypes();
2021-02-15 18:37:53 +01:00
public:
static std::string getID();
2021-07-21 00:54:48 +02:00
virtual std::string getIDM() { return getID(); };
2021-02-15 18:37:53 +01:00
static std::vector<std::string> getParameters();
static std::shared_ptr<ProcessingModule> getInstance(std::string input_file, std::string output_file_hint, std::map<std::string, std::string> parameters);
};