mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-11 10:47:11 +01:00
Fixes to filtering
This commit is contained in:
parent
3bf4f0ce01
commit
d1e553f05a
@ -123,8 +123,10 @@ namespace dsp {
|
||||
|
||||
level = pow(10, ((10.0f * log10f(level)) - (_CorrectedFallRate * count)) / 10.0f);
|
||||
|
||||
float absVal;
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (_in->readBuf[i] > level) { level = _in->readBuf[i]; }
|
||||
absVal = fabsf(_in->readBuf[i]);
|
||||
if (absVal > level) { level = absVal; }
|
||||
}
|
||||
|
||||
volk_32f_s32f_multiply_32f(out.writeBuf, _in->readBuf, 1.0f / level, count);
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
namespace dsp {
|
||||
namespace math {
|
||||
inline float sinc(float omega, float x, float norm) {
|
||||
return (x == 0.0f) ? 1.0f : (sinf(omega*x)/(norm*x));
|
||||
inline double sinc(double omega, double x, double norm) {
|
||||
return (x == 0.0f) ? 1.0f : (sin(omega*x)/(norm*x));
|
||||
}
|
||||
}
|
||||
}
|
@ -3,25 +3,25 @@
|
||||
|
||||
namespace dsp {
|
||||
namespace window_function {
|
||||
inline float blackman(float n, float N, float alpha = 0.16f) {
|
||||
float a0 = (1.0f-alpha) / 2.0f;
|
||||
float a2 = alpha / 2.0f;
|
||||
return a0 - (0.5f*cosf(2.0f*FL_M_PI*(n/N))) + (a2*cosf(4.0f*FL_M_PI*(n/N)));
|
||||
inline double blackman(double n, double N, double alpha = 0.16f) {
|
||||
double a0 = (1.0f-alpha) / 2.0f;
|
||||
double a2 = alpha / 2.0f;
|
||||
return a0 - (0.5f*cos(2.0f*FL_M_PI*(n/N))) + (a2*cos(4.0f*FL_M_PI*(n/N)));
|
||||
}
|
||||
|
||||
inline float blackmanThirdOrder(float n, float N, float a0, float a1, float a2, float a3) {
|
||||
return a0 - (a1*cosf(2.0f*FL_M_PI*(n/N))) + (a2*cosf(4.0f*FL_M_PI*(n/N))) - (a3*cosf(6.0f*FL_M_PI*(n/N)));
|
||||
inline double blackmanThirdOrder(double n, double N, double a0, double a1, double a2, double a3) {
|
||||
return a0 - (a1*cos(2.0f*FL_M_PI*(n/N))) + (a2*cos(4.0f*FL_M_PI*(n/N))) - (a3*cos(6.0f*FL_M_PI*(n/N)));
|
||||
}
|
||||
|
||||
inline float nuttall(float n, float N) {
|
||||
inline double nuttall(double n, double N) {
|
||||
return blackmanThirdOrder(n, N, 0.3635819f, 0.4891775f, 0.1365995f, 0.0106411f);
|
||||
}
|
||||
|
||||
inline float blackmanNuttall(float n, float N) {
|
||||
inline double blackmanNuttall(double n, double N) {
|
||||
return blackmanThirdOrder(n, N, 0.3635819f, 0.4891775f, 0.1365995f, 0.0106411f);
|
||||
}
|
||||
|
||||
inline float blackmanHarris(float n, float N) {
|
||||
inline double blackmanHarris(double n, double N) {
|
||||
return blackmanThirdOrder(n, N, 0.35875f, 0.48829f, 0.14128f, 0.01168f);
|
||||
}
|
||||
}
|
||||
|
@ -51,38 +51,21 @@ namespace dsp {
|
||||
}
|
||||
|
||||
void createTaps(float* taps, int tapCount, float factor = 1.0f) {
|
||||
// // Calculate cuttoff frequency
|
||||
// float omega = 2.0f * FL_M_PI * (_cutoff / _sampleRate);
|
||||
// if (omega > FL_M_PI) { omega = FL_M_PI; }
|
||||
// Calculate cuttoff frequency
|
||||
float omega = 2.0f * FL_M_PI * (_cutoff / _sampleRate);
|
||||
if (omega > FL_M_PI) { omega = FL_M_PI; }
|
||||
|
||||
// // Generate taps
|
||||
// float val;
|
||||
// float sum = 0.0f;
|
||||
// for (int i = 0; i < tapCount; i++) {
|
||||
// val = math::sinc(omega, i-(tapCount/2), FL_M_PI) * window_function::blackman(i, tapCount - 1);
|
||||
// taps[i] = val;
|
||||
// sum += val;
|
||||
// }
|
||||
|
||||
// // Normalize taps and multiply by supplied factor
|
||||
// for (int i = 0; i < tapCount; i++) {
|
||||
// taps[i] *= factor;
|
||||
// taps[i] /= sum;
|
||||
// }
|
||||
|
||||
float fc = _cutoff / _sampleRate;
|
||||
if (fc > 1.0f) {
|
||||
fc = 1.0f;
|
||||
}
|
||||
float tc = tapCount;
|
||||
float sum = 0.0f;
|
||||
// Generate taps
|
||||
float val;
|
||||
float sum = 0.0f;
|
||||
float tc = tapCount;
|
||||
for (int i = 0; i < tapCount; i++) {
|
||||
val = (sin(2.0f * FL_M_PI * fc * ((float)i - (tc / 2))) / ((float)i - (tc / 2))) *
|
||||
(0.42f - (0.5f * cos(2.0f * FL_M_PI / tc)) + (0.8f * cos(4.0f * FL_M_PI / tc)));
|
||||
taps[i] = val; // tapCount - i - 1
|
||||
val = math::sinc(omega, (float)i - (tc/2), FL_M_PI) * window_function::blackman(i, tc - 1);
|
||||
taps[i] = val;
|
||||
sum += val;
|
||||
}
|
||||
|
||||
// Normalize taps and multiply by supplied factor
|
||||
for (int i = 0; i < tapCount; i++) {
|
||||
taps[i] *= factor;
|
||||
taps[i] /= sum;
|
||||
|
@ -939,6 +939,9 @@ namespace ImGui {
|
||||
|
||||
rectMin = ImVec2(widgetPos.x + 50 + left, widgetPos.y + 10);
|
||||
rectMax = ImVec2(widgetPos.x + 51 + right, widgetPos.y + fftHeight + 10);
|
||||
|
||||
lbwSelMin = ImVec2(rectMin.x - 1, rectMin.y);
|
||||
lbwSelMax = ImVec2(rectMin.x + 1, rectMax.y);
|
||||
}
|
||||
|
||||
void WaterfallVFO::draw(ImGuiWindow* window, bool selected) {
|
||||
|
@ -42,6 +42,14 @@ namespace ImGui {
|
||||
ImVec2 wfRectMax;
|
||||
ImVec2 wfLineMin;
|
||||
ImVec2 wfLineMax;
|
||||
ImVec2 lbwSelMin;
|
||||
ImVec2 lbwSelMax;
|
||||
ImVec2 rbwSelMin;
|
||||
ImVec2 rbwSelMax;
|
||||
ImVec2 wfLbwSelMin;
|
||||
ImVec2 wfLbwSelMax;
|
||||
ImVec2 wfRbwSelMin;
|
||||
ImVec2 wfRbwSelMax;
|
||||
|
||||
bool centerOffsetChanged = false;
|
||||
bool lowerOffsetChanged = false;
|
||||
|
10
root/res/colormaps/electric.json
Normal file
10
root/res/colormaps/electric.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "Electric",
|
||||
"author": "Ryzerth",
|
||||
"map": [
|
||||
"#000000",
|
||||
"#0000FF",
|
||||
"#00FFFF",
|
||||
"#FFFFFF"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user