65
53
/*- End of function --------------------------------------------------------*/
67
55
static inline int echo_can_disable_detector_update (echo_can_disable_detector_state_t *det,
72
60
notched = biquad2 (&det->notch, amp);
73
61
/* Estimate the overall energy in the channel, and the energy in
74
62
the notch (i.e. overall channel energy - tone energy => noise).
78
66
blip every time the phase reverses */
79
67
det->channel_level += ((abs(amp) - det->channel_level) >> 5);
80
68
det->notch_level += ((abs(notched) - det->notch_level) >> 4);
81
if (det->channel_level > 280)
83
/* There is adequate energy in the channel. Is it mostly at 2100Hz? */
84
if (det->notch_level*6 < det->channel_level)
86
/* The notch says yes, so we have the tone. */
87
if (!det->tone_present)
89
/* Do we get a kick every 450+-25ms? */
90
if (det->tone_cycle_duration >= 425*8
92
det->tone_cycle_duration <= 475*8)
95
if (det->good_cycles > 2)
98
det->tone_cycle_duration = 0;
69
if (det->channel_level >= 70) {
70
/* There is adequate energy in the channel. Is it mostly at 2100Hz? */
71
if (det->notch_level*6 < det->channel_level) {
72
det->tone_cycle_duration++;
73
/* The notch says yes, so we have the tone. */
74
if (!det->tone_present) {
75
/* Do we get a kick every 450+-25ms? */
76
if ((det->tone_cycle_duration >= (425 * 8)) &&
77
(det->tone_cycle_duration <= (475 * 8))) {
78
/* It's ANS/PR (CED with polarity reversals), so wait
79
for at least three cycles before returning a hit. */
81
if (det->good_cycles > 2)
84
det->tone_cycle_duration = 0;
85
det->tone_present = TRUE;
86
} else if (det->tone_cycle_duration >= 600 * 8) {
87
/* It's ANS (CED without polarity reversals)
92
det->tone_present = FALSE;
100
det->tone_present = TRUE;
104
95
det->tone_present = FALSE;
106
det->tone_cycle_duration++;
110
det->tone_present = FALSE;
111
det->tone_cycle_duration = 0;
112
det->good_cycles = 0;
96
det->tone_cycle_duration = 0;
116
102
/*- End of function --------------------------------------------------------*/
117
103
/*- End of file ------------------------------------------------------------*/