[xiph-commits] r11940 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Mon Oct 23 09:01:02 PDT 2006
Author: jm
Date: 2006-10-23 09:00:59 -0700 (Mon, 23 Oct 2006)
New Revision: 11940
Modified:
trunk/speex/libspeex/preprocess.c
Log:
cleanup again
Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c 2006-10-23 15:51:38 UTC (rev 11939)
+++ trunk/speex/libspeex/preprocess.c 2006-10-23 16:00:59 UTC (rev 11940)
@@ -625,33 +625,47 @@
float prior_ratio;
float p;
float g;
+ float gain_floor;
+
+ /* Compute the gain floor based on different floors for the background noise and residual echo */
+ gain_floor = (noise_floor*st->noise[i] + echo_floor*st->echo_noise[i])/(1+st->noise[i] + st->echo_noise[i]);
+ gain_floor = sqrt(gain_floor);
+
+ /* Wiener filter gain */
prior_ratio = st->prior[i]/(1.0001f+st->prior[i]);
theta = (1.f+st->post[i])*prior_ratio;
p = st->gain2[i];
/* Optimal estimator for loudness domain */
MM = hypergeom_gain(theta);
-
g = prior_ratio * MM;
+
+ /* Constrain the gain to be close to the Bark scale gain */
if (g > 2*st->gain[i])
g = 2*st->gain[i];
if (g < .5*st->gain[i])
g = .5*st->gain[i];
st->gain[i] = g;
- /* Limit on the gain */
+
+ /* Sounds on the gain */
if (st->gain[i]>1.f)
st->gain[i]=1.f;
+ if (st->gain[i] < gain_floor)
+ st->gain[i] = gain_floor;
+ /* Exponential decay model for reverberation (unused) */
st->reverb_estimate[i] = st->reverb_decay*st->reverb_estimate[i] + st->reverb_decay*st->reverb_level*st->gain[i]*st->gain[i]*st->ps[i];
- /* Compute the gain floor based on different floors for the background noise and residual echo */
- float gain_floor = (noise_floor*st->noise[i] + echo_floor*st->echo_noise[i])/(1+st->noise[i] + st->echo_noise[i]);
- gain_floor = sqrt(gain_floor);
/* Take into account speech probability of presence (what's the best rule to use?) */
- if (st->gain[i] < gain_floor)
- st->gain[i] = gain_floor;
+#if 1 /* Loudness domain MMSE estimator */
st->gain2[i]=(p*sqrt(st->gain[i])+sqrt(gain_floor)*(1-p)) * (p*sqrt(st->gain[i])+sqrt(gain_floor)*(1-p));
- /*st->gain2[i] = pow(st->gain[i], p) * pow(gain_floor,1.f-p);*/
+#else /* Log-domain MMSE estimator */
+ st->gain2[i] = pow(st->gain[i], p) * pow(gain_floor,1.f-p);
+#endif
+
+ /* Save old power spectrum */
+ st->old_ps[i] = .2*st->old_ps[i] + .8*st->gain[i]*st->gain[i]*ps[i];
+
}
if (!st->denoise_enabled)
@@ -706,10 +720,6 @@
for (i=0;i<N3;i++)
st->outbuf[i] = st->frame[st->frame_size+i];
- /* Save old power spectrum */
- for (i=0;i<N+M;i++)
- st->old_ps[i] = .2*st->old_ps[i] + .8*st->gain[i]*st->gain[i]*ps[i];
-
return 1;
}
More information about the commits
mailing list