[pulseaudio-discuss] pulseaudio-discuss Digest, Vol 109, Issue 14

Stuart Naylor stuartiannaylor at outlook.com
Fri May 22 17:49:30 UTC 2020


Still the same and with tsched presume this is what you mean

No /etc/asound.conf or .asoundrc just vanilla
Set pa default sink source to correct card and all plays ok.
When media is playing and EC kicks in recording is the same quiet ‘vocoded’ garble.


/etc/pulse/default.pa
### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect tsched=0
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect tsched=0
.endif

### 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


Picked the above purely as example
I will clone pulseaudio and compile and run the test applications next.

Journalctl is complaining and maybe but don’t think this is actually effecting EC

May 22 18:32:10 raspberrypi systemd[594]: Started Sound Service.
May 22 18:32:10 raspberrypi systemd[594]: Reached target Default.
May 22 18:32:10 raspberrypi systemd[594]: Startup finished in 1.558s.
May 22 18:32:10 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 22 18:32:10 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (16127), drop source 4128
May 22 18:32:24 raspberrypi systemd-timesyncd[281]: Synchronized to time server for the first time 195.219.205.9:123 (2.debian.pool.ntp.org).
May 22 18:32:28 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] alsa-source.c: ALSA woke us up to read new data from the device, but there was actually nothing to read.
May 22 18:32:28 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] alsa-source.c: Most likely this is a bug in the ALSA driver 'snd_usb_audio'. Please report this issue to the ALSA developers.
May 22 18:32:28 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] alsa-source.c: We were woken up with POLLIN set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
May 22 18:32:31 raspberrypi systemd[1]: systemd-hostnamed.service: Succeeded.
May 22 18:34:12 raspberrypi pulseaudio[607]: E: [alsa-sink-USB Audio] alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write.
May 22 18:34:12 raspberrypi pulseaudio[607]: E: [alsa-sink-USB Audio] alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_usb_audio'. Please report this issue to the ALSA developers.
May 22 18:34:12 raspberrypi pulseaudio[607]: E: [alsa-sink-USB Audio] alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
May 22 18:35:45 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 22 18:35:45 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (13270), drop source 3392
May 22 18:36:30 raspberrypi sshd[651]: Accepted password for pi from 192.168.1.8 port 62656 ssh2
May 22 18:36:30 raspberrypi sshd[651]: pam_unix(sshd:session): session opened for user pi by (uid=0)
May 22 18:36:30 raspberrypi systemd-logind[356]: New session c2 of user pi.
May 22 18:36:30 raspberrypi systemd[1]: Started Session c2 of user pi.
May 22 18:36:42 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 22 18:36:42 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (8087), drop source 2064
May 22 18:36:48 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 22 18:36:48 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (109101), drop source 27928
May 22 18:36:48 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Doing resync
May 22 18:36:48 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (30637), drop source 7840
May 22 18:36:49 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (87442), drop source 22384
May 22 18:36:50 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (6950), drop source 1776
May 22 18:36:51 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9035), drop source 2312
May 22 18:36:52 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9685), drop source 2472
May 22 18:36:53 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10327), drop source 2640
May 22 18:36:54 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9473), drop source 2424
May 22 18:36:55 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10344), drop source 2648
May 22 18:36:56 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9592), drop source 2448
May 22 18:36:57 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10263), drop source 2624
May 22 18:36:58 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9805), drop source 2504
May 22 18:36:59 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10170), drop source 2600
May 22 18:37:00 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9643), drop source 2464
May 22 18:37:01 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10247), drop source 2616
May 22 18:37:02 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10158), drop source 2600
May 22 18:37:03 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9979), drop source 2552
May 22 18:37:04 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9802), drop source 2504
May 22 18:37:05 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9994), drop source 2552
May 22 18:37:06 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10367), drop source 2648
May 22 18:37:07 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9774), drop source 2496
May 22 18:37:08 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9974), drop source 2552
May 22 18:37:09 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10064), drop source 2576
May 22 18:37:10 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10102), drop source 2584
May 22 18:37:11 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9675), drop source 2472
May 22 18:37:12 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (9948), drop source 2544
May 22 18:37:13 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10421), drop source 2664
May 22 18:37:14 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback too far ahead (10022), drop source 2560
May 22 18:37:15 raspberrypi pulseaudio[607]: E: [alsa-source-USB Audio] module-echo-cancel.c: Playback after capture (-390), drop sink 176
May 22 18:47:28 raspberrypi systemd[1]: Starting Cleanup of Temporary Directories...


Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: pulseaudio-discuss-request at lists.freedesktop.org<mailto:pulseaudio-discuss-request at lists.freedesktop.org>
Sent: 22 May 2020 13:00
To: pulseaudio-discuss at lists.freedesktop.org<mailto:pulseaudio-discuss at lists.freedesktop.org>
Subject: pulseaudio-discuss Digest, Vol 109, Issue 14

Send pulseaudio-discuss mailing list submissions to
        pulseaudio-discuss at lists.freedesktop.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
or, via email, send a message with subject or body 'help' to
        pulseaudio-discuss-request at lists.freedesktop.org

You can reach the person managing the list at
        pulseaudio-discuss-owner at lists.freedesktop.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of pulseaudio-discuss digest..."


Today's Topics:

   1. Re: Webrtc AEC Raspberry Pi weird effects. (Arun Raghavan)
   2. Re: pa echo-cancel module and alsa (Monkey Bizness)


----------------------------------------------------------------------

Message: 1
Date: Thu, 21 May 2020 16:10:59 -0400
From: "Arun Raghavan" <arun at arunraghavan.net>
To: "Stuart Naylor" <stuartiannaylor at outlook.com>, "PulseAudio
        Discussion" <pulseaudio-discuss at lists.freedesktop.org>
Subject: Re: [pulseaudio-discuss] Webrtc AEC Raspberry Pi weird
        effects.
Message-ID: <1ed787dc-a446-4f9f-8843-85f760640381 at www.fastmail.com>
Content-Type: text/plain;charset=utf-8

Hi Stuart,

On Wed, 13 May 2020, at 10:33 AM, Stuart Naylor wrote:
>
> I will post the recordings.
>
>  EC
> https://drive.google.com/file/d/13WCq9Bs-cW-cJsGFwU9s6DZ2UNLPXyMU/view?usp=sharing
>
>
> No-EC
>
> https://drive.google.com/file/d/1HH5klDS_Y5Lcmsuc2EWsBO517V4dwLV0/view?usp=sharing

So I take it this is with webrtc?

What you're

>  If I run speexdsp AEC with exact same setup but via alsa with
> pulseaudio removed then the results are quite good.
>  The speaker is only 12? from the mic and 12? from me and quite loud as
> wondering what upstairs thinks.
>  But anyway the results are pretty good.
>
>  EC
>
> https://drive.google.com/file/d/1ohO0YaO3CEwrXWwcj8qDbUpWuQo5sv2T/view?usp=sharing
>
>
> No-EC
>
> https://drive.google.com/file/d/12qNv6O9o-ttFoWE9tytqXdbAKCkPT6NW/view?usp=sharing

Ah, that is quite good!

> Journalctl is giving the usual but this is a single usb soundcard with
> single clock for capture/playback.
>
>  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

The source dropped messages are from us trying to do drift compensation and matching the samples we believe correspond to each other given we know what the playback and capture latencies are.

Now if your device driver does not report the ALSA pointer correctly, this can throw the latency reports, and thus the AEC off. In your ALSA-only test, you are likely not exercising the ALSA API in the same way as PulseAudio does (for power saving etc.).

Do you see the same problem if you load the ALSA modules with tsched=off?

> I am sure there is something not quite write with the
> webrtc_audio_processing when it comes to arm Linux maybe even just the
> Pi which here is a Pi4.
>  Anyone any idea why the first EC with pulseaudio is so bad whilst even
> the supposedly weaker speexdsp aec actually makes quite a good job with
> exactly same hardware and setup?

I think one thing to do is minimise the dropped source/sink buffers, to get some steady performance.

Another way to experiment is to load module-echo-cancel with save_aec=true. This will dump the playback, capture, and cancelled data to /tmp.

You can then run echo-cancel-test (you'll need to have a PA build handy), which allows you to rerun on the same input with different AEC engines/parameters. However, all this only makes sense if you can get a steady state with buffers not being dropped. Each dropped buffer is going to introduce a discontinuity/non-linearity that throws the AEC engine for a toss for a short while at least.

Hope this helps,
Arun


------------------------------

Message: 2
Date: Fri, 22 May 2020 09:43:13 +0200
From: Monkey Bizness <monkey at infra-monkey.com>
To: pulseaudio-discuss at lists.freedesktop.org
Subject: Re: [pulseaudio-discuss] pa echo-cancel module and alsa
Message-ID:
        <e99842240c0cabc8700485320f9f1c53d649c423.camel at infra-monkey.com>
Content-Type: text/plain; charset="utf-8"

So it appears my alsa configuration was messing things up a bit I
think, and as I have only one app using audio, there is only little
interest in not using the default pulse config...A parallel thread
regarding AEC points out to time scheduling issues on raspberry pi.
So I could make AEC work by:  - removing my alsa config and just
keeping the default pulse device - loading module-alsa-sink with
tsched=off - defining my echo-cancel  sink and source as default
Now the autoload creates an additional sink for the alsa device
alsa_output.platform-bcm2835_audio.stereo-fallback and sets it by as
the default sink, overwritting the default sink i defined in the
configuration.
How can i force pulse autoload to either not add that input device, or
not set it as default sink?
thanksMonkey
On Tue, 2020-05-19 at 13:00 +0200, Monkey Bizness wrote:
> Hi,
>
> I'm hoping someone here can help me figure out how to setup my
> configuration properly.
>
> I'm trying to output sound through the echo-cancel module but by
> going through the alsa device. Unfortunately, the application doesn't
> support pulseaudio for the playback.
>
> configuration:
> raspberry pi 4ubuntu 20.04
> ffmpeg : 4.2.2-1ubuntu1
> pulseaudio : 13.99.1-1ubuntu3.2
>
>
>
>
> In order to do that, i've defined the echo-cancel configuration in
> /etc/pulse/default.pa:load-module module-echo-cancel
> use_master_format=1 aec_method=webrtc
> aec_args="analog_gain_control=0\ digital_gain_control=1"
> source_name="echoCancel_source" sink_name="echoCancel_sink"
>
>
> It works. I can test it with :
> ffmpeg -i recording.wav -f pulse -device echoCancel_sink test
>
>
>
> Now in order to playback through alsa, i've defined a pcm device:
> cat /etc/alsa/conf.d/90-echocancel.conf
> pcm.pulse-echo-cancel {
>
>         type pulse
>
>         device "echoCancel_sink"
>
> }
>
>
>
> ctl.pulse-echo-cancel {
>
>         type pulse
>
>         sink "echoCancel_sink"
>
> }
>
>
>
>
> When I try this configuration with:
>
> ffmpeg -i recording.wav -f alsa pulse-echo-cancel
>
>
>
> Sound is scrambled and super slow.
>
>
> Does anyone know how to make this configuration work?
> Any pointer would be appreciated.
>
>
> I feel I got the correct overall approach but i am missing something
> about the rate convertion or specification.
>
>
> Best regards
>
>
>
> _______________________________________________pulseaudio-discuss
> mailing listpulseaudio-discuss at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20200522/16f19af4/attachment-0001.htm>

------------------------------

Subject: Digest Footer

_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


------------------------------

End of pulseaudio-discuss Digest, Vol 109, Issue 14
***************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20200522/4dd33561/attachment-0001.htm>


More information about the pulseaudio-discuss mailing list