snapcast icon indicating copy to clipboard operation
snapcast copied to clipboard

Can hear Click/Crackle/Pop when starting to play a stream

Open mape opened this issue 1 year ago • 3 comments

Issue

When an audio clip starts playing a click/crackle/pop sound appears at the very start.

Sound example

https://h.ma.pe/snapPopIssue.mp3

The example file is me running these two commands a couple of times. Note that the pop only happens at the start of each command.

ffmpeg -y -i test.wav -f wav -ar 48000 -sample_fmt s16 -ac 2 ./snapfifo ffmpeg -y -i silence.wav -f wav -ar 48000 -sample_fmt s16 -ac 2 ./snapfifo

If I pipe these commands into a file and listen back to it, everything sounds fine.

I hear the same issue on

  • A raspberry pi + hifiberry miniamp running docker (ivdata/snapclient)
  • Windows 10 using https://github.com/stijnvdb88/Snap.Net
  • Windows 10 using Snapcast web client
  • Linux Mint running docker (ivdata/snapclient)
  • Linux Mint using Snapcast web client

Server runs through docker (Version 0.26.0)

docker run -d \
        --name snapcast \
        --restart unless-stopped \
        -v ./snapfifo:/tmp/snapfifo \
        -v ./snapserver.conf:/etc/snapserver.conf \
        -p 1704:1704 \
        -p 1705:1705 \
        -p 1780:1780 \
        ivdata/snapserver:latest

snapserver.conf

[http]
enabled = true
doc_root = /usr/share/snapserver/snapweb

[stream]
stream = pipe:///tmp/snapfifo?name=Default&sampleformat=48000:16:2

Logs

2023-01-14T15:58:48.942187017Z Found user 'avahi' (UID 86) and group 'avahi' (GID 86).
2023-01-14T15:58:48.942566220Z Successfully dropped root privileges.
2023-01-14T15:58:48.942653323Z avahi-daemon 0.8 starting up.
2023-01-14T15:58:48.942728245Z WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
2023-01-14T15:58:48.945865361Z Loading service file /etc/avahi/services/sftp-ssh.service.
2023-01-14T15:58:48.945906378Z 2023-01-14 15-58-48.945 [Info] (Snapserver) Version 0.26.0
2023-01-14T15:58:48.945938198Z 2023-01-14 15-58-48.945 [Info] (Snapserver) Adding stream: pipe:///tmp/snapfifo?name=Default&sampleformat=48000:16:2
2023-01-14T15:58:48.946038586Z Loading service file /etc/avahi/services/ssh.service.
2023-01-14T15:58:48.946102316Z 2023-01-14 15-58-48.945 [Notice] (init) Settings file: "/root/.config/snapserver/server.json"
2023-01-14T15:58:48.946361954Z 2023-01-14 15-58-48.946 [Info] (Snapserver) Using HTTP host name: f11c42685605
2023-01-14T15:58:48.946409484Z Joining mDNS multicast group on interface eth0.IPv4 with address 172.17.0.16.
2023-01-14T15:58:48.946546120Z New relevant interface eth0.IPv4 for mDNS.
2023-01-14T15:58:48.946557862Z Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1.
2023-01-14T15:58:48.946564395Z New relevant interface lo.IPv4 for mDNS.
2023-01-14T15:58:48.946570456Z Network interface enumeration completed.
2023-01-14T15:58:48.946576277Z Registering new address record for 172.17.0.16 on eth0.IPv4.
2023-01-14T15:58:48.946800358Z Registering new address record for 127.0.0.1 on lo.IPv4.
2023-01-14T15:58:48.949133675Z 2023-01-14 15-58-48.948 [Info] (PcmStream) PcmStream: Default, sampleFormat: 48000:16:2
2023-01-14T15:58:48.949241096Z 2023-01-14 15-58-48.949 [Info] (PipeStream) PipeStream mode: create
2023-01-14T15:58:48.949255753Z 2023-01-14 15-58-48.949 [Info] (Server) Stream: {"fragment":"","host":"","path":"/tmp/snapfifo","query":{"chunk_ms":"20","codec":"pcm","name":"Default","sampleformat":"48000:16:2"},"raw":"pipe:////tmp/snapfifo?chunk_ms=20&codec=flac&name=Default&sampleformat=48000:16:2","scheme":"pipe"}
2023-01-14T15:58:48.949308012Z 2023-01-14 15-58-48.949 [Info] (FlacEnc) Init - compression level: 2
2023-01-14T15:58:48.954838227Z 2023-01-14 15-58-48.954 [Error] (PosixStream) Exception: end of file
2023-01-14T15:58:48.954872501Z 2023-01-14 15-58-48.954 [Info] (ControlServer) Creating TCP acceptor for address: 0.0.0.0, port: 1705
2023-01-14T15:58:48.954878993Z 2023-01-14 15-58-48.954 [Info] (ControlServer) Creating HTTP acceptor for address: 0.0.0.0, port: 1780
2023-01-14T15:58:48.954892769Z 2023-01-14 15-58-48.954 [Info] (StreamServer) Creating stream acceptor for address: 0.0.0.0, port: 1704
2023-01-14T15:58:48.954899241Z 2023-01-14 15-58-48.954 [Info] (Snapserver) Number of threads: 4, hw threads: 28
2023-01-14T15:58:49.649103554Z 2023-01-14 15-58-49.648 [Notice] (StreamServer) StreamServer::NewConnection: 172.16.2.65
2023-01-14T15:58:49.652079368Z 2023-01-14 15-58-49.651 [Info] (Server) Hello from f0:2f:74:c3:74:0e, host: lumi, v0.26.0, ClientName: Snapclient, OS: Debian GNU/Linux 10 (buster), Arch: x86_64, Protocol version: 2
2023-01-14T15:58:49.706006092Z 2023-01-14 15-58-49.705 [Notice] (StreamServer) StreamServer::NewConnection: 172.16.2.41
2023-01-14T15:58:49.707305744Z 2023-01-14 15-58-49.707 [Notice] (ControlServer) ControlServer::NewConnection: 172.16.2.2
2023-01-14T15:58:49.719282225Z 2023-01-14 15-58-49.718 [Info] (Server) Hello from b8:27:eb:f8:28:ee, host: pihole, v0.26.0, ClientName: Snapclient, OS: Debian GNU/Linux 10 (buster), Arch: armv7l, Protocol version: 2
2023-01-14T15:58:49.878222979Z Server startup complete. Host name is f11c42685605.local. Local service cookie is 2827771526.
2023-01-14T15:58:49.960659100Z 2023-01-14 15-58-49.960 [Info] (Avahi) Adding service 'Snapcast'
2023-01-14T15:58:50.205607238Z 2023-01-14 15-58-50.205 [Notice] (ControlServer) ControlServer::NewConnection: 172.16.2.10
2023-01-14T15:58:50.809691646Z Service "f11c42685605" (/etc/avahi/services/ssh.service) successfully established.
2023-01-14T15:58:50.809752340Z Service "f11c42685605" (/etc/avahi/services/sftp-ssh.service) successfully established.
2023-01-14T15:58:50.981385220Z 2023-01-14 15-58-50.981 [Info] (Avahi) Service 'Snapcast' successfully established.
2023-01-14T15:58:52.671918284Z 2023-01-14 15-58-52.671 [Notice] (StreamServer) StreamServer::NewConnection: 172.16.2.2
2023-01-14T15:58:52.673167351Z 2023-01-14 15-58-52.673 [Info] (Server) Hello from d8:5e:d3:0d:f9:24#5, host: zardoz, v0.26.0, ClientName: Snapclient, OS: Windows 8, Arch: amd64, Protocol version: 2
2023-01-14T15:58:52.674988545Z 2023-01-14 15-58-52.674 [Info] (ControlServer) Removing 1 inactive session(s), active sessions: 2
2023-01-14T16:02:06.281871507Z 2023-01-14 16-02-06.280 [Info] (PcmStream) State changed: Default, state: idle => playing
2023-01-14T16:02:06.281944278Z 2023-01-14 16-02-06.280 [Info] (Server) onStateChanged (Default): playing
2023-01-14T16:02:08.364645079Z 2023-01-14 16-02-08.364 [Info] (PcmStream) State changed: Default, state: playing => idle
2023-01-14T16:02:08.364728611Z 2023-01-14 16-02-08.364 [Info] (Server) onStateChanged (Default): idle

mape avatar Jan 14 '23 16:01 mape

It works as expected if I use snd-aloop together with stream = alsa://?name=Default&device=hw:0,0

And then run ffmpeg -y -i test.wav -f wav -ar 48000 -sample_fmt s16 -ac 2 - | aplay -D hw:0,1,0

mape avatar Jan 14 '23 18:01 mape

This also happens when using tcp streams.

SantiagoSotoC avatar Dec 11 '23 21:12 SantiagoSotoC

Please try again with the latest version v0.28.0-beta.1

badaix avatar Apr 02 '24 08:04 badaix