Echo cancellation in Rust

Hi everyone,

I'm working on a new crate for echo cancellation in Rust, utilizing SpeexDSP. I've already set up the bindings and everything necessary to correctly call SpeexDSP, along with example code.

However, even with the simplest example, the echo cancellation isn't working as expected and the echo remain. Would anyone be willing to take a look and provide some guidance or suggestions?

Here are the links to the project and the example:

Thanks in advance!

Update:
Something is wrong with bindgen types/pointers/hound here. it works well with C++ the same way!

It looks unsound for the constructor to take a buffer size and then the method call that uses it doesn't check that the passed slices accommodate the required buffer size.

There is a typo in usage.rs:

let aec = aec_rs::Aec::new(sample_rate, filter_length, sample_rate as _);

Looks like the first argument should be the frame size, not the sample rate. You are probably hitting UB due to the unsoundness, here.

I didn't look any further, but this is all too suspicious. Run the bin with the sanitizers. I have found it is easiest with Linux, or WSL if you are on Windows.

2 Likes

I just fixed the issues now. I can't tell what exactly was the issue because I tried so many things. I just re wrote it in C++ and then when it worked slowly implemented again in Rust.

Now everything works in the repo. thanks!