Futher WIP
This commit is contained in:
parent
836fa2eb40
commit
9ef1c226c7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,14 @@ SincLowpass(int npoints, double corner, double gain)
|
|||
|
||||
|
||||
|
||||
Filter
|
||||
BlackmanLowpass(int npoints, double corner, double gain)
|
||||
{
|
||||
return Filter(fir_blackman_lowpass(npoints, corner, gain));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Filter
|
||||
LanczosLowpass(int npoints, double corner, double gain, int a)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,8 @@ Filter SincLowpass(int npoints, double corner, double gain);
|
|||
|
||||
|
||||
|
||||
Filter BlackmanLowpass(int npoints, double corner, double gain);
|
||||
|
||||
Filter LanczosLowpass(int npoints, double corner, double gain, int a);
|
||||
|
||||
|
||||
|
|
|
@ -7,8 +7,27 @@
|
|||
|
||||
|
||||
|
||||
struct fir_filter_t*
|
||||
fir_sinc_lowpass(int npoints, double corner, double gain)
|
||||
static double
|
||||
window_rectangle(int n, int N)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static double
|
||||
window_blackman(int n, int N)
|
||||
{
|
||||
double v = 2 * M_PI * n;
|
||||
v /= N;
|
||||
return 0.42 - 0.5 * cos(v) + 0.08 * cos(2 * v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct fir_filter_t*
|
||||
fir_windowed_lowpass(int npoints, double corner, double gain,
|
||||
double (*window)(int n, int N))
|
||||
{
|
||||
double* coeff, t, sum = 0;
|
||||
int i, spoints;
|
||||
|
@ -25,12 +44,12 @@ fir_sinc_lowpass(int npoints, double corner, double gain)
|
|||
/* only fill out for t ≤ 0 */
|
||||
for(i = 0; i < spoints; ++i) {
|
||||
if((i * 2 + 1) == npoints) {
|
||||
coeff[i] = 1;
|
||||
sum += 1; /* not 2, as we don't repeat this coeff */
|
||||
coeff[i] = window(i, npoints) * 1;
|
||||
sum += coeff[i]; /* not 2, as we don't repeat this coeff */
|
||||
} else {
|
||||
t = i + 0.5 - npoints * 0.5;
|
||||
t *= corner * 2 * M_PI;
|
||||
coeff[i] = sin(t) / t;
|
||||
coeff[i] = window(i, npoints) * sin(t) / t;
|
||||
sum += coeff[i] * 2;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +66,22 @@ fir_sinc_lowpass(int npoints, double corner, double gain)
|
|||
|
||||
|
||||
|
||||
struct fir_filter_t*
|
||||
fir_sinc_lowpass(int npoints, double corner, double gain)
|
||||
{
|
||||
return fir_windowed_lowpass(npoints, corner, gain, window_rectangle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct fir_filter_t*
|
||||
fir_blackman_lowpass(int npoints, double corner, double gain)
|
||||
{
|
||||
return fir_windowed_lowpass(npoints, corner, gain, window_blackman);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct fir_filter_t*
|
||||
fir_lanczos_lowpass(int npoints, double corner, double gain, int a)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,10 @@ struct fir_filter_t* fir_lanczos_lowpass(int npoints, double corner, double gain
|
|||
|
||||
|
||||
|
||||
struct fir_filter_t* fir_blackman_lowpass(int npoints, double corner, double gain);
|
||||
|
||||
|
||||
|
||||
/*!@}*/
|
||||
/* options for text editors
|
||||
vim: expandtab:ts=4:sw=4:syntax=ch.doxygen
|
||||
|
|
Loading…
Reference in New Issue