mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
made methods const
This commit is contained in:
parent
0427f29ce5
commit
d7acee8494
2 changed files with 13 additions and 13 deletions
12
filter.hh
12
filter.hh
|
|
@ -18,7 +18,7 @@ class LowPass
|
|||
TYPE f;
|
||||
public:
|
||||
LowPass(TYPE cutoff) : f(TYPE(2) * cutoff) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
TYPE x = TYPE(n) - TYPE(0.5) * TYPE(N - 1);
|
||||
return f * sinc(f * x);
|
||||
|
|
@ -32,7 +32,7 @@ class LowPass2
|
|||
TYPE fac;
|
||||
public:
|
||||
LowPass2(int num, int den) : num(num), den(den), fac(TYPE(2*num)/TYPE(den)) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
int twox = 2 * n - (N - 1);
|
||||
return !twox ? fac : fac *
|
||||
|
|
@ -47,7 +47,7 @@ class HighPass
|
|||
TYPE f;
|
||||
public:
|
||||
HighPass(TYPE cutoff) : f(TYPE(2) * cutoff) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
TYPE x = TYPE(n) - TYPE(0.5) * TYPE(N - 1);
|
||||
// if (N%1) return delta(x) - f * sinc(f * x);
|
||||
|
|
@ -63,7 +63,7 @@ class HighPass2
|
|||
TYPE fac;
|
||||
public:
|
||||
HighPass2(int num, int den) : num(num), den(den), fac(TYPE(2*num)/TYPE(den)) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
int twox = 2 * n - (N - 1);
|
||||
return !twox ? TYPE(1) - fac :
|
||||
|
|
@ -80,7 +80,7 @@ class BandPass
|
|||
public:
|
||||
BandPass(TYPE cutoff0, TYPE cutoff1) :
|
||||
f0(TYPE(2) * cutoff0), f1(TYPE(2) * cutoff1) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
TYPE x = TYPE(n) - TYPE(0.5) * TYPE(N - 1);
|
||||
return f1 * sinc(f1 * x) - f0 * sinc(f0 * x);
|
||||
|
|
@ -90,7 +90,7 @@ public:
|
|||
template <typename TYPE>
|
||||
struct HilbertTransform
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
if (N&1) {
|
||||
int x = n - (N - 1) / 2;
|
||||
|
|
|
|||
14
window.hh
14
window.hh
|
|
@ -16,13 +16,13 @@ namespace DSP {
|
|||
template <typename TYPE>
|
||||
struct Rect
|
||||
{
|
||||
TYPE operator () (int n, int N) { return n >= 0 && n < N ? 1 : 0; }
|
||||
TYPE operator () (int n, int N) const { return n >= 0 && n < N ? 1 : 0; }
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct Hann
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
return TYPE(0.5) * (TYPE(1) - UnitCircle<TYPE>::cos(n, N - 1));
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ struct Hann
|
|||
template <typename TYPE>
|
||||
struct Hamming
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
return TYPE(0.54) - TYPE(0.46) * UnitCircle<TYPE>::cos(n, N - 1);
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ struct Hamming
|
|||
template <typename TYPE>
|
||||
struct Lanczos
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
#if 0
|
||||
return sinc(TYPE(2 * n) / TYPE(N - 1) - TYPE(1));
|
||||
|
|
@ -60,7 +60,7 @@ public:
|
|||
Blackman(TYPE a) : Blackman((TYPE(1) - a) / TYPE(2), TYPE(0.5), a / TYPE(2)) {}
|
||||
// "exact Blackman"
|
||||
Blackman() : Blackman(TYPE(7938) / TYPE(18608), TYPE(9240) / TYPE(18608), TYPE(1430) / TYPE(18608)) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
return a0 - a1 * UnitCircle<TYPE>::cos(n, N-1) + a2 * UnitCircle<TYPE>::cos((2*n)%(N-1), N-1);
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ class Gauss
|
|||
TYPE o;
|
||||
public:
|
||||
Gauss(TYPE o) : o(o) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
return exp(- TYPE(0.5) * pow((TYPE(n) - TYPE(N - 1) / TYPE(2)) / (o * TYPE(N - 1) / TYPE(2)), TYPE(2)));
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ class Kaiser
|
|||
}
|
||||
public:
|
||||
Kaiser(TYPE a) : a(a) {}
|
||||
TYPE operator () (int n, int N)
|
||||
TYPE operator () (int n, int N) const
|
||||
{
|
||||
return i0(Const<TYPE>::Pi() * a * sqrt(TYPE(1) - sqr(TYPE(2 * n) / TYPE(N - 1) - TYPE(1)))) / i0(Const<TYPE>::Pi() * a);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue