# Audio echo and feedback cancelation

**URL:** <https://discourse.julialang.org/t/audio-echo-and-feedback-cancelation/272>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 13, 2016, 2:03pm UTC](https://discourse.julialang.org/t/audio-echo-and-feedback-cancelation/272 "2016-11-13T14:03:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [November 13, 2016, 2:03pm UTC](https://discourse.julialang.org/t/audio-echo-and-feedback-cancelation/272/1 "2016-11-13T14:03:07Z")

</div>

Hi all,

I am trying to use [PortAudio.jl](https://github.com/JuliaAudio/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:

```julia
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?

Cheers,

Bart

---

<div class="post-metadata">

**Author:** ![akis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/akis/32/156_2.png) [@akis](https://discourse.julialang.org/u/akis)\
**Post date:** [November 13, 2016, 3:47pm UTC](https://discourse.julialang.org/t/audio-echo-and-feedback-cancelation/272/2 "2016-11-13T15:47:24Z")

</div>

I cannot answer the OP, but this calls for the addition of an Audio or Sound category, to serve the [JuliaAudio](https://github.com/JuliaAudio/) Git organization.

EDIT: Audio and its relatives have found a house in the [Signal Processing](https://discourse.julialang.org/c/domain/dsp) category.

---

<div class="post-metadata">

**Author:** ![Oliver\_Lylloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliver_lylloff/32/9022_2.png) [@Oliver\_Lylloff](https://discourse.julialang.org/u/Oliver_Lylloff)\
**Post date:** [November 13, 2016, 11:18pm UTC](https://discourse.julialang.org/t/audio-echo-and-feedback-cancelation/272/3 "2016-11-13T23:18:16Z")

</div>

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…

Best,  
Oliver

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [November 14, 2016, 12:10am UTC](https://discourse.julialang.org/t/audio-echo-and-feedback-cancelation/272/4 "2016-11-14T00:10:48Z")

</div>

[Audio domain](https://discourse.julialang.org/c/domain/audio) created; the [description page](https://discourse.julialang.org/t/about-the-audio-category/275) is a wiki so please edit as appropriate.

Edit: the domain was renamed to [Signal Processing](https://discourse.julialang.org/c/domain/dsp) based on feedback.

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [November 17, 2016, 3:54pm UTC](https://discourse.julialang.org/t/audio-echo-and-feedback-cancelation/272/5 "2016-11-17T15:54:07Z")

</div>

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.
