ref: 41443428cbb9b551d96c687f70bae37ac3b32afb
parent: c32edb588f99f14cdcadbd2458acb02a3b79bd69
author: Jean-Marc Valin <[email protected]>
date: Fri Jun 9 18:16:53 EDT 2017
Improving tonality estimation with delayed decision
--- a/src/analysis.c
+++ b/src/analysis.c
@@ -233,6 +233,9 @@
int pos;
int curr_lookahead;
float psum;
+ float tonality_max;
+ float tonality_avg;
+ int tonality_count;
int i;
pos = tonal->read_pos;
@@ -252,6 +255,8 @@
if (pos<0)
pos = DETECT_SIZE-1;
OPUS_COPY(info_out, &tonal->info[pos], 1);
+ tonality_max = tonality_avg = info_out->tonality;
+ tonality_count = 1;
/* If possible, look ahead for a tone to compensate for the delay in the tone detector. */
for (i=0;i<3;i++)
{
@@ -260,8 +265,11 @@
pos = 0;
if (pos == tonal->write_pos)
break;
- info_out->tonality = MAX32(0, -.03f + MAX32(info_out->tonality, tonal->info[pos].tonality-.05f));
+ tonality_max = MAX32(tonality_max, tonal->info[pos].tonality);
+ tonality_avg += tonal->info[pos].tonality;
+ tonality_count++;
}
+ info_out->tonality = MAX32(tonality_avg/tonality_count, tonality_max-.2);
tonal->read_subframe += len/(tonal->Fs/400);
while (tonal->read_subframe>=8)
{