mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
unwrap delta
This commit is contained in:
parent
99baec64a5
commit
6fc424dca6
1 changed files with 9 additions and 0 deletions
9
fmd.hh
9
fmd.hh
|
|
@ -15,6 +15,14 @@ class FMD1
|
|||
typedef typename complex_type::value_type value_type;
|
||||
value_type prev;
|
||||
value_type scale;
|
||||
value_type unwrap(value_type angle)
|
||||
{
|
||||
if (angle < -DSP::Const<value_type>::Pi())
|
||||
return angle + DSP::Const<value_type>::TwoPi();
|
||||
if (angle > DSP::Const<value_type>::Pi())
|
||||
return angle - DSP::Const<value_type>::TwoPi();
|
||||
return angle;
|
||||
}
|
||||
public:
|
||||
constexpr FMD1() : prev(0), scale(0)
|
||||
{
|
||||
|
|
@ -27,6 +35,7 @@ public:
|
|||
{
|
||||
value_type phase = arg(input);
|
||||
value_type delta = phase - prev;
|
||||
delta = unwrap(delta);
|
||||
prev = phase;
|
||||
return scale * delta;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue