7#include "common/dsp/complex.h"
25 class FreqShiftBlock :
public BlockSimple<complex_t, complex_t>
28 bool needs_reinit =
false;
29 bool raw_shift =
false;
30 double freq_shift = 0;
31 double samplerate = 6e6;
34 complex_t phase_delta;
41 uint32_t
process(complex_t *input, uint32_t nsamples, complex_t *output);
45 if (raw_shift ==
false)
47 phase = complex_t(1, 0);
48 phase_delta = complex_t(cos(2.0 * M_PI * (freq_shift / samplerate)), sin(2.0 * M_PI * (freq_shift / samplerate)));
50 else if (raw_shift ==
true)
52 phase_delta = complex_t(cosf(freq_shift), sinf(freq_shift));
58 nlohmann::ordered_json p;
59 add_param_simple(p,
"freq_shift",
"float",
"Frequency Shift");
60 add_param_simple(p,
"samplerate",
"float",
"Samplerate");
61 add_param_simple(p,
"raw_shift",
"bool",
"Raw Shift");
67 if (key ==
"raw_shift")
69 else if (key ==
"freq_shift")
71 else if (key ==
"samplerate")
74 throw satdump_exception(key);
79 if (key ==
"raw_shift")
84 else if (key ==
"freq_shift")
89 else if (key ==
"samplerate")
95 throw satdump_exception(key);
cfg_res_t
set_cfg status.
Definition block.h:227
nlohmann::json get_cfg(std::string key)
Get parameters of the block as JSON.
Definition freq_shift.h:65
uint32_t process(complex_t *input, uint32_t nsamples, complex_t *output)
Simplified "work" function, called automatically by work(). This takes away all boilerplate work usua...
Definition freq_shift.cpp:11
nlohmann::ordered_json get_cfg_list()
Get parameters LIST of the block's parameters. This does not contain actual values,...
Definition freq_shift.h:56
void init()
Applies current parameters to the block. This is called automatically once in start(),...
Definition freq_shift.h:43
cfg_res_t set_cfg(std::string key, nlohmann::json v)
Set parameters of the block from JSON, including potentially IO configurations for blocks that may ha...
Definition freq_shift.h:77