45#define ECHO_GET_FRAME_SIZE 3
46#define ECHO_SET_SAMPLING_RATE 24
47#define ECHO_GET_SAMPLING_RATE 25
48#define ECHO_GET_IMPULSE_RESPONSE_SIZE 27
49#define ECHO_GET_IMPULSE_RESPONSE 29
53#define PSEUDOFLOAT(x) (x)
54#define FLOAT_MULT(a, b) ((a) * (b))
55#define FLOAT_AMULT(a, b) ((a) * (b))
56#define FLOAT_MUL32(a, b) ((a) * (b))
57#define FLOAT_DIV32(a, b) ((a) / (b))
58#define FLOAT_EXTRACT16(a) (a)
59#define FLOAT_EXTRACT32(a) (a)
60#define FLOAT_ADD(a, b) ((a) + (b))
61#define FLOAT_SUB(a, b) ((a) - (b))
62#define FLOAT_DIV32_FLOAT(a, b) ((a) / (b))
63#define FLOAT_MUL32U(a, b) ((a) * (b))
64#define FLOAT_SHL(a, b) (a)
65#define FLOAT_LT(a, b) ((a) < (b))
66#define FLOAT_GT(a, b) ((a) > (b))
67#define FLOAT_DIVU(a, b) ((a) / (b))
68#define FLOAT_SQRT(a) (sqrtf(a))
71#define ABS(x) (((x) < 0) ? (-(x)) : (x))
72#define ABS16(x) (((x) < 0) ? (-(x)) : (x))
73#define ABS32(x) (((x) < 0) ? (-(x)) : (x))
74#define MIN16(a, b) ((a) < (b) ? (a) : (b))
75#define MAX16(a, b) ((a) > (b) ? (a) : (b))
76#define MIN32(a, b) ((a) < (b) ? (a) : (b))
77#define MAX32(a, b) ((a) > (b) ? (a) : (b))
79#define QCONST16(x, bits) (x)
80#define QCONST32(x, bits) (x)
81#define NEG16(x) (-(x))
82#define NEG32(x) (-(x))
83#define EXTRACT16(x) (x)
84#define EXTEND32(x) (x)
85#define SHR16(a, shift) (a)
86#define SHL16(a, shift) (a)
87#define SHR32(a, shift) (a)
88#define SHL32(a, shift) (a)
89#define PSHR16(a, shift) (a)
90#define PSHR32(a, shift) (a)
91#define VSHR32(a, shift) (a)
92#define SATURATE16(x, a) (x)
93#define SATURATE32(x, a) (x)
94#define ADD16(a, b) ((a) + (b))
95#define SUB16(a, b) ((a) - (b))
96#define ADD32(a, b) ((a) + (b))
97#define SUB32(a, b) ((a) - (b))
98#define MULT16_16(a, b) ((echo_word32_t)(a) * (echo_word32_t)(b))
99#define MAC16_16(c, a, b) ((c) + (echo_word32_t)(a) * (echo_word32_t)(b))
100#define MULT16_32_Q15(a, b) ((a) * (b))
101#define MULT16_16_P15(a, b) ((a) * (b))
102#define MULT16_32_P15(a, b) ((a) * (b))
103#define MULT16_16_Q15(a, b) ((a) * (b))
104#define DIV32_16(a, b) (((echo_word32_t)(a)) / (echo_word16_t)(b))
105#define DIV32(a, b) (((echo_word32_t)(a)) / (echo_word32_t)(b))
109 : ((x) > 32766.5f ? 32767 : (echo_int16_t)floorf(.5f + (x))))
110#define MULT16_16_Q14(a, b) ((a) * (b))
111#define MULT16_16_Q13(a, b) ((a) * (b))
112#define MULT16_16_P13(a, b) ((a) * (b))
113#define MULT16_16_P14(a, b) ((a) * (b))
114#define MULT16_32_Q14(a, b) ((a) * (b))
115#define MAC16_32_Q15(c, a, b) ((c) + (a) * (b))
118#define WEIGHT_SHIFT 0
122#define PSEUDOFLOAT(x) (echo_float_from_double(x))
123#define FLOAT_MULT(a, b) (echo_float_mult(a, b))
124#define FLOAT_MUL32U(a, b) (echo_float_mul32_u(a, b))
125#define FLOAT_ADD(a, b) (echo_float_add(a, b))
126#define FLOAT_SUB(a, b) (echo_float_sub(a, b))
127#define FLOAT_LT(a, b) (echo_float_lt(a, b))
128#define FLOAT_GT(a, b) (echo_float_gt(a, b))
129#define FLOAT_DIVU(a, b) (echo_float_divu(a, b))
130#define FLOAT_SQRT(a) (echo_float_sqrt(a))
131#define FLOAT_EXTRACT16(a) (echo_float_extract16(a))
132#define FLOAT_SHL(a, b) (echo_float_shl(a, b))
135#define ABS(x) (((x) < 0) ? (-(x)) : (x))
136#define ABS16(x) (((x) < 0) ? (-(x)) : (x))
137#define ABS32(x) (((x) < 0) ? (-(x)) : (x))
138#define MIN16(a, b) ((a) < (b) ? (a) : (b))
139#define MAX16(a, b) ((a) > (b) ? (a) : (b))
140#define MIN32(a, b) ((a) < (b) ? (a) : (b))
141#define MAX32(a, b) ((a) > (b) ? (a) : (b))
146 : ((x) > 32766.5f ? 32767 : (echo_int16_t)floorf(.5f + (x))))
149#define WEIGHT_SHIFT 0
190 return result << (
e - 14);
192 return result >> (14 -
e);
200 return result << (
e - 14);
202 return result >> (14 -
e);
220 while (x >= 32768) { x *= 0.5; e++; }
221 while (x < 16384) { x *= 2.0; e--; }
230 r.e =
a.e +
b.e + 15;
232 while (
r.m < 16384) {
r.m <<= 1;
r.e--; }
243 int shift =
a.
e -
b.e;
244 if (shift > 15)
return a;
248 int shift =
b.e -
a.e;
249 if (shift > 15)
return b;
257 int shift =
a.
e -
b.e;
258 if (shift > 15)
return a;
262 int shift =
b.e -
a.e;
273 if (
a.e !=
b.e)
return a.e <
b.e;
278 if (
a.e !=
b.e)
return a.e >
b.e;
290 r.e =
a.e -
b.e - 15;
292 while (
r.m < 16384) {
r.m <<= 1;
r.e--; }
298 double val = x.
m * pow(2.0, x.
e - 14);
304 return x.
m << (x.
e > 15 ? 15 : x.
e);
306 return x.
m >> (-x.
e > 15 ? 15 : -x.
e);
338static const float MIN_LEAK = 0.005f;
365typedef float echo_float_t;
450template <
typename Allocator = std::allocator<u
int8_t>>
507template <
typename Allocator = std::allocator<u
int8_t>>
597 echoWarning(
"Internal playback buffer corruption");
639 for (
int i = 0; i < N * M; i++)
state->
W[i] = 0;
643 for (
int i = 0; i < N * (M + 1); i++)
state->
X[i] = 0;
651 for (
int i = 0; i < N *
C; i++)
state->
E[i] = 0;
652 for (
int i = 0; i < N * K; i++)
state->
x[i] = 0;
655 for (
int i = 0; i < K; i++)
state->
memX[i] = 0;
701 for (
int j = 0;
j < M;
j++) {
703 for (
int i = 0; i < n; i++)
filt[
j * n + i] = 32767 *
state->
wtmp[i];
738 echoWarning(
"Cannot change filter length after initialization");
752 echoWarning(
"Cannot change mic channels after initialization");
766 echoWarning(
"Cannot change speaker channels after initialization");
780 echoWarning(
"Cannot change FFT driver after initialization");
820 template <
typename T>
823 T* ptr =
alloc.allocate(count);
825 for (
size_t i = 0; i < count; ++i) {
838 template <
typename T>
844 alloc.deallocate(ptr, count);
849 LOGW(
"EchoCanceller Warning: %s", str);
853 LOGE(
"EchoCanceller Error: %s", str);
909 for (
int i = 0; i < len; i++) {
928 for (
int i = 0; i < len; i++) {
942 for (
int i = 1,
j = 1; i < N - 1; i += 2,
j++) {
943 ps[
j] = X[i] * X[i] + X[i + 1] * X[i + 1];
945 ps[N / 2] = X[N - 1] * X[N - 1];
956 ps[0] += X[0] * X[0];
957 for (
int i = 1,
j = 1; i < N - 1; i += 2,
j++) {
958 ps[
j] += X[i] * X[i] + X[i + 1] * X[i + 1];
960 ps[N / 2] += X[N - 1] * X[N - 1];
973 for (
int i = 0; i < N; i++)
acc[i] = 0;
975 for (
int j = 0;
j < M;
j++) {
976 acc[0] += X[0] * Y[0];
977 for (
int i = 1; i < N - 1; i += 2) {
978 acc[i] += (X[i] * Y[i] - X[i + 1] * Y[i + 1]);
979 acc[i + 1] += (X[i + 1] * Y[i] + X[i] * Y[i + 1]);
981 acc[N - 1] += X[N - 1] * Y[N - 1];
1003 for (
int i = 1,
j = 1; i < N - 1; i += 2,
j++) {
1005 prod[i] = W * ((
int32_t)(X[i] * Y[i] + X[i + 1] * Y[i + 1]));
1006 prod[i + 1] = W * ((
int32_t)(-X[i + 1] * Y[i] + X[i] * Y[i + 1]));
1025 for (
int i = 0; i < M; i++) {
1027 for (
int p = 0; p < P; p++) {
1028 for (
int j = 0;
j < N;
j++) {
1029 float val = W[p * N * M + i * N +
j];
1037 for (
int i = 0; i < M; i++) {
1042 for (
int i = 0; i < M; i++) {
1043 prop[i] = 0.99f * prop[i] /
prop_sum;
1057 int N = frame_size * 2;
1063 if (!
st)
return nullptr;
1067 st->frame_size = frame_size;
1068 st->window_size = N;
1070 st->cancel_count = 0;
1074 st->sampling_rate = 8000;
1075 st->spec_average =
st->frame_size / (
float)
st->sampling_rate;
1076 st->beta0 = (2.0f *
st->frame_size) /
st->sampling_rate;
1077 st->beta_max = (.5f *
st->frame_size) /
st->sampling_rate;
1078 st->leak_estimate = 0;
1108 for (
int i = 0; i < N; i++)
1109 st->window[i] = .5f - .5f *
cosf(2 *
M_PI * i / N);
1112 for (
int i = 0; i <=
st->frame_size; i++)
st->power_1[i] =
FLOAT_ONE;
1115 for (
int i = 0; i < N * M * K *
C; i++)
st->W[i] = 0;
1120 float decay =
expf(-2.4f / M);
1123 for (
int i = 1; i < M; i++) {
1124 st->prop[i] =
st->prop[i - 1] * decay;
1127 for (
int i = M - 1; i >= 0; i--) {
1128 st->prop[i] = .8f *
st->prop[i] / sum;
1137 if (
st->sampling_rate < 12000)
1138 st->notch_radius = .9f;
1139 else if (
st->sampling_rate < 24000)
1140 st->notch_radius = .982f;
1142 st->notch_radius = .992f;
1149 st->Davg1 =
st->Davg2 = 0;
1156 st->play_buf_started = 0;
1158 st->fft_table =
nullptr;
1182 int N =
st->window_size;
1188 float ss = .35f / M;
1194 st->input +
chan *
st->frame_size,
st->frame_size,
1197 for (
int i = 0; i <
st->frame_size; i++) {
1207 std::memmove(&
st->x[
speak * N],
1210 for (
int i = 0; i <
st->frame_size; i++) {
1220 for (
int j = M - 1;
j >= 0;
j--) {
1221 std::memmove(&
st->X[(
j + 1) * N * K +
speak * N],
1232 st->x +
speak * N +
st->frame_size,
st->frame_size);
1241 st->Y +
chan * N, N, M * K);
1243 for (
int i = 0; i <
st->frame_size; i++)
1245 st->e[
chan * N + i +
st->frame_size];
1254 if (
st->saturated == 0) {
1257 for (
int j = M - 1;
j >= 0;
j--) {
1259 &
st->X[(
j + 1) * N * K +
speak * N],
1261 for (
int i = 0; i < N; i++)
1262 st->W[
chan * N * K * M +
j * N * K +
speak * N + i] +=
st->PHI[i];
1273 for (
int j = 0;
j < M;
j++) {
1274 if (
j == 0 ||
st->cancel_count % (M - 1) ==
j - 1) {
1278 for (
int i =
st->frame_size; i < N; i++)
st->wtmp[i] = 0;
1280 st->fft_table,
st->wtmp,
1288 for (
int i = 0; i <=
st->frame_size; i++)
1289 st->Rf[i] =
st->Yf[i] =
st->Xf[i] = 0;
1300 for (
int i = 0; i <
st->frame_size; i++)
1302 st->y[
chan * N + i +
st->frame_size];
1305 for (
int i = 0; i <
st->frame_size; i++)
1307 st->y[
chan * N + i +
st->frame_size];
1318 st->Davg1 = .6f *
st->Davg1 + .4f * (
Sff -
See);
1319 st->Davg2 = .85f *
st->Davg2 + .15f * (
Sff -
See);
1337 st->Davg1 =
st->Davg2 = 0;
1341 for (
int i = 0; i <
st->frame_size; i++)
1342 st->e[
chan * N + i +
st->frame_size] =
1343 st->window[i +
st->frame_size] *
1344 st->e[
chan * N + i +
st->frame_size] +
1345 st->window[i] *
st->y[
chan * N + i +
st->frame_size];
1361 for (
int i = 0; i <
st->frame_size; i++)
1362 st->y[
chan * N + i +
st->frame_size] =
1363 st->e[
chan * N + i +
st->frame_size];
1364 for (
int i = 0; i <
st->frame_size; i++)
1366 st->y[
chan * N + i +
st->frame_size];
1369 st->Davg1 =
st->Davg2 = 0;
1378 for (
int i = 0; i <
st->frame_size; i++) {
1382 st->e[
chan * N + i +
st->frame_size];
1385 st->y[
chan * N + i +
st->frame_size];
1388 if (in[i *
C +
chan] <= -32000 || in[i *
C +
chan] >= 32000) {
1389 if (
st->saturated == 0)
st->saturated = 1;
1396 for (
int i = 0; i <
st->frame_size; i++) {
1403 st->y +
chan * N +
st->frame_size,
st->frame_size);
1405 st->y +
chan * N +
st->frame_size,
st->frame_size);
1407 st->input +
chan *
st->frame_size,
st->frame_size);
1412 for (
int i = 0; i <
st->frame_size; i++)
st->y[i +
chan * N] = 0;
1421 if (!(
Syy >= 0 &&
Sxx >= 0 &&
See >= 0) ||
1422 !(
Sff < N * 1e9f &&
Syy < N * 1e9f &&
Sxx < N * 1e9f)) {
1423 st->screwed_up += 50;
1424 for (
int i = 0; i <
st->frame_size *
C; i++) out[i] = 0;
1425 }
else if (
Sff >
Sdd + N * 10000.0f) {
1431 if (
st->screwed_up >= 50) {
1441 st->x +
speak * N +
st->frame_size,
st->frame_size);
1446 for (
int j = 0;
j <=
st->frame_size;
j++)
1451 for (
int j =
st->frame_size;
j >= 0;
j--) {
1457 (1 -
st->spec_average) *
st->Eh[
j] +
st->spec_average *
st->Rf[
j];
1459 (1 -
st->spec_average) *
st->Yh[
j] +
st->spec_average *
st->Yf[
j];
1480 if (
st->leak_estimate > 16383)
1481 st->leak_estimate = 32767;
1483 st->leak_estimate =
st->leak_estimate * 2;
1489 if (
RER > .5f)
RER = .5f;
1491 if (!
st->adapted &&
st->sum_adapt > M &&
1492 st->leak_estimate *
Syy > .03f *
Syy) {
1497 for (
int i = 0; i <=
st->frame_size; i++) {
1500 if (
r > .5f * e)
r = .5f * e;
1501 r = .7f *
r + .3f * (
RER * e);
1502 st->power_1[i] =
r / (e * (
st->power[i] + 10));
1506 if (
Sxx > N * 1000.0f) {
1511 for (
int i = 0; i <=
st->frame_size; i++)
1516 std::memmove(
st->last_y,
1517 &
st->last_y[
st->frame_size],
1520 for (
int i = 0; i <
st->frame_size; i++)
1521 st->last_y[
st->frame_size + i] = in[i] - out[i];
1537template <
typename Allocator>
1548 if (!driver->
begin(cfg)) {
1559template <
typename Allocator = std::allocator<u
int8_t>>
1576template <
typename Allocator = std::allocator<u
int8_t>>
1580 if (!
st || !
st->driver)
return;
1583 for (
int i = 0; i <
st->N; i++) {
1584 st->
driver->setValue(i, in[i] / (
float)
st->N);
1593 out[0] =
st->driver->getValue(0);
1594 for (
int i = 1; i <
st->N - 1; i += 2) {
1595 int bin = (i + 1) / 2;
1597 st->driver->getBin(bin, real, img);
1601 out[
st->N - 1] =
st->driver->getValue(
st->N / 2);
1612template <
typename Allocator = std::allocator<u
int8_t>>
1616 if (!
st || !
st->driver || !
st->driver->isReverseFFT())
return;
1620 for (
int i = 1; i <
st->N - 1; i += 2) {
1621 int bin = (i + 1) / 2;
1622 st->driver->setBin(bin, in[i], in[i + 1]);
1624 st->driver->setBin(
st->N / 2, in[
st->N - 1], 0);
1630 for (
int i = 0; i <
st->N; i++) {
1631 out[i] =
st->driver->getValue(i);
#define ss
Definition AudioLoRa.h:8
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define LOGE(...)
Definition AudioLoggerIDF.h:30
#define M_PI
Definition GoerzelStream.h:8
#define ECHO_GET_IMPULSE_RESPONSE
Definition MDFEchoCancellation.h:49
#define PSEUDOFLOAT(x)
Definition MDFEchoCancellation.h:122
#define FLOAT_MUL32U(a, b)
Definition MDFEchoCancellation.h:124
#define WORD2INT(x)
Definition MDFEchoCancellation.h:143
#define FLOAT_MULT(a, b)
Definition MDFEchoCancellation.h:123
#define FLOAT_SQRT(a)
Definition MDFEchoCancellation.h:130
#define ECHO_GET_SAMPLING_RATE
Definition MDFEchoCancellation.h:47
#define FLOAT_SUB(a, b)
Definition MDFEchoCancellation.h:126
#define FLOAT_GT(a, b)
Definition MDFEchoCancellation.h:128
#define FLOAT_SHL(a, b)
Definition MDFEchoCancellation.h:132
#define FLOAT_EXTRACT16(a)
Definition MDFEchoCancellation.h:131
#define ECHO_SET_SAMPLING_RATE
Definition MDFEchoCancellation.h:46
#define FLOAT_DIVU(a, b)
Definition MDFEchoCancellation.h:129
#define MAX32(a, b)
Definition MDFEchoCancellation.h:141
#define FLOAT_LT(a, b)
Definition MDFEchoCancellation.h:127
#define FLOAT_ADD(a, b)
Definition MDFEchoCancellation.h:125
#define ECHO_GET_IMPULSE_RESPONSE_SIZE
Definition MDFEchoCancellation.h:48
#define ECHO_GET_FRAME_SIZE
Definition MDFEchoCancellation.h:45
#define PLAYBACK_DELAY
Definition MDFEchoCancellationConfig.h:64
#define FLOAT_ZERO
Definition MDFEchoCancellationConfig.h:82
#define FLOAT_ONE
Definition MDFEchoCancellationConfig.h:85
void play(maxi_float_t *channels)
echo_word32_t * Yh
Definition MDFEchoCancellation.h:422
void spectralMulAccum(const echo_word16_t *X, const echo_word32_t *Y, echo_word16_t *acc, int N, int M)
Accumulate spectral multiplication across multiple frames.
Definition MDFEchoCancellation.h:971
echo_word16_t spec_average
Definition MDFEchoCancellation.h:390
int getMicChannels()
Definition MDFEchoCancellation.h:759
void echo_ifft(void *table, echo_word16_t *in, echo_word16_t *out)
Perform inverse FFT.
Definition MDFEchoCancellation.h:1613
void cancel(const echo_int16_t *rec, const echo_int16_t *play, echo_int16_t *out)
Definition MDFEchoCancellation.h:575
int getSamplingRate()
Definition MDFEchoCancellation.h:721
echo_word16_t * memX
Definition MDFEchoCancellation.h:428
void mdfAdjustProp(const echo_word32_t *W, int N, int M, int P, echo_word16_t *prop)
Adjust proportional adaptation weights.
Definition MDFEchoCancellation.h:1020
void * fft_table
Definition MDFEchoCancellation.h:427
void echo_fft(void *table, echo_word16_t *in, echo_word16_t *out)
Perform forward FFT.
Definition MDFEchoCancellation.h:1577
int window_size
Definition MDFEchoCancellation.h:381
echo_word16_t * X
Definition MDFEchoCancellation.h:398
std::vector< float, FloatAllocator > temp_real
Definition MDFEchoCancellation.h:456
echo_word32_t operator*(int16_t scalar) const
Definition MDFEchoCancellation.h:186
~MDFEchoCancellation()
Definition MDFEchoCancellation.h:532
void getImpulseResponse(echo_int32_t *response)
Definition MDFEchoCancellation.h:729
int play_buf_pos
Definition MDFEchoCancellation.h:434
int K
Definition MDFEchoCancellation.h:388
echo_word32_t mdfInnerProd(const echo_word16_t *x, const echo_word16_t *y, int len)
Compute inner product of two vectors.
Definition MDFEchoCancellation.h:925
echo_int16_t spxIlog2(echo_uint32_t x)
Definition MDFEchoCancellation.h:858
echo_word32_t * W
Definition MDFEchoCancellation.h:405
void setSpeakerChannels(int num)
Definition MDFEchoCancellation.h:764
AudioFFTBase * fft_driver
Definition MDFEchoCancellation.h:791
float spxSqrt(float x)
Definition MDFEchoCancellation.h:856
int16_t e
Definition MDFEchoCancellation.h:175
echo_float_t Dvar1
Definition MDFEchoCancellation.h:412
echo_word16_t * prop
Definition MDFEchoCancellation.h:426
void setMicChannels(int num)
Definition MDFEchoCancellation.h:750
AudioFFTBase * driver
Definition MDFEchoCancellation.h:454
echo_word16_t * last_y
Definition MDFEchoCancellation.h:401
echo_word32_t Davg1
Definition MDFEchoCancellation.h:409
echo_float_t Pey
Definition MDFEchoCancellation.h:423
echo_word16_t beta0
Definition MDFEchoCancellation.h:391
void * echo_fft_init(int size, AudioFFTBase *driver, const Allocator &alloc)
Initialize FFT state.
Definition MDFEchoCancellation.h:1538
int C
Definition MDFEchoCancellation.h:387
echo_word16_t * Y
Definition MDFEchoCancellation.h:402
echo_float_t * power_1
Definition MDFEchoCancellation.h:416
echo_float_t Dvar2
Definition MDFEchoCancellation.h:413
echo_word32_t sum_adapt
Definition MDFEchoCancellation.h:393
int M
Definition MDFEchoCancellation.h:382
echo_mem_t * notch_mem
Definition MDFEchoCancellation.h:431
echo_int16_t * play_buf
Definition MDFEchoCancellation.h:433
void filterDcNotch16(const echo_int16_t *in, echo_word16_t radius, echo_word16_t *out, int len, echo_mem_t *mem, int stride)
Apply DC notch filter to remove DC offset.
Definition MDFEchoCancellation.h:905
fft_state(int size, AudioFFTBase *drv, const Allocator &alloc=Allocator())
Construct FFT state with specified size and driver.
Definition MDFEchoCancellation.h:465
void echoFree(T *ptr, size_t count=0)
Deallocate memory using custom allocator.
Definition MDFEchoCancellation.h:839
echo_word16_t * e
Definition MDFEchoCancellation.h:396
echo_int32_t sampling_rate
Definition MDFEchoCancellation.h:389
struct EchoState_ EchoState
Definition MDFEchoCancellation.h:438
echo_word32_t * power
Definition MDFEchoCancellation.h:415
int control(int request, void *ptr)
Definition MDFEchoCancellation.h:675
MDFEchoCancellation(int filterLength, AudioFFTBase &fftDriver, const Allocator &alloc=Allocator())
Definition MDFEchoCancellation.h:515
echo_float_t operator*(const echo_float_t &other) const
Definition MDFEchoCancellation.h:182
int N
Definition MDFEchoCancellation.h:455
int nb_speakers
Definition MDFEchoCancellation.h:795
echo_word16_t notch_radius
Definition MDFEchoCancellation.h:430
int getFilterLength()
Definition MDFEchoCancellation.h:745
echo_word16_t preemph
Definition MDFEchoCancellation.h:429
echo_float_t Pyy
Definition MDFEchoCancellation.h:424
void ensureInitialized()
Ensure echo canceller is initialized (lazy initialization)
Definition MDFEchoCancellation.h:801
void echo_fft_destroy(void *table)
Destroy FFT state and release resources.
Definition MDFEchoCancellation.h:1560
int16_t m
Definition MDFEchoCancellation.h:174
echo_word16_t * foreground
Definition MDFEchoCancellation.h:407
echo_word32_t * Yf
Definition MDFEchoCancellation.h:419
int adapted
Definition MDFEchoCancellation.h:384
void setFilterLength(int len)
Definition MDFEchoCancellation.h:736
void echoFatal(const char *str)
Definition MDFEchoCancellation.h:852
void playback(const echo_int16_t *play)
Definition MDFEchoCancellation.h:607
echo_word32_t * Eh
Definition MDFEchoCancellation.h:421
echo_word32_t operator*(int32_t scalar) const
Definition MDFEchoCancellation.h:196
int saturated
Definition MDFEchoCancellation.h:385
int getImpulseResponseSize()
Definition MDFEchoCancellation.h:724
int getFrameSize()
Definition MDFEchoCancellation.h:713
echo_word16_t beta_max
Definition MDFEchoCancellation.h:392
echo_word16_t * input
Definition MDFEchoCancellation.h:399
void powerSpectrum(const echo_word16_t *X, echo_word32_t *ps, int N)
Compute power spectrum from FFT output.
Definition MDFEchoCancellation.h:940
int screwed_up
Definition MDFEchoCancellation.h:386
echo_word32_t * Rf
Definition MDFEchoCancellation.h:418
void echoWarning(const char *str)
Definition MDFEchoCancellation.h:848
void setSamplingRate(int rate)
Definition MDFEchoCancellation.h:718
EchoState * getState()
Definition MDFEchoCancellation.h:787
EchoState * state
Definition MDFEchoCancellation.h:790
T * echoAlloc(size_t count)
Allocate memory for array of type T using custom allocator.
Definition MDFEchoCancellation.h:821
constexpr echo_float_t(int16_t mantissa=0, int16_t exponent=0)
Definition MDFEchoCancellation.h:178
void powerSpectrumAccum(const echo_word16_t *X, echo_word32_t *ps, int N)
Accumulate power spectrum from FFT output.
Definition MDFEchoCancellation.h:954
echo_word16_t leak_estimate
Definition MDFEchoCancellation.h:394
std::vector< float, FloatAllocator > temp_img
Definition MDFEchoCancellation.h:457
void capture(const echo_int16_t *rec, echo_int16_t *out)
Definition MDFEchoCancellation.h:585
int nb_mic
Definition MDFEchoCancellation.h:794
typename std::allocator_traits< Allocator >::template rebind_alloc< float > FloatAllocator
Definition MDFEchoCancellation.h:452
int cancel_count
Definition MDFEchoCancellation.h:383
void setFFTDriver(AudioFFTBase &fftDriver)
Definition MDFEchoCancellation.h:778
void reset()
Definition MDFEchoCancellation.h:629
friend echo_word32_t operator*(int32_t scalar, const echo_float_t &f)
Definition MDFEchoCancellation.h:206
echo_word16_t * window
Definition MDFEchoCancellation.h:425
int frame_size
Definition MDFEchoCancellation.h:380
echo_word32_t Davg2
Definition MDFEchoCancellation.h:411
echo_word32_t * Xf
Definition MDFEchoCancellation.h:420
echo_word16_t * E
Definition MDFEchoCancellation.h:403
MDFEchoCancellation(int filterLength, int nbMic, int nbSpeakers, AudioFFTBase &fftDriver, const Allocator &alloc=Allocator())
Definition MDFEchoCancellation.h:526
echo_word16_t * memE
Definition MDFEchoCancellation.h:428
float spxExp(float x)
Compute exponential function.
Definition MDFEchoCancellation.h:887
void weightedSpectralMulConj(const echo_float_t *w, const echo_float_t p, const echo_word16_t *X, const echo_word16_t *Y, echo_word32_t *prod, int N)
Compute weighted spectral multiplication with conjugate.
Definition MDFEchoCancellation.h:996
echo_word32_t * PHI
Definition MDFEchoCancellation.h:404
echo_word16_t * wtmp
Definition MDFEchoCancellation.h:417
echo_word16_t * x
Definition MDFEchoCancellation.h:397
echo_word16_t * y
Definition MDFEchoCancellation.h:400
bool initialized
Definition MDFEchoCancellation.h:796
int getSpeakerChannels()
Definition MDFEchoCancellation.h:773
float spxCos(float x)
Compute cosine function.
Definition MDFEchoCancellation.h:894
EchoState * echoStateInitMc(int frame_size, int filter_length, int nb_mic, int nb_speakers)
Initialize multi-channel echo canceller state.
Definition MDFEchoCancellation.h:1055
int play_buf_started
Definition MDFEchoCancellation.h:435
void echoCancellationImpl(EchoState *st, const echo_int16_t *in, const echo_int16_t *far_end, echo_int16_t *out)
Core echo cancellation implementation.
Definition MDFEchoCancellation.h:1179
echo_word16_t * memD
Definition MDFEchoCancellation.h:428
Allocator allocator
Definition MDFEchoCancellation.h:792
int filter_length
Definition MDFEchoCancellation.h:793
@ TX_MODE
Definition AudioTypes.h:30