diff --git a/decode.cc b/decode.cc index c578ac8..99a1494 100644 --- a/decode.cc +++ b/decode.cc @@ -226,8 +226,14 @@ struct Decoder : Common demod[i] *= DSP::polar(1, -tse(i+tone_off)); for (int i = 0; i < tone_count; ++i) chan[i] *= DSP::polar(1, tse(i+tone_off)); - for (int i = pilot_off; i < tone_count; i += block_length) - chan[i] = DSP::lerp(chan[i], tone[i], value(0.5)); + if (differential) { + for (int i = 0; i < tone_count; ++i) + if (i % block_length != reserved_off) + chan[i] = fdom[bin(i+tone_off)]; + } else { + for (int i = pilot_off; i < tone_count; i += block_length) + chan[i] = DSP::lerp(chan[i], tone[i], value(0.5)); + } value sp = 0, np = 0; for (int i = 0; i < pilot_tones; ++i) { cmplx hard(1, 0); diff --git a/encode.cc b/encode.cc index 85de1be..e24b339 100644 --- a/encode.cc +++ b/encode.cc @@ -37,6 +37,7 @@ struct Encoder : public Common cmplx kern[symbol_len]; cmplx guard[guard_len]; cmplx tone[tone_count]; + cmplx prev[tone_count]; value weight[guard_len]; value papr_min, papr_max; @@ -93,6 +94,11 @@ struct Encoder : public Common } void symbol(bool papr_reduction = true, bool guard_interval = true) { + for (int i = 0; differential && i < tone_count; ++i) + if (!papr_reduction) + prev[i] = 1; + else if (i % block_length != reserved_off) + prev[i] = tone[i] *= prev[i]; for (int i = 0; i < symbol_len; ++i) fdom[i] = 0; for (int i = 0; i < tone_count; ++i)