Audio echo and feedback cancelation



Hi all,

I am trying to use PortAudio.jl to build a system that immediately plays back audio from a microphone to the speakers. The long term plan is to be able to add funny effects and things like pitch correction. The idea is to make this run on the Raspberry Pi and use it as a system for my daughter to sing along with music videos.

It turns out to be very simple with PortAudio to just feed the microphone output to the speakers:

using PortAudio

stream = PortAudioStream(2, 2)
write(stream, stream)

However, as one might expect, depending on the buffer size this gives either horrible feedback or echo. Is there a standard algorithm to cancel these effects that would be easy to implement using what’s available in Julia?




I cannot answer the OP, but this calls for the addition of an Audio or Sound category, to serve the JuliaAudio Git organization.

EDIT: Audio and its relatives have found a house in the Signal Processing category.


Hi Bart,

Doesn’t answer your question but you could start by separating mic and speakers physically such that the mic doesn’t pick up the speaker signals. However, an algorithm would be cool to have in julia. There are plenty of audio feedback cancellation algorithms out there but have not seen any written i julia. You could start by trying out some written in python perhaps…



Audio domain created; the description page is a wiki so please edit as appropriate.

Edit: the domain was renamed to Signal Processing based on feedback.


I don’t have any specific experience implementing AEC (acoustic echo cancellation), but I agree it’d be great to see an algorithm implemented in Julia.

Also I’m excited that you’re using PortAudio.jl and it was easy to get going for you. Don’t hesitate to let me know if you hit stumbling blocks. It’s still a pretty young library so I wouldn’t be surprised if there are some rough edges that can be smoothed.