#include "stream_wrapper.h" #include "ringbuffer.h" #include "passthrough.h" #include "lustre/dsp_EchoCancel.h" #include 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; bool force_learn = true; }; 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 ? _real h[256]; int cnt = 0; private: logger_record& pstrm; ringbuffer* hp_rb; ringbuffer* mic_rb; enum {INIT, SKIP_EARLY, SCAN_SILENT, SCAN_LOUD, ACTIVE, INACTIVE} status; int remaining_samples = -1; // Remaining samples in current phase aec_params params; std::mutex prm_mutex; dsp_EchoCancel_ctx_type* ctx; };