VIANC/pw_plugin_II/aec.h

39 lines
778 B
C
Raw Normal View History

#pragma once
2025-02-09 11:00:00 +01:00
#include "fdaf.h"
#include <array>
class AEC {
public:
2025-02-09 11:00:00 +01:00
void do_sample(float mic, float hp, bool maybevoice);
void do_buffer(float* res, float* mic, float* hp, bool maybevoice);
bool inject_noise();
2025-02-09 11:00:00 +01:00
std::array<float, 8192> lookback;
int lb_index;
/*
By chunks of 8 samples
We expect to have >= 1024 samples delay, or 128 chunks delay.
*/
std::array<float, 512> lookback_power;
float mic_acc = 0.0f;
float hp_acc = 0.0f;
int lookback_phase = 0;
std::array<float, 512> weighted_xcorr;
static constexpr float xcorr_decay = (1.0f)/(48000/8); // 100ms
int current_delay = 0; // We expect sudden drifts
2025-02-11 14:14:22 +01:00
enum {LOST, LEARNING, ONLINE} status = LOST;
int cnt = 0;
2025-02-09 11:00:00 +01:00
FDAF fd = FDAF(1024);
private:
void find_delay(float mic, float hp);
};