mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
FFT filter: removed useless code and some fixes
This commit is contained in:
parent
66d4c665c8
commit
e070b73104
@ -159,46 +159,6 @@ void fftfilt::create_filter(float f1, float f2, FFTWindow::Function wf)
|
||||
}
|
||||
}
|
||||
|
||||
void fftfilt::create_filter(const std::vector<std::pair<float, float>>& limits, bool pass)
|
||||
{
|
||||
// initialize the filter canvas
|
||||
std::vector<int> canvas(flen, pass ? 0 : 1);
|
||||
fftfilt::cmplx* xfilter = new fftfilt::cmplx[flen];
|
||||
|
||||
for (const auto& fs : limits)
|
||||
{
|
||||
const float& f1 = fs.first + 0.5;
|
||||
const float& w = fs.second > 0.0 ? fs.second : 0.0;
|
||||
const float& f2 = f1 + w;
|
||||
|
||||
for (int i = 0; i < flen; i++)
|
||||
{
|
||||
if (pass) // pass
|
||||
{
|
||||
if ((i >= f1*flen) && (i <= f2*flen)) {
|
||||
canvas[i] = 1;
|
||||
}
|
||||
}
|
||||
else // reject
|
||||
{
|
||||
if ((i >= f1*flen) && (i <= f2*flen)) {
|
||||
canvas[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < flen; i++) {
|
||||
xfilter[i] = cmplx(canvas[i], 0);
|
||||
}
|
||||
|
||||
// Rearrange
|
||||
std::copy(&xfilter[flen2], &xfilter[flen-1], filter);
|
||||
std::copy(&xfilter[0], &xfilter[flen2-1], &filter[flen2]);
|
||||
|
||||
delete[] xfilter;
|
||||
}
|
||||
|
||||
void fftfilt::create_filter(const std::vector<std::pair<float, float>>& limits, bool pass, FFTWindow::Function wf)
|
||||
{
|
||||
std::vector<int> canvasNeg(flen2, pass ? 0 : 1); // initialize the negative frequencies filter canvas
|
||||
@ -281,6 +241,10 @@ void fftfilt::create_filter(const std::vector<std::pair<float, float>>& limits,
|
||||
filter[i] -= fsinc(f1, i, flen2);
|
||||
}
|
||||
}
|
||||
|
||||
if (f2 == 0 && f1 != 0) {
|
||||
filter[flen2 / 2] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& indexes : indexesNegList)
|
||||
@ -297,6 +261,10 @@ void fftfilt::create_filter(const std::vector<std::pair<float, float>>& limits,
|
||||
filterOpp[i] -= fsinc(f1, i, flen2);
|
||||
}
|
||||
}
|
||||
|
||||
if (f2 == 0 && f1 != 0) {
|
||||
filterOpp[flen2 / 2] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
FFTWindow fwin;
|
||||
|
Loading…
Reference in New Issue
Block a user