More cleanup

This commit is contained in:
AlexandreRouma 2022-06-26 23:36:31 +02:00
parent 3f6687659e
commit ff6754099f
20 changed files with 85 additions and 15 deletions

View File

@ -22,6 +22,7 @@ namespace sdrpp_credits {
"Syne Ardwin (WI9SYN)", "Syne Ardwin (WI9SYN)",
"Szymon Zakrent", "Szymon Zakrent",
"Tobias Mädel", "Tobias Mädel",
"Youssef Touil",
"Zimm" "Zimm"
}; };

View File

@ -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;
}
};
}

View File

@ -0,0 +1,41 @@
#pragma once
#include "pll.h"
#include "../math/step.h"
namespace dsp::loop {
template<int ORDER>
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<float>(err, -1.0f, 1.0f);
}
};
}

View File

@ -61,7 +61,7 @@ namespace dsp::loop {
base_type::tempStart(); 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++) { for (int i = 0; i < count; i++) {
out[i] = math::phasor(pcl.phase); out[i] = math::phasor(pcl.phase);
pcl.advance(math::normPhaseDiff(in[i].phase() - pcl.phase)); pcl.advance(math::normPhaseDiff(in[i].phase() - pcl.phase));

8
core/src/dsp/math/step.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
namespace dsp::math {
template <class T>
inline T step(T x) {
return (x > 0.0) ? 1.0 : -1.0;
}
}

View File

@ -14,7 +14,10 @@
#include "taps/fir_8_4.h" #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -1,7 +1,7 @@
#pragma once #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!!! DO NOT EDIT MANUALLY!!!
*/ */

View File

@ -449,6 +449,7 @@ I will soon publish a contributing.md listing the code style to use.
* [Syne Ardwin (WI9SYN)](https://esaille.me/) * [Syne Ardwin (WI9SYN)](https://esaille.me/)
* [Szymon Zakrent](https://github.com/zakrent) * [Szymon Zakrent](https://github.com/zakrent)
* [Tobias Mädel](https://github.com/Manawyrm) * [Tobias Mädel](https://github.com/Manawyrm)
* Youssef Touil
* [Zimm](https://github.com/invader-zimm) * [Zimm](https://github.com/invader-zimm)