1 /* Copyright (C) Jean-Marc Valin
2 
3    File: speex_echo.h
4 
5 
6    Redistribution and use in source and binary forms, with or without
7    modification, are permitted provided that the following conditions are
8    met:
9 
10    1. Redistributions of source code must retain the above copyright notice,
11    this list of conditions and the following disclaimer.
12 
13    2. Redistributions in binary form must reproduce the above copyright
14    notice, this list of conditions and the following disclaimer in the
15    documentation and/or other materials provided with the distribution.
16 
17    3. The name of the author may not be used to endorse or promote products
18    derived from this software without specific prior written permission.
19 
20    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23    DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33 #ifndef SPEEX_ECHO_H
34 #define SPEEX_ECHO_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 struct drft_lookup;
41 
42 typedef struct SpeexEchoState {
43    int frame_size;           /**< Number of samples processed each time */
44    int window_size;
45    int M;
46    int cancel_count;
47    int adapted;
48    float adapt_rate;
49    float sum_adapt;
50    float Sey;
51    float Syy;
52    float See;
53 
54    float *x;
55    float *X;
56    float *d;
57    float *D;
58    float *y;
59    float *y2;
60    float *last_y;
61    float *Yps;
62    float *Y;
63    float *Y2;
64    float *E;
65    float *PHI;
66    float * W;
67    float *power;
68    float *power_1;
69    float *grad;
70    float *Rf;
71    float *Yf;
72    float *Xf;
73    float *fratio;
74    float *regul;
75 
76    struct drft_lookup *fft_lookup;
77 
78 
79 } SpeexEchoState;
80 
81 
82 /** Creates a new echo canceller state */
83 SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length);
84 
85 /** Destroys an echo canceller state */
86 void speex_echo_state_destroy(SpeexEchoState *st);
87 
88 /** Performs echo cancellation a frame */
89 void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out, float *Y);
90 
91 /** Reset the echo canceller state */
92 void speex_echo_state_reset(SpeexEchoState *st);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
99