mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
added DC blocker
This commit is contained in:
parent
a87ee25f66
commit
73f69e0faa
2 changed files with 38 additions and 0 deletions
|
|
@ -41,6 +41,10 @@ The following [infinite impulse response](https://en.wikipedia.org/wiki/Infinite
|
|||
* [2n-order Butterworth cascade of second-order low or high pass filters](https://en.wikipedia.org/wiki/Butterworth_filter)
|
||||
* [second-order notch filter](https://en.wikipedia.org/wiki/Band-stop_filter)
|
||||
|
||||
### [blockdc.hh](blockdc.hh)
|
||||
|
||||
A [notch filter at DC](https://en.wikipedia.org/wiki/Band-stop_filter) helps removing [DC bias](https://en.wikipedia.org/wiki/DC_bias).
|
||||
|
||||
### [phasor.hh](phasor.hh)
|
||||
|
||||
[Numerically controlled oscillator](https://en.wikipedia.org/wiki/Numerically_controlled_oscillator) implemented using a [phasor](https://en.wikipedia.org/wiki/Phasor) and [complex multiplication](https://en.wikipedia.org/wiki/Complex_number#Multiplication) instead of a [lookup table](https://en.wikipedia.org/wiki/Lookup_table).
|
||||
|
|
|
|||
34
blockdc.hh
Normal file
34
blockdc.hh
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
DC Blocker
|
||||
|
||||
Copyright 2019 Ahmet Inan <inan@aicodix.de>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace DSP {
|
||||
|
||||
template <typename TYPE, typename VALUE>
|
||||
class BlockDC
|
||||
{
|
||||
TYPE x1, y1;
|
||||
VALUE a, b;
|
||||
public:
|
||||
constexpr BlockDC() : x1(0), y1(0), a(0), b(0.5)
|
||||
{
|
||||
}
|
||||
void samples(int s)
|
||||
{
|
||||
a = VALUE(s - 1) / VALUE(s);
|
||||
b = (VALUE(1) + a) / VALUE(2);
|
||||
}
|
||||
TYPE operator()(TYPE x0)
|
||||
{
|
||||
TYPE y0 = b * (x0 - x1) + a * y1;
|
||||
x1 = x0; y1 = y0;
|
||||
return y0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue