Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/rnnoise.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2017-08-01 08:56:22 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2017-08-01 08:56:22 +0300
commitb8d09fd8305760ce7358ad78006fc83db47ff3b8 (patch)
treefa19bfac4d3265ef32c5b0843f81ba4eba4d8aa2 /src
parentdfb9728be00c2865e33a04b8103d7a6a984d6f7e (diff)
add low-pass filter
Diffstat (limited to 'src')
-rw-r--r--src/denoise.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/denoise.c b/src/denoise.c
index 427fbe7..cd83ba2 100644
--- a/src/denoise.c
+++ b/src/denoise.c
@@ -357,9 +357,25 @@ void rnnoise_process_frame(DenoiseState *st, float *out, const float *in) {
frame_synthesis(st, out, y);
}
+void biquad(float *y, float mem[2], const float *x, const float *b, const float *a, int N) {
+ int i;
+ for (i=0;i<N;i++) {
+ float xi, yi;
+ xi = x[i];
+ yi = x[i] + mem[0];
+ mem[0] = mem[1] + (b[0]*(double)xi - a[0]*(double)yi);
+ mem[1] = (b[1]*(double)xi - a[1]*(double)yi);
+ y[i] = yi;
+ }
+}
+
int main(int argc, char **argv) {
int i;
int count=0;
+ static const float a_hp[2] = {-1.99599, 0.99600};
+ static const float b_hp[2] = {-2, 1};
+ float mem_hp_x[2]={0};
+ float mem_hp_n[2]={0};
float x[FRAME_SIZE];
float n[FRAME_SIZE];
float xn[FRAME_SIZE];
@@ -407,6 +423,8 @@ int main(int argc, char **argv) {
fread(tmp, sizeof(short), FRAME_SIZE, f2);
if (feof(f2)) break;
for (i=0;i<FRAME_SIZE;i++) n[i] = noise_gain*tmp[i];
+ biquad(x, mem_hp_x, x, b_hp, a_hp, FRAME_SIZE);
+ biquad(n, mem_hp_n, n, b_hp, a_hp, FRAME_SIZE);
for (i=0;i<FRAME_SIZE;i++) xn[i] = x[i] + n[i];
for (i=0;i<FRAME_SIZE;i++) E += x[i]*(float)x[i];
if (E > 1e9f) {