#include #include #include #include #include #include #include #include #include #include "pipewire/pipewire.h" #include "spa/param/audio/format-utils.h" #include "spa/param/latency-utils.h" #include "passthrough.h" #include "micpath.h" int main(int argc, char** argv) { pw_init(&argc, &argv); auto* tloop = pw_thread_loop_new("thread", NULL); { ringbuffer rb; if(tloop == nullptr) { std::cerr << "Could not create loop!\n"; return 1; } logger_record lr(pw_thread_loop_get_loop(tloop), &rb); logger_playback lp(pw_thread_loop_get_loop(tloop), &rb);//, true, false); ringbuffer mic_rb; logger_record mic_lr(pw_thread_loop_get_loop(tloop),&mic_rb, "aec-record", "Capture"); aec_stream aec(pw_thread_loop_get_loop(tloop), &rb, &mic_rb, lr); pw_thread_loop_start(tloop); aec_params x; do { std::this_thread::sleep_for(std::chrono::seconds(1)); x = aec.get_aec_params(); } while(!x.valid); while(true) { std::this_thread::sleep_for(std::chrono::seconds(60)); } std::puts("L = ["); for(int i = 0; i < 8192; ++i) { std::printf("%f,", aec.cov[i]); } std::puts("]"); std::printf("Noise power : %f dB\n", 10*std::log10(x.noise_power)); std::printf("Echo return loss : %f dB (-20dB input power)\n", -10*std::log10(x.echo_return_gain)); std::printf("Delay : %d samples\n", x.sample_delay); std::this_thread::sleep_for(std::chrono::seconds(600)); pw_thread_loop_stop(tloop); std::puts("h = ["); for(int i = 0; i < 128; ++i) { std::printf("%e,", (float)aec.h[i]); } std::puts("]"); } pw_thread_loop_destroy(tloop); pw_deinit(); std::puts("See you space cowboy..."); return 0; }