aboutsummaryrefslogtreecommitdiff
path: root/src/postfilter.c
diff options
context:
space:
mode:
authordrowe67 <[email protected]>2023-07-20 08:59:48 +0930
committerGitHub <[email protected]>2023-07-20 08:59:48 +0930
commit06d4c11e699b0351765f10398abb4f663a984f36 (patch)
tree33e22af0814c5b6c3d676f096ae8c2ac8a3ed9f0 /src/postfilter.c
parent6588e77f38bdebd7adffe091b22e7760d95d0ccb (diff)
parent4d6c143c0abec15e1d6ed1fd95d36f80e6cb7df8 (diff)
Merge pull request #3 from drowe67/dr-cleanup21.2.0
Cleanup Part 2
Diffstat (limited to 'src/postfilter.c')
-rw-r--r--src/postfilter.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/src/postfilter.c b/src/postfilter.c
index 96f4f02..e46d488 100644
--- a/src/postfilter.c
+++ b/src/postfilter.c
@@ -27,16 +27,17 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "postfilter.h"
+
#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
-#include "defines.h"
#include "comp.h"
+#include "defines.h"
#include "dump.h"
#include "sine.h"
-#include "postfilter.h"
/*---------------------------------------------------------------------------*\
@@ -44,13 +45,14 @@
\*---------------------------------------------------------------------------*/
-#define BG_THRESH 40.0 /* only consider low levels signals for bg_est */
-#define BG_BETA 0.1 /* averaging filter constant */
-#define BG_MARGIN 6.0 /* harmonics this far above BG noise are
- randomised. Helped make bg noise less
- spikey (impulsive) for mmt1, but speech was
- perhaps a little rougher.
- */
+#define BG_THRESH 40.0 /* only consider low levels signals for bg_est */
+#define BG_BETA 0.1 /* averaging filter constant */
+#define BG_MARGIN \
+ 6.0 /* harmonics this far above BG noise are \
+ randomised. Helped make bg noise less \
+ spikey (impulsive) for mmt1, but speech was \
+ perhaps a little rougher. \
+ */
/*---------------------------------------------------------------------------*\
@@ -98,45 +100,39 @@
\*---------------------------------------------------------------------------*/
-void postfilter(
- MODEL *model,
- float *bg_est
-)
-{
- int m, uv;
+void postfilter(MODEL *model, float *bg_est) {
+ int m, uv;
float e, thresh;
/* determine average energy across spectrum */
e = 1E-12;
- for(m=1; m<=model->L; m++)
- e += model->A[m]*model->A[m];
+ for (m = 1; m <= model->L; m++) e += model->A[m] * model->A[m];
assert(e > 0.0);
- e = 10.0*log10f(e/model->L);
+ e = 10.0 * log10f(e / model->L);
/* If beneath threshold, update bg estimate. The idea
of the threshold is to prevent updating during high level
speech. */
if ((e < BG_THRESH) && !model->voiced)
- *bg_est = *bg_est*(1.0 - BG_BETA) + e*BG_BETA;
+ *bg_est = *bg_est * (1.0 - BG_BETA) + e * BG_BETA;
/* now mess with phases during voiced frames to make any harmonics
less then our background estimate unvoiced.
*/
uv = 0;
- thresh = POW10F((*bg_est + BG_MARGIN)/20.0);
+ thresh = POW10F((*bg_est + BG_MARGIN) / 20.0);
if (model->voiced)
- for(m=1; m<=model->L; m++)
- if (model->A[m] < thresh) {
- model->phi[m] = (TWO_PI/CODEC2_RAND_MAX)*(float)codec2_rand();
- uv++;
- }
+ for (m = 1; m <= model->L; m++)
+ if (model->A[m] < thresh) {
+ model->phi[m] = (TWO_PI / CODEC2_RAND_MAX) * (float)codec2_rand();
+ uv++;
+ }
#ifdef DUMP
- dump_bg(e, *bg_est, 100.0*uv/model->L);
+ dump_bg(e, *bg_est, 100.0 * uv / model->L);
#endif
-
}