mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
added Hilbert transform filter
This commit is contained in:
parent
d44f88352c
commit
8d3a6e83d8
2 changed files with 16 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ Implemented are the following [finite impulse response](https://en.wikipedia.org
|
|||
* [low-pass filter](https://en.wikipedia.org/wiki/Low-pass_filter)
|
||||
* [high-pass filter](https://en.wikipedia.org/wiki/High-pass_filter)
|
||||
* [band-pass filter](https://en.wikipedia.org/wiki/Band-pass_filter)
|
||||
* [Hilbert-transform filter](https://en.wikipedia.org/wiki/Hilbert_transform)
|
||||
|
||||
### [ema.hh](ema.hh)
|
||||
|
||||
|
|
|
|||
15
filter.hh
15
filter.hh
|
|
@ -87,5 +87,20 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct HilbertTransform
|
||||
{
|
||||
TYPE operator () (int n, int N)
|
||||
{
|
||||
if (N&1) {
|
||||
int x = n - (N - 1) / 2;
|
||||
return x&1 ? TYPE(2) / (Const<TYPE>::Pi() * TYPE(x)) : TYPE(0);
|
||||
} else {
|
||||
TYPE x = TYPE(n) - TYPE(0.5) * TYPE(N - 1);
|
||||
return TYPE(1) / (Const<TYPE>::Pi() * x);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue