VIANC/pw_plugin/micpath.h

46 lines
947 B
C
Raw Normal View History

2025-01-28 22:09:02 +01:00
#include "stream_wrapper.h"
#include "ringbuffer.h"
#include "passthrough.h"
2025-01-30 01:57:30 +01:00
#include "lustre/dsp_EchoCancel.h"
2025-01-28 22:09:02 +01:00
#include <mutex>
struct aec_params {
float noise_power = 0.0f;
float echo_return_gain = 1.0f;
float fast_learn_rate = 1.0f/128;
float learn_rate = 1.0f/1280;
int sample_delay = 0;
bool valid = false;
2025-01-30 02:06:59 +01:00
bool force_learn = true;
2025-01-28 22:09:02 +01:00
};
class aec_stream : public pwstream {
public:
aec_stream(pw_loop* lp, ringbuffer* hp, ringbuffer* mic,
logger_record& record_stream, aec_params p = {});
aec_params get_aec_params();
void on_process() override;
float cov[8192]; // From 1024 to 1024+2048 delay ?
2025-01-30 01:57:30 +01:00
_real h[256];
int cnt = 0;
2025-01-28 22:09:02 +01:00
private:
logger_record& pstrm;
ringbuffer* hp_rb;
ringbuffer* mic_rb;
2025-01-30 01:57:30 +01:00
enum {INIT, SKIP_EARLY, SCAN_SILENT, SCAN_LOUD, ACTIVE, INACTIVE} status;
2025-01-28 22:09:02 +01:00
int remaining_samples = -1; // Remaining samples in current phase
aec_params params;
std::mutex prm_mutex;
2025-01-30 01:57:30 +01:00
dsp_EchoCancel_ctx_type* ctx;
2025-01-28 22:09:02 +01:00
};