blob: 2f3b5936b95bcd0875f951e25cf6eeb9efad91cb [file] [log] [blame]
Chia-chi Yeha8a10092010-10-05 01:17:13 +08001/*
2 * Copyrightm (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __ECHO_SUPPRESSOR_H__
18#define __ECHO_SUPPRESSOR_H__
19
20#include <stdint.h>
21
22class EchoSuppressor
23{
24public:
25 // The sampleCount must be power of 2.
Chia-chi Yeh8a68b522010-10-21 23:39:35 +080026 EchoSuppressor(int sampleCount, int tailLength);
Chia-chi Yeha8a10092010-10-05 01:17:13 +080027 ~EchoSuppressor();
28 void run(int16_t *playbacked, int16_t *recorded);
29
30private:
Chia-chi Yeh8a68b522010-10-21 23:39:35 +080031 int mShift;
Chia-chi Yeha8a10092010-10-05 01:17:13 +080032 int mScale;
33 int mSampleCount;
34 int mWindowSize;
35 int mTailLength;
36 int mRecordLength;
37 int mRecordOffset;
38
Chia-chi Yeh8a68b522010-10-21 23:39:35 +080039 uint16_t *mXs;
40 uint32_t *mXSums;
41 uint32_t *mX2Sums;
42 uint16_t *mXRecords;
Chia-chi Yeha8a10092010-10-05 01:17:13 +080043
Chia-chi Yeh8a68b522010-10-21 23:39:35 +080044 uint32_t mYSum;
45 uint32_t mY2Sum;
46 uint32_t *mYRecords;
47 uint32_t *mY2Records;
Chia-chi Yeha8a10092010-10-05 01:17:13 +080048
Chia-chi Yeh8a68b522010-10-21 23:39:35 +080049 uint32_t *mXYSums;
50 uint32_t *mXYRecords;
51
52 int32_t mLastX;
53 int32_t mLastY;
54
55 float mWeight;
Chia-chi Yeha8a10092010-10-05 01:17:13 +080056};
57
58#endif