I'm a little lost again
This commit is contained in:
@@ -22,8 +22,9 @@ static constexpr double SCALE_FACTOR = 32767.0;
|
||||
class PSKModulator {
|
||||
public:
|
||||
PSKModulator(const double _sample_rate, const bool _is_frequency_hopping, const size_t _num_taps)
|
||||
: sample_rate(validateSampleRate(_sample_rate)), gain(1.0/sqrt(2.0)), is_frequency_hopping(_is_frequency_hopping), samples_per_symbol(static_cast<size_t>(sample_rate / SYMBOL_RATE)), phase_detector(symbolMap), srrc_filter(48, _sample_rate, SYMBOL_RATE, ROLLOFF_FACTOR) {
|
||||
: sample_rate(validateSampleRate(_sample_rate)), gain(1.0/sqrt(2.0)), is_frequency_hopping(_is_frequency_hopping), samples_per_symbol(static_cast<size_t>(sample_rate / SYMBOL_RATE)), srrc_filter(48, _sample_rate, SYMBOL_RATE, ROLLOFF_FACTOR) {
|
||||
initializeSymbolMap();
|
||||
phase_detector = PhaseDetector(symbolMap);
|
||||
}
|
||||
|
||||
std::vector<int16_t> modulate(const std::vector<uint8_t>& symbols) {
|
||||
@@ -78,7 +79,7 @@ public:
|
||||
|
||||
std::vector<uint8_t> demodulate(const std::vector<int16_t> passband_signal) {
|
||||
// Carrier recovery. initialize the Costas loop.
|
||||
CostasLoop costas_loop(sample_rate, symbolMap);
|
||||
CostasLoop costas_loop(CARRIER_FREQ, sample_rate, symbolMap, 5.0);
|
||||
|
||||
// Convert passband signal to doubles.
|
||||
std::vector<double> normalized_passband(passband_signal.size());
|
||||
@@ -91,8 +92,17 @@ public:
|
||||
|
||||
// Phase detection and symbol formation
|
||||
std::vector<uint8_t> baseband_symbols;
|
||||
for (size_t i = 0; i < baseband_IQ.size(); i++) {
|
||||
baseband_symbols.emplace_back(phase_detector.getSymbol(baseband_IQ[i]));
|
||||
size_t samples_per_symbol = sample_rate / SYMBOL_RATE;
|
||||
|
||||
for (size_t i = 0; i < baseband_IQ.size(); i += samples_per_symbol) {
|
||||
std::complex<double> symbol_avg(0.0, 0.0);
|
||||
for (size_t j = 0; j < samples_per_symbol; ++j) {
|
||||
symbol_avg += baseband_IQ[i + j];
|
||||
}
|
||||
symbol_avg /= static_cast<double>(samples_per_symbol);
|
||||
|
||||
// Detect symbol from averaged signal
|
||||
baseband_symbols.emplace_back(phase_detector.getSymbol(symbol_avg));
|
||||
}
|
||||
|
||||
return baseband_symbols;
|
||||
|
||||
Reference in New Issue
Block a user