FS#8961 - Anti-Aliased Fonts.
[kugel-rb/myfork.git] / apps / codecs / libspeex / speex / speex_echo.h
blob6fcb0c00d7aa566adf3203f415696348ec5908a1
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:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
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.
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.
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.
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 * @{
40 #include "speex_types.h"
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 /** Obtain frame size used by the AEC */
47 #define SPEEX_ECHO_GET_FRAME_SIZE 3
49 /** Set sampling rate */
50 #define SPEEX_ECHO_SET_SAMPLING_RATE 24
51 /** Get sampling rate */
52 #define SPEEX_ECHO_GET_SAMPLING_RATE 25
54 /** Internal echo canceller state. Should never be accessed directly. */
55 struct SpeexEchoState_;
57 /** @class SpeexEchoState
58 * This holds the state of the echo canceller. You need one per channel.
61 /** Internal echo canceller state. Should never be accessed directly. */
62 typedef struct SpeexEchoState_ SpeexEchoState;
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
69 SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length);
71 /** Destroys an echo canceller state
72 * @param st Echo canceller state
74 void speex_echo_state_destroy(SpeexEchoState *st);
76 /** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added
77 * to playback in this form)
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
84 void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out);
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);
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
95 void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out);
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)
101 void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play);
103 /** Reset the echo canceller to its original state
104 * @param st Echo canceller state
106 void speex_echo_state_reset(SpeexEchoState *st);
108 /** Used like the ioctl function to control the echo canceller parameters
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
115 int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr);
117 #ifdef __cplusplus
119 #endif
122 /** @}*/
123 #endif