diff options
Diffstat (limited to 'lib/rbcodec/codecs/libspeex/speex/speex_echo.h')
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_echo.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_echo.h b/lib/rbcodec/codecs/libspeex/speex/speex_echo.h new file mode 100644 index 0000000000..6fcb0c00d7 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_echo.h | |||
@@ -0,0 +1,123 @@ | |||
1 | /* Copyright (C) Jean-Marc Valin */ | ||
2 | /** | ||
3 | @file speex_echo.h | ||
4 | @brief Echo cancellation | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions are | ||
9 | met: | ||
10 | |||
11 | 1. Redistributions of source code must retain the above copyright notice, | ||
12 | this list of conditions and the following disclaimer. | ||
13 | |||
14 | 2. Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | 3. The name of the author may not be used to endorse or promote products | ||
19 | derived from this software without specific prior written permission. | ||
20 | |||
21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
31 | POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #ifndef SPEEX_ECHO_H | ||
35 | #define SPEEX_ECHO_H | ||
36 | /** @defgroup SpeexEchoState SpeexEchoState: Acoustic echo canceller | ||
37 | * This is the acoustic echo canceller module. | ||
38 | * @{ | ||
39 | */ | ||
40 | #include "speex_types.h" | ||
41 | |||
42 | #ifdef __cplusplus | ||
43 | extern "C" { | ||
44 | #endif | ||
45 | |||
46 | /** Obtain frame size used by the AEC */ | ||
47 | #define SPEEX_ECHO_GET_FRAME_SIZE 3 | ||
48 | |||
49 | /** Set sampling rate */ | ||
50 | #define SPEEX_ECHO_SET_SAMPLING_RATE 24 | ||
51 | /** Get sampling rate */ | ||
52 | #define SPEEX_ECHO_GET_SAMPLING_RATE 25 | ||
53 | |||
54 | /** Internal echo canceller state. Should never be accessed directly. */ | ||
55 | struct SpeexEchoState_; | ||
56 | |||
57 | /** @class SpeexEchoState | ||
58 | * This holds the state of the echo canceller. You need one per channel. | ||
59 | */ | ||
60 | |||
61 | /** Internal echo canceller state. Should never be accessed directly. */ | ||
62 | typedef struct SpeexEchoState_ SpeexEchoState; | ||
63 | |||
64 | /** Creates a new echo canceller state | ||
65 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) | ||
66 | * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) | ||
67 | * @return Newly-created echo canceller state | ||
68 | */ | ||
69 | SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length); | ||
70 | |||
71 | /** Destroys an echo canceller state | ||
72 | * @param st Echo canceller state | ||
73 | */ | ||
74 | void speex_echo_state_destroy(SpeexEchoState *st); | ||
75 | |||
76 | /** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added | ||
77 | * to playback in this form) | ||
78 | * | ||
79 | * @param st Echo canceller state | ||
80 | * @param rec Signal from the microphone (near end + far end echo) | ||
81 | * @param play Signal played to the speaker (received from far end) | ||
82 | * @param out Returns near-end signal with echo removed | ||
83 | */ | ||
84 | void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out); | ||
85 | |||
86 | /** Performs echo cancellation a frame (deprecated) */ | ||
87 | void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out, spx_int32_t *Yout); | ||
88 | |||
89 | /** Perform echo cancellation using internal playback buffer, which is delayed by two frames | ||
90 | * to account for the delay introduced by most soundcards (but it could be off!) | ||
91 | * @param st Echo canceller state | ||
92 | * @param rec Signal from the microphone (near end + far end echo) | ||
93 | * @param out Returns near-end signal with echo removed | ||
94 | */ | ||
95 | void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out); | ||
96 | |||
97 | /** Let the echo canceller know that a frame was just queued to the soundcard | ||
98 | * @param st Echo canceller state | ||
99 | * @param play Signal played to the speaker (received from far end) | ||
100 | */ | ||
101 | void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play); | ||
102 | |||
103 | /** Reset the echo canceller to its original state | ||
104 | * @param st Echo canceller state | ||
105 | */ | ||
106 | void speex_echo_state_reset(SpeexEchoState *st); | ||
107 | |||
108 | /** Used like the ioctl function to control the echo canceller parameters | ||
109 | * | ||
110 | * @param st Echo canceller state | ||
111 | * @param request ioctl-type request (one of the SPEEX_ECHO_* macros) | ||
112 | * @param ptr Data exchanged to-from function | ||
113 | * @return 0 if no error, -1 if request in unknown | ||
114 | */ | ||
115 | int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr); | ||
116 | |||
117 | #ifdef __cplusplus | ||
118 | } | ||
119 | #endif | ||
120 | |||
121 | |||
122 | /** @}*/ | ||
123 | #endif | ||