47 lines
1 KiB
C
47 lines
1 KiB
C
|
#include "stream_wrapper.h"
|
||
|
#include "ringbuffer.h"
|
||
|
#include "passthrough.h"
|
||
|
|
||
|
//#include "lustre/dsp_EchoCancel.h"
|
||
|
#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;
|
||
|
};
|
||
|
|
||
|
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 ?
|
||
|
private:
|
||
|
logger_record& pstrm;
|
||
|
|
||
|
ringbuffer* hp_rb;
|
||
|
ringbuffer* mic_rb;
|
||
|
|
||
|
int hp_mic_delta = 0;
|
||
|
/* When first sample from mic is acquired, where was the read head
|
||
|
of the hp ringbuffer. This roughly tells us what is the delta in
|
||
|
the 0-delay case. (Up to a quantum.)
|
||
|
*/
|
||
|
|
||
|
enum {INIT, SKIP_EARLY, SCAN_SILENT, SCAN_LOUD, INACTIVE} status;
|
||
|
int remaining_samples = -1; // Remaining samples in current phase
|
||
|
|
||
|
|
||
|
aec_params params;
|
||
|
std::mutex prm_mutex;
|
||
|
};
|