EC respeaker echo cancellation

The 2Mic turned up today and see zero advantage with the 4 mic linear especially as still can not find out if it has a loopback or not.
The 2 Mic is really good and my head is spinning with the number of buttons with this thing but its the https://statics.cirrus.com/pubs/proDatasheet/WM8960_v4.4.pdf so you can sort of work things out as you go along.
I wish the noise gate was enabled but don’t think it is.
Running EC currently on a Pi3A+ so its a $10 sound card with a little amp and a $25 SoC which aint bad.
I am still waiting for the 4 mic respeaker to arrive but already know that seperate playback and capture doesn’t work well with Speex AEC so much so that Speex say in the manual it just doesn’t work.
I have almost spend the same amount of getting a Respeaker USB v2.0 $10 more would of got me one :slight_smile:
But glad I persisted in this one as the options are quite clear the $10 2 mic makes and absolute amazing budget system even with a small amp built in.
The WM8960 can have a DC buzz but even the higher end Mics still use a WM8960 for output.
If you know the impendance of the amp then its some simple pythagoras math and 2 simple dc block capacitors.
Generally you don’t notice unless you hover your ear over a silent but active speaker.

Why the PS3eye is recommended isn’t that it was a waste of $ but wow such a damaging waste of time that was. As an introduction to Mycroft it baffles me why you would recommend that experience as there must be many no longer in forums who thought yeah they are no Google and Amazon and generally Mycroft is crap.
It isn’t but generally the PS3eye is especially when you compare it to a card that is 2-3$ more that has Leds, better audio quality, has inbuilt amp and even has leds gpio and i2c on it!?
But also it is possible to get a level of software AEC which has some huge advantages but purely having playback and capture on the same card so no clock drift between them just round trip latency.

Pi-Zero didn’t have any expectations but been really surprised that it actually has a good attempt and the load is manageable.
It doesn’t work well at all but never even though I would achieve that.

What it does prove to me is that the Pi3/4 is capable and they are providing pretty good results with the speexdsp-aec, but the software we have is not the greatest.
Thought I would post the above as it actually surprised me a zero even made an attempt.

After an epic search or what is the best cost effective hardware for Mycroft I might of found it even if I still have some other things to come.
In its this little thing next to the Pi4 and you can see the size as the Pi4 has a Zero soundcard hat on it.
Imgur

No GPU, approx Pi3 perf did some benchs and very close with Pi3/rk3308 swapping leads on different tests.
I am waiting for some mic modules to be delivered so dunno what the adc and embedded codec is like.
Its also got hardware VAD that can bring it out of a sleep state on voice so is the lowest power device we have by far.
When its out of sleep state the single mic input for wake can then be used with 4.
If what I have got works then with my above rambles at Pi3 level I can get AEC software running use DSP VAD the the $15 rk3308 starts looking really cost effective.
Its a choice of 2 or 4 mics https://www.aliexpress.com/item/32966959737.html which I have on order.
The 512Mb Wfif/Bt = $13.99

The above mems mic boards are $2.47 so its either x2 or 4 so $18.93 or $23.4 + P&P.
Also has an IPX antenna connection which is another bonus as range is likely good.

Really impressed with the price of the cortex-a35


Seems about right as after some benches the 1.5Ghz rk3308 seem on a par with the 1.4Ghz Pi3B+

Benchmarks are the one thing, real world performance the other. Rock Pi S has only 512MB RAM, but Mycroft likes a lot of RAM. All recommended hardware for Picroft has at least 1GB RAM. But for 15$ it is worth a try…

Its up to 40% faster than the Respeaker Core V2.0 that I think is going to be the core of the Mycroft II!?

I have had zero problem with Mycroft and a Pi3A+ so should have no problem with this and zram will always come to my rescue if I need it.
The only thing I haven’t noticed are ram intensive processes as much is relatively light apart from some of the install.
Can not remember what it was that was a memory chomper maybe the precise compile but when running Mycroft consumes quite low amounts of ram.
Its prob cause I always use zram that it has never even come close to being an issue.

Its not process power or ram it lacks but its me and working out the codec and setting the thing up.

Its process power you need for Mycroft and its approx a Pi3 via benchmark and also what Arm says about the A35 its the A7 of the respeaker core II that seems to dip under the hardware recommendations of at least a Pi3 or “Functions very slowly, …”

The Mycroft dev-team used the RC2 for prototyping of Mark-II after the plans for a custom SoC failed. To my knowledge current SBC candidates are the RPI4 and Pine H64 and plus the Respeaker 4mic USB for audio.

Pine H64 seems a bit bizarre as a choice but nothing new there :slight_smile: RPI4 is a good choice as same price.
Glad about that as never said anything but thought it would struggle on a RC2 that must of changed recently though.

But exactly dev or not it can not be that bad or its a reflection of the dev team.

I also never saw more than a couple of hundred MB’s of memory use and that is even with stuff pushed to it uncompressed via normal tmpfs.

# <file system>	<mount pt>	<type>	<options>	<dump>	<pass>
/dev/root	/		ext2	rw,noauto	0	1
proc		/proc		proc	defaults	0	0
devpts		/dev/pts	devpts	defaults,gid=5,mode=620,ptmxmode=0666	0	0
tmpfs		/dev/shm	tmpfs	mode=0777	0	0
tmpfs		/tmp		tmpfs	mode=1777	0	0
tmpfs		/run		tmpfs	mode=0755,nosuid,nodev	0	0
sysfs		/sys		sysfs	defaults	0	0
tmpfs		/var/log	tmpfs	defaults	0	0
tmpfs		/var/tmp	tmpfs	defaults	0	0
tmpfs		/ramdisk	tmpfs	rw,nodev,nosuid,size=20M	0	0

I just disabled swap completely.

But if for whatever reason you indeed go over the 512 limit, allocating a good part of it to zram might be sufficient to make it fit again.

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