mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #528] Loud ticks/clicks when selecting other songs #339
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#339
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @basmeyer on GitHub (Oct 3, 2020).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/528
Hi, I have been directed to you regarding problems with the moOde player.
It is about very audible ticks of clicks and they appear when one song is playing and another is selected in Spotify.
Equipment: Raspberry Pi 4B with HiFBerry DAC+ Pro XLR add-on board.
Software: moOde Player 6.7.1 2020-07-22, but also in previous 6.4.0 2019-11-24.
The loudness of the ticks follow the volume set in the player and are regardless of hardware or software volume control.
System information below. Please let me know if I could provide more information. Thanks!
`
S Y S T E M P A R A M E T E R S
moOde release = 6.7.1 2020-07-22
RaspiOS = 10.4
Linux kernel = 5.4.51-v8+ #1325
Platform = Pi-4B 4GB v1.1
Architecture = aarch64 (64-bit)
System uptime = up 16 hours, 26 minutes
Timezone = Europe/Amsterdam
Current time = 2020-10-03 18:36:15
Host name = moode
Ethernet address = 192.168.1.13
Ethernet MAC = dc:a6:32:61:3c:2c
WLAN address = unassigned
WLAN MAC = dc:a6:32:61:3c:2e
WLAN country = US
SoC identifier = bcm2711
Core count = 4
Kernel timer freq = 250 Hz
SDCard freq = 50 MHz
USB boot = not available
Warranty = OK
Root size = 3.4G
Root used = 80%
Root available = 674M
Root expand = not expanded
Memory free = 3504 MB
Memory used = 88 MB
SoC temperature = 46.7°C
CPU governor = ondemand
Onboard WiFi = On
Onboard BT = On
HDMI output = Off
LED state = 1,1
Eth addr wait = On
Max USB current = Off
USB (UAC2) fix = Off
Pi-3B+ eth fix = Off
SSH term server = Off
PHP-FPM version = 7.3.14
NGINX version = 1.14.2
SQLite3 version = 3.27.2
Hostapd version = 2.8-devel
WiringPi version = 2.50
RPi.GPIO version = 0.7.0
A U D I O P A R A M E T E R S
Audio device = HiFiBerry DAC+ Pro
Interface = I2S
Mixer name = Digital
Hardware volume = Controller detected
Max ALSA volume = 100
Max MPD volume = 100
Volume step limit = 10
Audio source = Local
Output device = Local
Resume MPD = No
Volume knob = 0
Volume mute = Unmuted
Saved MPD vol = 0
Preamp volume = 0
ALSA version = 1.1.8-1+rpt1
SoX version = 0.1.2-3
Bluetooth controller = Off
Pairing agent = Off
Airplay receiver = Off
Spotify receiver = On
Squeezelite = Off
UPnP client = Off
DLNA server = Off
GPIO button handler = Off
UPnP browser = Off
Auto-shuffle = Off
Autoplay = Off
Rotary encoder = Off
Encoder params = 100 2 3 23 24
USB volume knob = Off
Polarity inversion = Off
Crossfeed = Off
Crossfade = Off
Parametric EQ = Off
Graphic EQ = Off
MPD httpd = Off
A P P E A R A N C E S E T T I N G S
Themes and backgrounds
Theme = Default
Accent color = Emerald
Alpha blend = 1.0
Adaptive background = No
Background image = No
Cover backdrop = No
Cover blur = 20px
Cover scale = 1.25
Library options
Instant play action = Add/Play
Show tagview genres = Yes
Show tagview covers = Yes
Show sample rate = No
Ellipsis limited text = No
Thumbnail columns = 6/2 (Default)
Albumview sort order = by Artist
Tagview sort order = by Artist
Compilation identifier = Various Artists
Recently added = 1 Month
Ignore articles = a,an,the
UTF8 character filter = No
Hi-res thumbs = Auto
Cover search pri = Embedded cover
Pixel ratio = 2
Coverview screen saver
CoverView auto-display = Never
CoverView style = Gradient (Linear)
Other options
Font size = Normal
Auto-shuffle filter = None
Extra metadata = track,disc,date,composer,encoded
Playback history = No
First use help = y,y
M P D S E T T I N G S
Version = 0.21.24
Volume control = hardware
ALSA device = hw:0
SoX resampling = disabled
SoX quality = very high
SoX multithreading = off
DSD over PCM (DoP) = no
Replaygain = off
Replaygain preamp = 0
Volume normalization = No
Audio buffer = 8192 (kb)
Output buffer size = 131072 (kb)
B L U E T O O T H S E T T I N G S
Bluetooth ver = 5.50
Bluealsa ver = v2.1.0
Speaker sharing = No
Resume MPD = No
PCM buffer time = 500000 (µs)
A I R P L A Y S E T T I N G S
Version = 3.3.6
Friendly name = moOde Airplay
ALSA device = hw:0
Interpolation = soxr
Output bit depth = S16
Output sample rate = 44100
Session interruption = no
Session timeout = 120 (ms)
Latency offset = 0.0 (secs)
Audio buffer = 0.2 (secs)
Resume MPD = No
S P O T I F Y S E T T I N G S
Friendly name = moOde Spotify
ALSA device = plughw:0
Bit rate = 320
Initial volume = 0
Volume curve = Logarithmic
Volume normalization = No
Normalization pregain = 0
Autoplay = No
Resume MPD = No
S Q U E E Z E L I T E S E T T I N G S
Version = 1.8.7-1052 "DSD/SRC enabled"
Friendly name = Moode
ALSA device = hw:0
ALSA params = 80:4::1
Output buffers = 40000:100000
Task priority = 45
Codec list = flac,pcm,mp3,ogg,aac,alac,dsd
Other options = -W -D 500 -R E -S /var/local
Resume MPD = No
L O C A L D I S P L A Y S E T T I N G S
Local UI display = Off
Mouse cursor = On
Screen blank = 600 Secs
Wake display on play = Off
Brightness = 255
Pixel aspect ratio = Default
Rotate screen = 0 Deg
M O O D E S T A R T U P L O G
20201003 020939 worker: -- Start
20201003 020939 worker: Successfully daemonized
20201003 020939 worker: Integrity check (passed)
20201003 020939 worker: Session loaded
20201003 020939 worker: Debug logging (off)
20201003 020939 worker: Device raw: (0:sndrpihifiberry|1:empty|2:empty|3:empty
20201003 020939 worker: Device i2s: (HiFiBerry DAC+ Pro)
20201003 020939 worker: Device mpd: (0:HiFiBerry DAC+ Pro)
20201003 020939 worker: Device ses: (0|HiFiBerry DAC+ Pro|Digital|0%)
20201003 020939 worker: ALSA Digital volume set to (0%)
20201003 020939 worker: -- System
20201003 020940 worker: Host (moode)
20201003 020941 worker: moOde (6.7.1 2020-07-22)
20201003 020941 worker: RaspiOS (10.4)
20201003 020941 worker: Kernel (5.4.51-v8+ #1325)
20201003 020941 worker: Platform (Pi-4B 4GB v1.1)
20201003 020941 worker: ARM arch (aarch64, 64-bit kernel)
20201003 020941 worker: MPD ver (0.21.24)
20201003 020941 worker: CPU gov (ondemand)
20201003 020941 worker: USB boot not available
20201003 020941 worker: File system not expanded yet
20201003 020941 worker: HDMI port off
20201003 020941 worker: File check (OK)
20201003 020941 worker: -- Network
20201003 020941 worker: eth0 exists
20201003 020941 worker: IP addr (192.168.1.13)
20201003 020941 worker: Netmask (255.255.255.0)
20201003 020941 worker: Gateway (192.168.1.1)
20201003 020941 worker: Pri DNS (192.168.1.1)
20201003 020941 worker: Domain (blueeaglevision)
20201003 020941 worker: wlan0 exists
20201003 020941 worker: wifi country (US)
20201003 020941 worker: wlan0 SSID is blank
20201003 020941 worker: eth0 addr exists, AP mode not started
20201003 020941 worker: wlan0 address not assigned
20201003 020941 worker: -- Audio
20201003 020942 worker: MPD conf updated
20201003 020942 worker: ALSA outputs unmuted
20201003 020942 worker: ALSA card number (0)
20201003 020942 worker: Audio output (HiFiBerry DAC+ Pro)
20201003 020942 worker: Audio formats (S16_LE, S24_LE, S32_LE)
20201003 020942 worker: ALSA mixer name (Digital)
20201003 020942 worker: MPD volume control (hardware)
20201003 020942 worker: Hdwr volume controller exists
20201003 020942 worker: Max ALSA volume (100%)
20201003 020942 worker: Reset renderer active flags
20201003 020942 worker: -- MPD
20201003 020942 worker: MPD started
20201003 020943 worker: MPD accepting connections
20201003 020943 worker: Configure MPD outputs
20201003 020943 worker: MPD output 1 ALSA default (on)
20201003 020943 worker: MPD output 2 ALSA crossfeed (off)
20201003 020943 worker: MPD output 3 ALSA parametric eq (off)
20201003 020943 worker: MPD output 4 ALSA graphic eq (off)
20201003 020943 worker: MPD output 5 ALSA polarity inversion (off)
20201003 020943 worker: MPD output 6 ALSA bluetooth (off)
20201003 020943 worker: MPD output 7 HTTP stream (off)
20201003 020943 worker: MPD crossfade (off)
20201003 020943 worker: -- Feature availability
20201003 020943 worker: Source select (available)
20201003 020943 worker: Source select (source: MPD)
20201003 020943 worker: Source select (output: HiFiBerry DAC+ Pro)
20201003 020943 worker: Bluetooth (available)
20201003 020943 worker: Airplay renderer (available)
20201003 020943 worker: Spotify renderer (available)
20201003 020943 worker: Spotify renderer (started)
20201003 020943 worker: Squeezelite renderer (available)
20201003 020943 worker: UPnP renderer (available)
20201003 020943 worker: DLNA server (available)
20201003 020943 worker: UPnP browser (available)
20201003 020943 worker: Audio scrobbler (available)
20201003 020943 worker: GPIO button handler (available)
20201003 020943 worker: -- Music sources
20201003 020943 worker: USB sources (none attached)
20201003 020943 worker: NAS and UPnP sources (none configured)
20201003 020943 worker: -- Miscellaneous
20201003 020943 worker: USB volume knob (Off)
20201003 020943 worker: USB auto-mounter (udisks-glue)
20201003 020943 worker: LED0 (On)
20201003 020943 worker: LED1 (On)
20201003 020943 worker: Saved MPD vol level (0)
20201003 020943 worker: Preamp volume level (0)
20201003 020943 worker: MPD volume level (0) restored
20201003 020943 worker: ALSA Digital volume (0%)
20201003 020943 worker: Auto-play (Off)
20201003 020943 worker: Maintenance interval (3 hrs)
20201003 020943 worker: Screen saver activation (Never)
20201003 020943 worker: Session permissions (OK)
20201003 020943 worker: Watchdog started
20201003 020943 worker: Ready
20201003 172513 worker: Job airplaysvc
20201003 172529 worker: Job btsvc
20201003 172547 worker: Job upnpsvc
20201003 172556 worker: Job minidlna
`
@JasonLG1979 commented on GitHub (Oct 6, 2020):
Sounds like buffer underruns.
While playing Spotify what is the output of
cat /proc/asound/card*/pcm*p/sub*/hw_params?@basmeyer commented on GitHub (Oct 7, 2020):
Hi Jason,
Thanks for looking into this.
The output is, and stays:
pi@moode:/proc/asound/card0/pcm0p/sub0 $ !!
cat /proc/asound/card0/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (352800/8)
period_size: 225
buffer_size: 22050
Regards,
Bas Meijer
@basmeyer commented on GitHub (Oct 7, 2020):
Hi Jason,
Thanks for looking into this.
The output is, and stays:
pi@moode:/proc/asound/card0/pcm0p/sub0 $ !!
cat /proc/asound/card0/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (352800/8)
period_size: 225
buffer_size: 22050
In addition, when I compare with HiFiBerryOS, this is then the output, which looks similar to me:
cat hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (352800/8)
period_size: 225
buffer_size: 22050
Regards,
Bas Meijer
@JasonLG1979 commented on GitHub (Oct 7, 2020):
That's what I thought. That period size is WAY to small. That translates to 196 CPU interrupts per second. For about a 0.5 sec buffer a much more reasonable buffer setting would be a buffer size of 22052 and a period size of 5513. That would translate to about 8 CPU interrupts per second. Which is what the current git master pretty much uses from what I remember.
Basically what's happening is that with everything that's going on the CPU gets hammered and can't keep up.
I would advice both Moode Audio and HiFiBerryOS to rebuild librespot against the current git master. If that doesn't help they can create a new pcm device in asound.conf specifically for librespot and manually set their own buffer parmas.
@basmeyer commented on GitHub (Oct 7, 2020):
Thank you for your help, this sounds like a very obvious cause of the clicks/spikes when starting new tracks!
I will forward this to Moode. As far as HiFiBerryOS I did not experience this problem (yet).
Not sure but perhaps this could also explain the “buggy” behavior using Spotify Connect with both (!) systems regarding the volume levels when switching sources, so like from another music source to Spotify.
Thanks again.
@JasonLG1979 commented on GitHub (Oct 7, 2020):
I ran into the same issue using raspotify on a pi zero. I upped the buffer to 1 sec and 0.25 sec period time by overriding default in asound.conf and it worked wonders. The Pi4 is exponentially more powerful then a zero so 0.5 secs should be fine.
@JasonLG1979 commented on GitHub (Oct 7, 2020):
Well there could be several reasons for that depending on how volume is configured in librespot and the main volume setting in Moode Audio and HiFiBerryOS.
Your best bet is to just set volume to 100% everywhere and use the volume on whatever's downstream from your pi, a receiver or amp or whatever.
@basmeyer commented on GitHub (Oct 7, 2020):
That is really hopeful. I was eager to try it our myself, but I have not manage to locate the file/folder asound.conf than you mentioned.
We are talking Moode right?
I did had a look at the files in the /proc/asound folder but it does not make sense to me what to edit and to not recognise the current values there.
Tried lots of things and searched the whole remote location.
Thanks for your help.
@JasonLG1979 commented on GitHub (Oct 7, 2020):
It's
/etc/asound.confunless created it does not exist. It's an override config file.https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#Configuration
I would not change it if it exists already on an "Audiophile" Linux distro like Moode or HiFiBerryOS. I'm not sure how they handle the file but I know on Volumio they have scripts that generate/write to that file. If you change it you can break your system and/or anything you change can just get overwritten.
@JasonLG1979 commented on GitHub (Oct 7, 2020):
Another problem or at least inconsistency is that in every "Audiophile" distro I've tried no matter what you set the sample rate and bit depth and buffer settings in the main settings librespot always uses it's default settings. (16 bit 44.1 kHz and the above mentioned buffer sizes) Now granted that upsampling has absolutely zero benefit on modern DACs (they oversample internally anyway) and upping the bit depth is really only useful for improving the quality of software volume control, buffer settings are useful and, like I said for consistency's sake they should be in harmony.
It's very easily possible to make all the setting match with a custom pcm definition in
/etc/asound.conf.Something like this:
With the above all that has to be overwritten is the defaults and the slave.pcm definition in pcm.spotify when any of the main audio settings are changed and then they would just have to tell librespot to use the custom "spotify" pcm with
--device spotify.@JasonLG1979 commented on GitHub (Oct 7, 2020):
hqstereo20is more or less a function.@basmeyer commented on GitHub (Oct 9, 2020):
Thanks Jason,
I contacted Moode and see what they (Tim Curtis) come up with.
I offered to do some testing with my current gear but the asked for a ready made asound.conf where I can only fill in the necessary params to moderate the period_size and buffer_size.
My C-skill are to outdated to seriously make a working asound.conf
It is not posible to permanently demolish the Moode system but I constantly end up with Spotify Connect that stops working to output to Moode once I press start or raise the volume from 0. ;)
I handed out your code and all necessary information around have them update the librespot use by Moode.
I still wonder why HiFiBerryOS does not give glitches with the similar output of hw_params but that could possibly have to do with other system things that will have its effect on CPU load.
Regards, Bas
@JasonLG1979 commented on GitHub (Oct 10, 2020):
It's not C it's a plain text file.
@JasonLG1979 commented on GitHub (Oct 10, 2020):
When I say that
hqstereo20is like a function I mean that you can pass arguments to it like a function if you want to by editing the string in quotes afterslave.pcm. It's not actually a real function.@JasonLG1979 commented on GitHub (Oct 10, 2020):
I don't know but I do know that HiFiBerryOS is not a Raspberry Pi/Debian based system. It's built with buildroot last I checked.
@JasonLG1979 commented on GitHub (Oct 10, 2020):
I jumped in on your moodeaudio forum thread.