PipeWire
1.2.7
Loading...
Searching...
No Matches
dll.h
1
/* Simple DLL */
2
/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */
3
/* SPDX-License-Identifier: MIT */
4
5
#ifndef SPA_DLL_H
6
#define SPA_DLL_H
7
8
#ifdef __cplusplus
9
extern
"C"
{
10
#endif
11
12
#include <stddef.h>
13
#include <math.h>
14
15
#define SPA_DLL_BW_MAX 0.128
16
#define SPA_DLL_BW_MIN 0.016
17
18
struct
spa_dll
{
19
double
bw
;
20
double
z1
,
z2
,
z3
;
21
double
w0
,
w1
,
w2
;
22
};
23
24
static
inline
void
spa_dll_init(
struct
spa_dll
*dll)
25
{
26
dll->
bw
= 0.0;
27
dll->
z1
= dll->
z2
= dll->
z3
= 0.0;
28
}
29
30
static
inline
void
spa_dll_set_bw(
struct
spa_dll
*dll,
double
bw,
unsigned
period,
unsigned
rate)
31
{
32
double
w = 2 * M_PI * bw * period / rate;
33
dll->
w0
= 1.0 - exp (-20.0 * w);
34
dll->
w1
= w * 1.5 / period;
35
dll->
w2
= w / 1.5;
36
dll->
bw
= bw;
37
}
38
39
static
inline
double
spa_dll_update(
struct
spa_dll
*dll,
double
err)
40
{
41
dll->
z1
+= dll->
w0
* (dll->
w1
* err - dll->
z1
);
42
dll->
z2
+= dll->
w0
* (dll->
z1
- dll->
z2
);
43
dll->
z3
+= dll->
w2
* dll->
z2
;
44
return
1.0 - (dll->
z2
+ dll->
z3
);
45
}
46
47
#ifdef __cplusplus
48
}
/* extern "C" */
49
#endif
50
51
#endif
/* SPA_DLL_H */
spa_dll
Definition
dll.h:24
spa_dll::z2
double z2
Definition
dll.h:26
spa_dll::z1
double z1
Definition
dll.h:26
spa_dll::w2
double w2
Definition
dll.h:27
spa_dll::z3
double z3
Definition
dll.h:26
spa_dll::w0
double w0
Definition
dll.h:27
spa_dll::bw
double bw
Definition
dll.h:25
spa_dll::w1
double w1
Definition
dll.h:27
spa
utils
dll.h
Generated by
1.10.0