mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 22:35:45 +00:00
removed CoeffsFunc
This commit is contained in:
parent
98a5a204d1
commit
7b2cf8970a
3 changed files with 14 additions and 21 deletions
13
coeffs.hh
13
coeffs.hh
|
|
@ -8,24 +8,19 @@ Copyright 2018 Ahmet Inan <inan@aicodix.de>
|
|||
|
||||
namespace DSP {
|
||||
|
||||
template <typename TYPE>
|
||||
struct CoeffsFunc
|
||||
{
|
||||
virtual TYPE operator () (int, int) = 0;
|
||||
virtual ~CoeffsFunc() = default;
|
||||
};
|
||||
|
||||
template <int TAPS, typename TYPE>
|
||||
class Coeffs
|
||||
{
|
||||
TYPE w[TAPS];
|
||||
public:
|
||||
Coeffs(CoeffsFunc<TYPE> *func)
|
||||
template <typename FUNC>
|
||||
Coeffs(FUNC *func)
|
||||
{
|
||||
for (int n = 0; n < TAPS; ++n)
|
||||
w[n] = (*func)(n, TAPS);
|
||||
}
|
||||
Coeffs(CoeffsFunc<TYPE> *func0, CoeffsFunc<TYPE> *func1)
|
||||
template <typename FUNC0, typename FUNC1>
|
||||
Coeffs(FUNC0 *func0, FUNC1 *func1)
|
||||
{
|
||||
for (int n = 0; n < TAPS; ++n)
|
||||
w[n] = (*func0)(n, TAPS) * (*func1)(n, TAPS);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@ Copyright 2018 Ahmet Inan <inan@aicodix.de>
|
|||
|
||||
#include "const.hh"
|
||||
#include "utils.hh"
|
||||
#include "coeffs.hh"
|
||||
|
||||
namespace DSP {
|
||||
|
||||
template <typename TYPE>
|
||||
class LowPass : public CoeffsFunc<TYPE>
|
||||
class LowPass
|
||||
{
|
||||
TYPE f;
|
||||
public:
|
||||
|
|
@ -26,7 +25,7 @@ public:
|
|||
};
|
||||
|
||||
template <typename TYPE>
|
||||
class HighPass : public CoeffsFunc<TYPE>
|
||||
class HighPass
|
||||
{
|
||||
TYPE f;
|
||||
public:
|
||||
|
|
@ -41,7 +40,7 @@ public:
|
|||
};
|
||||
|
||||
template <typename TYPE>
|
||||
class BandPass : public CoeffsFunc<TYPE>
|
||||
class BandPass
|
||||
{
|
||||
TYPE f0, f1;
|
||||
public:
|
||||
|
|
|
|||
15
window.hh
15
window.hh
|
|
@ -10,18 +10,17 @@ Copyright 2018 Ahmet Inan <inan@aicodix.de>
|
|||
#include "kahan.hh"
|
||||
#include "utils.hh"
|
||||
#include "unit_circle.hh"
|
||||
#include "coeffs.hh"
|
||||
|
||||
namespace DSP {
|
||||
|
||||
template <typename TYPE>
|
||||
struct Rect : public CoeffsFunc<TYPE>
|
||||
struct Rect
|
||||
{
|
||||
TYPE operator () (int n, int N) { return n >= 0 && n < N ? 1 : 0; }
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct Hann : public CoeffsFunc<TYPE>
|
||||
struct Hann
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
{
|
||||
|
|
@ -30,7 +29,7 @@ struct Hann : public CoeffsFunc<TYPE>
|
|||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct Hamming : public CoeffsFunc<TYPE>
|
||||
struct Hamming
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
{
|
||||
|
|
@ -39,7 +38,7 @@ struct Hamming : public CoeffsFunc<TYPE>
|
|||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct Lanczos : public CoeffsFunc<TYPE>
|
||||
struct Lanczos
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
{
|
||||
|
|
@ -53,7 +52,7 @@ struct Lanczos : public CoeffsFunc<TYPE>
|
|||
};
|
||||
|
||||
template <typename TYPE>
|
||||
class Blackman : public CoeffsFunc<TYPE>
|
||||
class Blackman
|
||||
{
|
||||
TYPE a0, a1, a2;
|
||||
public:
|
||||
|
|
@ -68,7 +67,7 @@ public:
|
|||
};
|
||||
|
||||
template <typename TYPE>
|
||||
class Gauss : public CoeffsFunc<TYPE>
|
||||
class Gauss
|
||||
{
|
||||
TYPE o;
|
||||
public:
|
||||
|
|
@ -80,7 +79,7 @@ public:
|
|||
};
|
||||
|
||||
template <typename TYPE>
|
||||
class Kaiser : public CoeffsFunc<TYPE>
|
||||
class Kaiser
|
||||
{
|
||||
TYPE a;
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue