EC respeaker echo cancellation

I don’t think it prob needs it @j1nx as like you RAM usuage seems to be quite low. I think the mycroft-core install is the only big requirement and that is only when you choose to install it that way.

But yeah getting the codec to work on this thing might be another thing! :slight_smile:
Also like always its adverised as 1.3Ghz and I am currently asking why mine is fixed to a max of 1Ghz.
But it could make a great little low cost device that is extremely suited for the multiple satelite role.

For $25 you can stick 2x Mems I2S mics on a Pi3A+ and its job done and such a shame for some reason it doesn’t work on the Pi4.
Also a USB sound card with a stereo ADC hasn’t been ruled out and I will also give you a shout about those also.

Ps I did some benchmarks running @ 1296000 and seems stable and doesn’t throttle.

I used the Pi benchs of http://www.roylongbottom.org.uk/Raspberry%20Pi%20Benchmarks.htm
Where the original is http://www.roylongbottom.org.uk/Rpi3-64-Bit-Benchmarks.tar.gz

But also if you download this one it has the benchtexts from the last RockPiS in it so you can compare before you run.
RockPiS trades very well with a Pi3B+

Benches are what they are but it gives you a metric to the RockPiS

@StuartIanNaylor Just stumbled on this new one;

https://www.waveshare.com/maix-r6-1-microphone-array.htm

Not for RPI, but perhaps could be hacked / make workable

1 Like

Its just a Mic board though?

https://www.waveshare.com/Maix-Go-AIoT-Developer-Kit.htm

The usb butt plug turns up today and will see how it works with software EC.

There is a bit with zram that has confused when zram is enabled for some reason the raspbian kernel config has the writeback cache disabled.
Which is a further backup if mem gets low where swap will get idle pages pushed out to swap whilst zram continues to be used.
I have no idea why they disabled it as it has to be enabled on each zram drive you create and the default is off.

http://www.enermax.com/home.php?fn=eng/product_a1_1_1&lv0=3&lv1=59&no=192

Back to that time again with the Enermax AP001E DreamBass USB Soundcard.
Finally got a passive mic and not a 4 pole that I got by mistake.
Also got some mic modules but not bothered to wire up as the passive mic is much better than expected.

I also got a syba SD-AUD20101 which actually is the chipset but the dreambass of the enermax isn’t so dreamy for me and far too pronounced.
The Syba turned up and will test but its not a SD-AUD20101which has the via chip inside its a cheaper cmedia mono mic chip in packaging and labelled as SD-AUD20101 but linux says otherwise.
So beware as to be polite obvs some got mistakenly packaged.

The sound is pretty good from the enermax apart from being bass heavy which prob will fix with a DC blocking cap that will also attenuate the bass.
Thinking approx 1uF should do the trick.

The USB soundcards are free of the horrid respeaker drivers and same price and don’t take up your GPIO header so definately changed my choice.
Next step is to check PulseAudio webrtc as with the respeaker driver it just didn’t seem to like the pulseaudio install and the driver would fail.

I have no idea what is happening with pulseaudio with this card as seems a pretty default setup.

May 13 14:14:30 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 13 14:14:30 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (37856), drop
May 13 14:14:49 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 13 14:14:49 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (131103), dro
May 13 14:14:49 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 13 14:14:49 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (75977), drop
May 13 14:14:50 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (62480), drop
May 13 14:14:51 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (13404), drop
May 13 14:14:52 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10231), drop
May 13 14:14:53 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9131), drop
May 13 14:14:54 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9136), drop
May 13 14:14:55 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9651), drop
May 13 14:14:56 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9915), drop
May 13 14:14:57 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9814), drop
May 13 14:14:58 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10011), drop
May 13 14:15:00 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback after capture (-580), drop
May 13 14:15:03 raspberrypi pulseaudio[608]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback after capture (-158), drop
May 13 14:15:20 raspberrypi pulseaudio[608]: E: [alsa-sink-USB Audio] alsa-sink.c: ALSA woke us up to write new data to the device
May 13 14:15:20 raspberrypi pulseaudio[608]: E: [alsa-sink-USB Audio] alsa-sink.c: Most likely this is a bug in the ALSA driver 's
May 13 14:15:20 raspberrypi pulseaudio[608]: E: [alsa-sink-USB Audio] alsa-sink.c: We were woken up with POLLOUT set -- however a

We still get resync messages and to be honest if someone else wants to find out why with PA please do but listen to this.

I can could never get the latency of the ec as it always errors but the latency of the hardware is much lower and actually I had the delay set to 75.

pi@raspberrypi:~ $ alsabat -Dplughw:Dongle --roundtriplatency
alsa-utils version 1.1.8


Start round trip latency
Entering playback thread (ALSA).
Set period size: 45  buffer size: 90
Get period size: 45  buffer size: 90
Playing generated audio sine wave
Entering capture thread (ALSA).
Set period size: 45  buffer size: 90
Get period size: 45  buffer size: 90
Recording ...
Test1, round trip latency 10ms
Test2, round trip latency 10ms
Test3, round trip latency 10ms
Test4, round trip latency 10ms
Test5, round trip latency 11ms
Final round trip latency: 10ms
Playback completed.
Capture completed.

Return value is 0

Whilst I have the imposter USB audio card thought I would run the same tests.
Prob just a cheap c-media chip inside but not what it says on the outside.
Runs a bit quieter than the via and mic capture is lower so bear that in mind when listening to playback.

No-ec

ec

So USB soundcards with capture/playback on single device actually don’t do that bad and are very cost effective that will work with alsa speex Aec.

I have run into a barrier with my RK3308 that didn’t evisage but speex-dsp with neon enabled doesn’t compile on aarch64!
Dunno why but yeah complains and errors about missing 16bit integers.

I do have one more test with pi0/pi3 where basically make my own sound card via I2S modules, known not to work on the Pi4.

But to be honest the easiest route negating the respeaker driver hell of the 2mic is a stereo ADC sound card for approx the same cost of about $10.

That will prob be my next test as have various powered modules to test but maybe apart from the ‘unknown’ c-media even a $3 lapel passive mic off ebay worked quite well on the via and was slighlty less sensitive on the c-media

Ok 2x $1.80 I2S Mems Mics + Pi 3.5mm

https://www.aliexpress.com/item/4000320765322.html

The above is worth a read as " What is the difference between an omnidirectional microphone and a unidirectional microphone:" is pure comedy.

Really all the thunder goes to Adafruit as they have done all the work and looks like it supports all Pi models now.

I have a adafruit module on the way and will tell you if the audio quality is any better but the cheap aliexpress modules are at least adequate.
Adafruit document and provide the driver so if you can purchase from them.

All the wiring and install is in the brilliant adafruit tutorial.

My .asoundrc is as so.

pcm.!default {
    type asym
    playback.pcm "eci"
    capture.pcm "eco"
}


pcm.eci {
    type plug
    slave {
        format S16_LE
        rate 16000
        channels 1
        pcm {
            type file
            slave.pcm null
            file "/tmp/ec.input"
            format "raw"
        }
    }
}

pcm.eco {
    type plug
    slave.pcm {
        type fifo
        infile "/tmp/ec.output"
        rate 16000
        format S16_LE
        channels 2
    }
}




pcm.dmic_hw {
	type hw
	card sndrpii2scard
	channels 2
	format S32_LE
}
 
pcm.dmic_sv {
	type softvol
	slave.pcm dmic_hw
	control {
		name "Boost Capture Volume"
		card sndrpii2scard
	}
	min_dB -3.0
	max_dB 30.0
}


pcm.cap {
 type plug
 slave {
   pcm "dmic_sv"
   channels 2
   }
 route_policy sum

}

Then in 3 cli windows for ec its start ec with

```` ./ec -i plug:cap -o plughw:1 -d 20`

then just
aplay file_example_WAV_10MG.wav
arecord -r16000 -fS16_LE -c1 ec-i2s.wav

So no soundcard needed just 2x I2S mics direct to GPIO & 3.5mm Pi output.
Was pretty sure this would work as they are essentiall all on the same clock of the Pi I2S.

For the cable and a bit of soldering

1 Like

I am going to have to have relook at my 4 mic linear array as after the I2s mic thinking hold on that should be the same clock as the Pi 3.5mm.

They are getting cheaper and noticed this one as well but a clone and hate the drivers.

[EDIT]
memory coming back to me there are only 2 channels avail on that I2S clock so a 4 channel will not work.
2x I2s does 4x does not.

I tried to use AEC by EC on RPI 3A+ with respeaker 4mic for pi. It works but at the begining of my playing sound, the sound gose intermittently for 5 to 15 sec. I still did not solve this.

Dunno as not all that keen on the respeaker drivers but did try it with the linear4mic and 2mic.

But noticed speexdsp is an RC in raspbian and have always been compiling so maybe that.

sudo apt-get install autotools-dev autoconf libtool pkg-config if not raspbian32
Don’t --enable-neon if 64bitOS, still is detected and compiled neon optimised but adding that screws the compile ?!

git clone https://github.com/xiph/speexdsp.git
cd speexdsp
./autogen.sh
./configure --lib-dir=/usr/lib/arm-linux-gnueabihf or /usr/lib/aarch64-linux-gnu depending on OS.

You will have to do a ./configure -h as that was from memory and it aint good.

make & sudo make install

The filter is adaptive and it gets better after the first couple of seconds but didn’t cut out.

Also sudo modprobe snd-aloop as it stops after recording but you can arecord -Dmydevice > aplay -Dloopback and the other side is then your source.

I have to revist the 4mic linear as seem to remember it acted like it had a seperate clock from the I2S clock and wasn’t synced.
But like I say my memory not so sure now.

In fact yep it must have as its 4 channel and there are only 2 avail on that I2s so nope apols prob not going to work.

seems need username and password to git clone

Its not going to work Zitan as there are only 2 channels remaining on that I2S clock and obviously its 4 and seperate.

Its github but you usually don’t need to login.

If it on another clock you get clock drift between playback and capture and due to the nature of fft the whole EC just goes to hell.
Even when you think its working that is totally not the rather good results I get.
You either need a 2mic card with onboard codec or wire up 2x I2s mic direct.

I typed a wrong letter sorry hahaha

it takes one channel to record and as playback , than make it into a stereo

From memory I think I2S has 2 channels on the Pi but in each channel there is a high/low word for left/right.
The Pi 3.5mm mono is on one so the other channel has 2 but not 4 and even though other word is not used that channel is in use.

Lols didn’t make much sense but on one Pi I2S channel you have a left and right word serialised after each other and a left/right clock to select the left/right word.
The other I2S channel the mono 3.5mm is on and not sure if that is just down mixed to a single word or connector or whatever but its in use.

So apols but no point getting my 4mic linear out as its not going to work.

If you get a usb sound card that will alaso work but think I prefer 5 wires and 2 I2s mics.
https://www.aliexpress.com/item/4000320765322.html are cheap but really adafruit should get all the credit.

1 Like

https://1drv.ms/u/s!AihVIqpb7OsKxwagrlMifnqf_fyA?e=fc6f6w

for this link you can find my test result. and what is annoying me is that the sound 'jumped ’ and the begin. I have to wait until it become normal and then talk in front of respeaker to do the test.

Wow that really weird as it works really well after the initial annoying skip!

With me it never worked that well but didn’t skip just sounded like sh**

I had to get a sound card arrangement where playback clock and capture clock where the same.

Doesn’t work on the hot new RaspiOS arm64 as they still haven’t added the kernel headers as that was what I was trying earlier.
But 32bit the adafruit solution is just a matter of 5 wires total to GPIO for both mics.
The SEL pins its GND one side & VCC the other with 2 mics and that selects the hi/lo word it transmits on.

the skip is really irregular for me, sometimes almost no skip sometimes so much. (between 5 to 20 sec)

Not even all that sure how that is working so well on yours due to clock drift.

Pulseaudio webrtc AEC is supposed to be able to cope with clock drift but when I paplay / parecord after adding it to /etc/pulse/default.pa the results are terrible.

/etc/pulse/default.pa

 ### Enable Echo/Noise-Cancellation
 load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1\ agc_start_volume=85"  source_name=echoCancel_source sink_name=echoCancel_sink

    set-default-source echoCancel_source
    set-default-sink echoCancel_sink

But as said pulseaudio never worked for me but give it a try, but 2x I2S mic or USB soundcard.

thanks for your helping anyway, I will let you know when i get somethings new :slight_smile:

The kernel freeze with those respeakers are a liability to cause some dependency problems.
I would try 2x

But the cheap aliexpress ones do actually work OK even if sensitivity isn’t brilliant its adequate.