diff --git a/core/src/credits.cpp b/core/src/credits.cpp index b30d7bb3..2cc93477 100644 --- a/core/src/credits.cpp +++ b/core/src/credits.cpp @@ -22,6 +22,7 @@ namespace sdrpp_credits { "Syne Ardwin (WI9SYN)", "Szymon Zakrent", "Tobias Mädel", + "Youssef Touil", "Zimm" }; diff --git a/core/src/dsp/loop/carrier_tracking_pll.h b/core/src/dsp/loop/carrier_tracking_pll.h new file mode 100644 index 00000000..1790f007 --- /dev/null +++ b/core/src/dsp/loop/carrier_tracking_pll.h @@ -0,0 +1,16 @@ +#pragma once +#include "pll.h" + +namespace dsp::loop { + class CarrierTrackingPLL : public PLL { + using base_type = PLL; + public: + inline int process(int count, complex_t* in, complex_t* out) { + for (int i = 0; i < count; i++) { + out[i] = in[i] * math::phasor(-pcl.phase); + pcl.advance(math::normPhaseDiff(in[i].phase() - pcl.phase)); + } + return count; + } + }; +} \ No newline at end of file diff --git a/core/src/dsp/loop/costas.h b/core/src/dsp/loop/costas.h new file mode 100644 index 00000000..29475646 --- /dev/null +++ b/core/src/dsp/loop/costas.h @@ -0,0 +1,41 @@ +#pragma once +#include "pll.h" +#include "../math/step.h" + +namespace dsp::loop { + template + class Costas : public PLL { + static_assert(ORDER == 2 || ORDER == 4 || ORDER == 8, "Invalid costas order"); + using base_type = PLL; + public: + inline int process(int count, complex_t* in, complex_t* out) { + for (int i = 0; i < count; i++) { + out[i] = in[i] * math::phasor(-pcl.phase); + pcl.advance(errorFunction(out[i])); + } + return count; + } + + protected: + inline float errorFunction(complex_t val) { + float err; + if constexpr (ORDER == 2) { + err = val.re * val.im; + } + if constexpr (ORDER == 4) { + err = (math::step(val.re) * val.im) - (math::step(val.im) * val.re); + } + if constexpr (ORDER == 8) { + // The way this works is it compresses order 4 constellations into the quadrants + const float K = sqrtf(2.0) - 1.0; + if (fabsf(outVal.re) >= fabsf(outVal.im)) { + err = (math::step(val.re) * val.im) - (math::step(val.im) * val.re * K); + } + else { + err = (math::step(val.re) * val.im * K) - (math::step(val.im) * val.re); + } + } + return std::clamp(err, -1.0f, 1.0f); + } + }; +} \ No newline at end of file diff --git a/core/src/dsp/loop/pll.h b/core/src/dsp/loop/pll.h index d3b9c197..47d4170a 100644 --- a/core/src/dsp/loop/pll.h +++ b/core/src/dsp/loop/pll.h @@ -61,7 +61,7 @@ namespace dsp::loop { base_type::tempStart(); } - inline int process(int count, complex_t* in, complex_t* out) { + virtual inline int process(int count, complex_t* in, complex_t* out) { for (int i = 0; i < count; i++) { out[i] = math::phasor(pcl.phase); pcl.advance(math::normPhaseDiff(in[i].phase() - pcl.phase)); diff --git a/core/src/dsp/math/step.h b/core/src/dsp/math/step.h new file mode 100644 index 00000000..961308f9 --- /dev/null +++ b/core/src/dsp/math/step.h @@ -0,0 +1,8 @@ +#pragma once + +namespace dsp::math { + template + inline T step(T x) { + return (x > 0.0) ? 1.0 : -1.0; + } +} \ No newline at end of file diff --git a/core/src/dsp/multirate/decim/plans.h b/core/src/dsp/multirate/decim/plans.h index 94a82781..7e2f2697 100644 --- a/core/src/dsp/multirate/decim/plans.h +++ b/core/src/dsp/multirate/decim/plans.h @@ -14,7 +14,10 @@ #include "taps/fir_8_4.h" /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. + It uses an implementation of Youssef Touil's optimized plan generation algo, see + generation code for more info. + DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_1024_64.h b/core/src/dsp/multirate/decim/taps/fir_1024_64.h index 110cb080..65827548 100644 --- a/core/src/dsp/multirate/decim/taps/fir_1024_64.h +++ b/core/src/dsp/multirate/decim/taps/fir_1024_64.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_128_16.h b/core/src/dsp/multirate/decim/taps/fir_128_16.h index 878cc705..bc86ca2d 100644 --- a/core/src/dsp/multirate/decim/taps/fir_128_16.h +++ b/core/src/dsp/multirate/decim/taps/fir_128_16.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_16_8.h b/core/src/dsp/multirate/decim/taps/fir_16_8.h index d1a21961..1e56b538 100644 --- a/core/src/dsp/multirate/decim/taps/fir_16_8.h +++ b/core/src/dsp/multirate/decim/taps/fir_16_8.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_2048_64.h b/core/src/dsp/multirate/decim/taps/fir_2048_64.h index a583dfb6..a6251991 100644 --- a/core/src/dsp/multirate/decim/taps/fir_2048_64.h +++ b/core/src/dsp/multirate/decim/taps/fir_2048_64.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_256_32.h b/core/src/dsp/multirate/decim/taps/fir_256_32.h index d47c58ed..c8ada297 100644 --- a/core/src/dsp/multirate/decim/taps/fir_256_32.h +++ b/core/src/dsp/multirate/decim/taps/fir_256_32.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_2_2.h b/core/src/dsp/multirate/decim/taps/fir_2_2.h index bc9ac46e..7438a947 100644 --- a/core/src/dsp/multirate/decim/taps/fir_2_2.h +++ b/core/src/dsp/multirate/decim/taps/fir_2_2.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_32_8.h b/core/src/dsp/multirate/decim/taps/fir_32_8.h index 31b9e6f0..e382ae7f 100644 --- a/core/src/dsp/multirate/decim/taps/fir_32_8.h +++ b/core/src/dsp/multirate/decim/taps/fir_32_8.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_4096_64.h b/core/src/dsp/multirate/decim/taps/fir_4096_64.h index 071fa7c7..15d1fe7e 100644 --- a/core/src/dsp/multirate/decim/taps/fir_4096_64.h +++ b/core/src/dsp/multirate/decim/taps/fir_4096_64.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_4_2.h b/core/src/dsp/multirate/decim/taps/fir_4_2.h index d5658460..f945bb40 100644 --- a/core/src/dsp/multirate/decim/taps/fir_4_2.h +++ b/core/src/dsp/multirate/decim/taps/fir_4_2.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_512_32.h b/core/src/dsp/multirate/decim/taps/fir_512_32.h index 0ce8baa7..c058c17a 100644 --- a/core/src/dsp/multirate/decim/taps/fir_512_32.h +++ b/core/src/dsp/multirate/decim/taps/fir_512_32.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_64_8.h b/core/src/dsp/multirate/decim/taps/fir_64_8.h index 7e19493a..755d7671 100644 --- a/core/src/dsp/multirate/decim/taps/fir_64_8.h +++ b/core/src/dsp/multirate/decim/taps/fir_64_8.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_8192_128.h b/core/src/dsp/multirate/decim/taps/fir_8192_128.h index c547d944..15f64177 100644 --- a/core/src/dsp/multirate/decim/taps/fir_8192_128.h +++ b/core/src/dsp/multirate/decim/taps/fir_8192_128.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/core/src/dsp/multirate/decim/taps/fir_8_4.h b/core/src/dsp/multirate/decim/taps/fir_8_4.h index a01aaaa5..5f0dc5e3 100644 --- a/core/src/dsp/multirate/decim/taps/fir_8_4.h +++ b/core/src/dsp/multirate/decim/taps/fir_8_4.h @@ -1,7 +1,7 @@ #pragma once /* - This file was auto-generated by Ryzerth's magic optimized FIR script. + This file was auto-generated by the magic optimized FIR script. DO NOT EDIT MANUALLY!!! */ diff --git a/readme.md b/readme.md index 37d4d8af..14ed3e4e 100644 --- a/readme.md +++ b/readme.md @@ -449,6 +449,7 @@ I will soon publish a contributing.md listing the code style to use. * [Syne Ardwin (WI9SYN)](https://esaille.me/) * [Szymon Zakrent](https://github.com/zakrent) * [Tobias Mädel](https://github.com/Manawyrm) +* Youssef Touil * [Zimm](https://github.com/invader-zimm)