Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Intermittent loud ticks and no-audio using Spotify
#1
Hi,

I wonder what the cause could be that Spotify Connect creates loud speaker-killing ticks/pops/clicks now and then when selecting another song.

Other problems, but perhaps related (ALSA mixer controlling problem?), occur when switching between Airplay and Spotify Connect modes. When switching between those playing modes strange unpredictable states introduce, when no audio comes through or only when the volume is set way up high.
A workaround that sometimes seems to prevent this from happing, but not permanently, is to switch back to play on the device (iPhone/iPad) itself and then to the other desired mode.
If I change the MDP Config > Audio Device > Volume Control setting into Software I have the idea that I get slightly better results, but not satisfying either. In that case the ticking is still there. Switching from Spotify Connect mode to Airplay audio is now possible, but not backwards, then no audio. I noticed that after doing that, Airplay is still on (selected), which should not be as Spotify Connect is not Airplay. Sometimes I have to pause/play to hear music although it is still running (not minding that, just some more info).

If I then try the workaround trick to play over the device and then to Spotify Connect I sometimes heard nothing for 2 seconds, then a loud tick, then music.

I have no experience with other DAC boards on the Raspberry Pi, but the one that we have here is: HiFiBerry DAC+ Pro XLR

I am a professional sound engineer. Please feel free to ask questions to more reproduce the problem or if I need to go through some settings. I already tried a few but no change. I would like to attach one of those sexy System Parameter reports but I do not know how to produce one. Thanks for letting me know.
Reply
#2
(01-16-2020, 02:19 PM)basmeye Wrote: I would like to attach one of those sexy System Parameter reports but I do not know how to produce one. Thanks for letting me know.

Go to the System Config page and you can then get the System info from the menu at top right. Highlight that and drag it into the reply box. (Well, that's what works for me...) Done!
Reply
#3
Thanks, @jonners
I overlooked this because it is a bit illogical to look at that M menu again once you are already in it, to find more/other menu options to go to.
Well, this is it:

S Y S T E M   P A R A M E T E R S

moOde release = 6.4.0 2019-11-24
Raspbian OS = 10.2
Linux kernel = 4.19.83-v7l+ #1277
Platform = Pi-4B 4GB
Architecture = armv7l (32-bit)
System uptime = up 23 hours, 48 minutes
Timezone = Europe/Amsterdam
Current time = 2020-01-16 16:08:57

Host name = moode
Ethernet address = 192.168.1.13
Ethernet MAC = dc:a6:32:61:3c:2c
WLAN address = 192.168.1.14
WLAN MAC = dc:a6:32:61:3c:2e
WLAN country = NL

SoC identifier = bcm2711
Core count = 4
Kernel timer freq = 100 Hz
SDCard freq = 50 MHz
USB boot = not available
Warranty = OK

Root size = 3.4G
Root used = 80%
Root available = 680M
Root expand = not expanded
Memory free = 3454 MB
Memory used = 157 MB
SoC temperature = 47.2°C

CPU governor = ondemand
Onboard WiFi = On
Onboard BT = On
HDMI output = Off
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.11
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
Audio source = Local
Output device = Local
Resume MPD = No
Volume knob = 21
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 = On
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
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

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
CoverView auto-display = Never
CoverView style = Animated
Auto-shuffle filter = None
Extra metadata = Yes
Playback history = No

L I B R A R Y   S E T T I N G S

Instant play action = Clear/Play
Show genres column = Yes
Album grouping = 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 = Cover image file
Pixel ratio = 2

M P D   S E T T I N G S

Version = 0.21.16
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 = 4096 (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 = 2.0.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.5
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 = 20
Volume curve = Logarithmic
Volume normalization = No
Normalization pregain = 0
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

20200115 143430 worker: -- Start
20200115 143430 worker: Successfully daemonized
20200115 143430 worker: Integrity check (passed)
20200115 143430 worker: Session loaded
20200115 143430 worker: Debug logging (off)
20200115 143430 worker: Device raw: Card0 (sndrpihifiberry) | Card1 () | I2Sdev (HiFiBerry DAC+ Pro)
20200115 143430 worker: Device cfg: Name (HiFiBerry DAC+ Pro) | Card (0) | MPDdev (0) | Mixer (Digital) | Alsavol: (0)
20200115 143430 worker: ALSA volume set to (0%)
20200115 143430 worker: -- System
20200115 143432 worker: Host name     (moode)
20200115 143432 worker: moOde release (6.4.0 2019-11-24)
20200115 143432 worker: Raspbian OS   (10.2)
20200115 143432 worker: Linux kernel  (4.19.83-v7l+ #1277)
20200115 143432 worker: Platform      (Pi-4B 4GB)
20200115 143432 worker: Architecture  (armv7l)
20200115 143432 worker: MPD version   (0.21.16)
20200115 143432 worker: CPU governor  (ondemand)
20200115 143432 worker: USB boot not available
20200115 143432 worker: File system not expanded yet
20200115 143432 worker: HDMI port off
20200115 143432 worker: File check (OK)
20200115 143432 worker: -- Network
20200115 143432 worker: eth0 exists
20200115 143432 worker: IP addr (192.168.1.13)
20200115 143432 worker: Netmask (255.255.255.0)
20200115 143433 worker: Gateway (192.168.1.1)
20200115 143433 worker: Pri DNS (192.168.1.1)
20200115 143433 worker: Domain  (blueeaglevision)
20200115 143433 worker: wlan0 exists
20200115 143433 worker: wifi country (NL)
20200115 143433 worker: wlan0 trying SSID (Blue Eagle)
20200115 143433 worker: IP addr (192.168.1.14)
20200115 143433 worker: Netmask (255.255.255.0)
20200115 143433 worker: Gateway (192.168.1.1)
20200115 143433 worker: Pri DNS (192.168.1.1)
20200115 143433 worker: Domain  (blueeaglevision)
20200115 143433 worker: -- Audio
20200115 143434 worker: ALSA outputs unmuted
20200115 143434 worker: ALSA card number (0)
20200115 143434 worker: Audio output (I2S audio device)
20200115 143434 worker: Audio device (HiFiBerry DAC+ Pro)
20200115 143434 worker: Audio formats (S16_LE, S24_LE, S32_LE)
20200115 143434 worker: ALSA mixer name (Digital)
20200115 143434 worker: MPD volume control (hardware)
20200115 143434 worker: Hdwr volume controller exists
20200115 143434 worker: Max ALSA volume (100%)
20200115 143434 worker: -- Services
20200115 143434 worker: Reset renderer active state
20200115 143435 worker: MPD conf updated
20200115 143435 worker: MPD started
20200115 143435 worker: MPD accepting connections
20200115 143435 worker: Configure MPD outputs
20200115 143435 worker: MPD output 1 ALSA default (on)
20200115 143435 worker: MPD output 2 ALSA crossfeed (off)
20200115 143435 worker: MPD output 3 ALSA parametric eq (off)
20200115 143435 worker: MPD output 4 ALSA graphic eq (off)
20200115 143435 worker: MPD output 5 ALSA polarity inversion (off)
20200115 143435 worker: MPD output 6 ALSA bluetooth (off)
20200115 143435 worker: MPD output 7 HTTP stream (off)
20200115 143435 worker: MPD crossfade (off)
20200115 143435 worker: Audio source (Local)
20200115 143435 worker: Output device (Local)
20200115 143435 worker: Airplay receiver started
20200115 143435 worker: Spotify receiver started
20200115 143435 worker: USB auto-mounter (udisks-glue)
20200115 143435 worker: -- Music sources
20200115 143435 worker: USB sources (none attached)
20200115 143436 worker: NAS and UPnP sources (mountall initiated)
20200115 143436 worker: -- Miscellaneous
20200115 143436 worker: Saved MPD vol level (0)
20200115 143436 worker: Preamp volume level (0)
20200115 143436 worker: MPD volume level (13) restored
20200115 143436 worker: ALSA volume level (49%)
20200115 143436 worker: Auto-play (Off)
20200115 143436 worker: Maintenance interval (6 hrs)
20200115 143436 worker: Screen saver activation (Never)
20200115 143436 worker: Session permissions (OK)
20200115 143436 worker: Watchdog started
20200115 143436 worker: Ready
20200115 143437 watchdog: INFO Audio output is (closed)
20200115 162849 watchdog: INFO Audio output is (in use)
20200115 163003 watchdog: INFO Audio output is (closed)
20200115 163357 watchdog: INFO Audio output is (in use)
20200115 164652 watchdog: INFO Audio output is (closed)
20200115 164717 watchdog: INFO Audio output is (in use)
20200115 164754 watchdog: INFO Audio output is (in use)
20200115 164831 watchdog: INFO Audio output is (closed)
20200115 165046 watchdog: INFO Audio output is (in use)
20200115 165200 watchdog: INFO Audio output is (closed)
20200115 165213 watchdog: INFO Audio output is (in use)
20200115 165329 worker: Job airplaysvc
20200115 165333 watchdog: INFO Audio output is (closed)
20200115 165639 worker: Job setlogoimage
20200115 165656 watchdog: INFO Audio output is (in use)
20200115 165720 watchdog: INFO Audio output is (closed)
20200115 165804 watchdog: INFO Audio output is (in use)
20200115 170025 watchdog: INFO Audio output is (closed)
20200115 170500 worker: Job setlogoimage
20200115 170514 watchdog: INFO Audio output is (in use)
20200115 170521 watchdog: INFO Audio output is (closed)
20200115 170551 watchdog: INFO Audio output is (in use)
20200115 170628 watchdog: INFO Audio output is (closed)
20200115 170718 watchdog: INFO Audio output is (in use)
20200115 170748 watchdog: INFO Audio output is (closed)
20200115 170908 watchdog: INFO Audio output is (in use)
20200115 170927 watchdog: INFO Audio output is (closed)
20200115 171256 watchdog: INFO Audio output is (in use)
20200115 171511 worker: Job airplaysvc
20200115 171512 watchdog: INFO Audio output is (closed)
20200115 172023 worker: Job setlogoimage
20200115 172044 watchdog: INFO Audio output is (in use)
20200115 172223 watchdog: INFO Audio output is (closed)
20200115 172407 watchdog: INFO Audio output is (in use)
20200115 172451 watchdog: INFO Audio output is (closed)
20200115 172509 watchdog: INFO Audio output is (in use)
20200115 172826 watchdog: INFO Audio output is (closed)
20200115 172832 watchdog: INFO Audio output is (in use)
20200115 172915 watchdog: INFO Audio output is (closed)
20200115 172928 watchdog: INFO Audio output is (in use)
20200115 173011 watchdog: INFO Audio output is (closed)
20200115 173112 watchdog: INFO Audio output is (in use)
20200115 173118 watchdog: INFO Audio output is (closed)
20200115 173149 watchdog: INFO Audio output is (in use)
20200115 173722 watchdog: INFO Audio output is (in use)
20200115 173746 watchdog: INFO Audio output is (closed)
20200115 175055 worker: Job setlogoimage
20200115 175113 watchdog: INFO Audio output is (in use)
20200115 175150 watchdog: INFO Audio output is (closed)
20200115 175221 watchdog: INFO Audio output is (in use)
20200115 175239 watchdog: INFO Audio output is (closed)
20200115 175329 watchdog: INFO Audio output is (in use)
20200115 175640 worker: Job airplaysvc
20200115 175646 watchdog: INFO Audio output is (closed)
20200115 175652 watchdog: INFO Audio output is (in use)
20200115 175741 watchdog: INFO Audio output is (in use)
20200115 180338 watchdog: INFO Audio output is (in use)
20200115 181000 watchdog: INFO Audio output is (closed)
20200115 181006 watchdog: INFO Audio output is (in use)
20200115 185628 watchdog: INFO Audio output is (closed)
20200115 185635 watchdog: INFO Audio output is (in use)
20200115 191019 watchdog: INFO Audio output is (closed)
20200115 191115 watchdog: INFO Audio output is (in use)
20200115 192404 watchdog: INFO Audio output is (closed)
20200115 222114 worker: Maintenance completed
20200116 042136 worker: Maintenance completed
20200116 102158 worker: Maintenance completed
20200116 131840 watchdog: INFO Audio output is (in use)
20200116 132107 watchdog: INFO Audio output is (in use)
20200116 132156 watchdog: INFO Audio output is (closed)
20200116 132209 watchdog: INFO Audio output is (in use)
20200116 132341 watchdog: INFO Audio output is (closed)
20200116 132354 watchdog: INFO Audio output is (in use)
20200116 132400 watchdog: INFO Audio output is (in use)
20200116 132437 watchdog: INFO Audio output is (closed)
20200116 132455 watchdog: INFO Audio output is (in use)
20200116 132544 watchdog: INFO Audio output is (closed)
20200116 132557 watchdog: INFO Audio output is (in use)
20200116 132621 watchdog: INFO Audio output is (in use)
20200116 132640 watchdog: INFO Audio output is (in use)
20200116 132723 watchdog: INFO Audio output is (in use)
20200116 132729 watchdog: INFO Audio output is (in use)
20200116 132748 watchdog: INFO Audio output is (closed)
20200116 132824 watchdog: INFO Audio output is (in use)
20200116 132831 watchdog: INFO Audio output is (in use)
20200116 132843 watchdog: INFO Audio output is (closed)
20200116 132914 watchdog: INFO Audio output is (in use)
20200116 132932 watchdog: INFO Audio output is (closed)
20200116 132944 watchdog: INFO Audio output is (in use)
20200116 133129 watchdog: INFO Audio output is (closed)
20200116 133142 watchdog: INFO Audio output is (in use)
20200116 133243 watchdog: INFO Audio output is (closed)
20200116 133249 watchdog: INFO Audio output is (in use)
20200116 133345 watchdog: INFO Audio output is (in use)
20200116 133453 watchdog: INFO Audio output is (closed)
20200116 133511 watchdog: INFO Audio output is (in use)
20200116 133548 watchdog: INFO Audio output is (closed)
20200116 133619 watchdog: INFO Audio output is (in use)
20200116 133631 watchdog: INFO Audio output is (closed)
20200116 133637 watchdog: INFO Audio output is (in use)
20200116 133643 watchdog: INFO Audio output is (closed)
20200116 133650 watchdog: INFO Audio output is (in use)
20200116 133841 watchdog: INFO Audio output is (in use)
20200116 133847 watchdog: INFO Audio output is (closed)
20200116 133853 watchdog: INFO Audio output is (in use)
20200116 133917 watchdog: INFO Audio output is (closed)
20200116 133924 watchdog: INFO Audio output is (in use)
20200116 133948 watchdog: INFO Audio output is (closed)
20200116 133954 watchdog: INFO Audio output is (in use)
20200116 134001 watchdog: INFO Audio output is (closed)
20200116 134007 watchdog: INFO Audio output is (in use)
20200116 134139 watchdog: INFO Audio output is (closed)
20200116 134158 watchdog: INFO Audio output is (in use)
20200116 134247 watchdog: INFO Audio output is (closed)
20200116 134253 watchdog: INFO Audio output is (in use)
20200116 134401 watchdog: INFO Audio output is (closed)
20200116 134407 watchdog: INFO Audio output is (in use)
20200116 135703 watchdog: INFO Audio output is (closed)
20200116 135709 watchdog: INFO Audio output is (in use)
20200116 135715 watchdog: INFO Audio output is (closed)
20200116 144141 worker: Job mpdcfg
20200116 144247 watchdog: INFO Audio output is (in use)
20200116 144537 worker: Job mpdcfg
20200116 144733 worker: Job mpdcfg
20200116 144831 worker: Job mpdcfg
20200116 144839 worker: Job mpdcfg
20200116 144913 worker: Job mpdcfg
20200116 145017 watchdog: INFO Audio output is (closed)
20200116 145023 watchdog: INFO Audio output is (in use)
20200116 145103 worker: Job mpdcfg
20200116 145113 worker: Job mpdcfg
20200116 145124 watchdog: INFO Audio output is (closed)
20200116 145137 watchdog: INFO Audio output is (in use)
20200116 145143 watchdog: INFO Audio output is (in use)
20200116 145309 watchdog: INFO Audio output is (closed)
20200116 145315 watchdog: INFO Audio output is (in use)
20200116 145340 watchdog: INFO Audio output is (closed)
20200116 145346 watchdog: INFO Audio output is (in use)
20200116 145358 watchdog: INFO Audio output is (in use)
20200116 145709 watchdog: INFO Audio output is (in use)
20200116 145715 watchdog: INFO Audio output is (in use)
20200116 145740 watchdog: INFO Audio output is (closed)
20200116 145906 watchdog: INFO Audio output is (in use)
20200116 150242 watchdog: INFO Audio output is (in use)
20200116 150516 watchdog: INFO Audio output is (closed)
20200116 150612 watchdog: INFO Audio output is (in use)
20200116 150624 watchdog: INFO Audio output is (in use)
20200116 150815 watchdog: INFO Audio output is (closed)
20200116 150821 watchdog: INFO Audio output is (in use)
20200116 150833 watchdog: INFO Audio output is (in use)
20200116 150858 watchdog: INFO Audio output is (in use)
20200116 150910 watchdog: INFO Audio output is (in use)
20200116 150935 worker: Job mpdcfg
20200116 151012 watchdog: INFO Audio output is (in use)
20200116 151037 watchdog: INFO Audio output is (in use)
20200116 151144 watchdog: INFO Audio output is (closed)
20200116 151151 watchdog: INFO Audio output is (in use)
20200116 151234 watchdog: INFO Audio output is (closed)
20200116 151240 watchdog: INFO Audio output is (in use)
20200116 151354 watchdog: INFO Audio output is (in use)
20200116 151508 watchdog: INFO Audio output is (closed)
20200116 151646 watchdog: INFO Audio output is (in use)
20200116 151717 watchdog: INFO Audio output is (in use)
20200116 151742 watchdog: INFO Audio output is (closed)
20200116 151748 watchdog: INFO Audio output is (in use)
20200116 152154 watchdog: INFO Audio output is (closed)
20200116 152219 watchdog: INFO Audio output is (in use)
20200116 152459 watchdog: INFO Audio output is (closed)
20200116 152512 watchdog: INFO Audio output is (in use)
20200116 152625 worker: Job spotifysvc
20200116 152626 watchdog: LIBRESPOT restarted (check syslog for errors)
20200116 152626 watchdog: INFO Audio output is (closed)
20200116 152709 watchdog: INFO Audio output is (in use)
20200116 152811 watchdog: INFO Audio output is (in use)
20200116 152817 watchdog: INFO Audio output is (in use)
20200116 152854 watchdog: INFO Audio output is (in use)
20200116 152912 watchdog: INFO Audio output is (in use)
Reply
#4
(01-16-2020, 02:19 PM)basmeyer Wrote: Hi,

I wonder what the cause could be that Spotify Connect creates loud speaker-killing ticks/pops/clicks now and then when selecting another song.

Other problems, but perhaps related (ALSA mixer controlling problem?), occur when switching between Airplay and Spotify Connect modes. When switching between those playing modes strange unpredictable states introduce, when no audio comes through or only when the volume is set way up high.
A workaround that sometimes seems to prevent this from happing, but not permanently, is to switch back to play on the device (iPhone/iPad) itself and then to the other desired mode.
If I change the MDP Config > Audio Device > Volume Control setting into Software I have the idea that I get slightly better results, but not satisfying either. In that case the ticking is still there. Switching from Spotify Connect mode to Airplay audio is now possible, but not backwards, then no audio. I noticed that after doing that, Airplay is still on (selected), which should not be as Spotify Connect is not Airplay. Sometimes I have to pause/play to hear music although it is still running (not minding that, just some more info).

If I then try the workaround trick to play over the device and then to Spotify Connect I sometimes heard nothing for 2 seconds, then a loud tick, then music.

I have no experience with other DAC boards on the Raspberry Pi, but the one that we have here is: HiFiBerry DAC+ Pro XLR

I am a professional sound engineer. Please feel free to ask questions to more reproduce the problem or if I need to go through some settings. I already tried a few but no change. I would like to attach one of those sexy System Parameter reports but I do not know how to produce one. Thanks for letting me know.

Try posting your issue in the librespot repo.
https://github.com/librespot-org/librespot
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
(01-17-2020, 01:10 AM)Tim Curtis Wrote: Try posting your issue in the librespot repo.
https://github.com/librespot-org/librespot

So I did in the "meantime" (almost sorry for taking the time)...  Wink

Also referring to the (at the time of writing this) unresolved topic what could be, but not necessarily, dealing with the same cause:
http://moodeaudio.org/forum/showthread.p...sound.conf

OK, so with release 6.7.1 2020-07-22 still glitches between tracks and when stopping tracks, especially with Spotify Connect.
I was hoping for a bit of improvement, updating from release 6.4.0, but this is not the case.
I even experience more problems with this release over 6.4.0 regarding an inconsistent audio volume levels when switching between radio stations and spotify with sometimes result in extreme loud volumes (probably maxed out) were suddenly the ALSA mixer goes bananas and make your rig sweat.

Regarding librespot I wrote with Jason Gray and he made me have a look at the output of /proc/asound/card*/pcm*p/sub*/hw_params so that is in my case  /proc/asound/card0/pcm0p/sub0/hw_params when Spotify was playing. That resulted in:

access: RW_INTERLEAVED

format: S16_LE
subformat: STD
channels: 2
rate: 44100 (352800/8)
period_size: 225
buffer_size: 22050

According to Jason the period_size is way (!)  too small, because that translates into 196 CPU interrupts per second. For 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.

He said this about it:

Quote:I would advice Moode Audio 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 params.

He also mentioned that, because with a beafy Pi 4 there is much more power at hand than a Pi zero, it is wise to have even a larger buffer like 1 sec and a 0.25 sec period time for the zero. He could replicate the problem on a zero easily he said.

My guess is, but because I cannot compare it is just a guess, that it could vary from soundcard to soundcard.
In my case I have only the HiFiBerry DAC+ Pro XLR to test.
And by the way, HiFiBerryOS does NOT produce these glitches, despite the same period_size and buffer_size output of hw_params.


It would be great to be able to do some temporary testing and create /etc/asound.conf with some values that would enlarger the period_size and buffer_size, would it be to much to ask to give me something to work with? I would be nice to have something to just fill in the necessary values. I am afraid my C-skills are not up to notch any more since I programmed with it for the last time in the early 90's.

Another thing that Jason mentioned was about consistency, and the importance about having harmony between buffer settings and sample rate + bit depth.
A suggestion for /etc/asound.conf to make all settings match was this piece of code:

Code:
###############################################################################

pcm.hqstereo20 {
   @args [
       SAMPLE_RATE FORMAT SAMPLE_RATE_CONVERTER
       BUFFER_PERIODS BUFFER_PERIOD_TIME
   ]
   # Sampling rate in Hz:
   # 44100, 48000, 88200, 96000...
   # Defaults to 44.1 kHz (CD Quality).
   @args.SAMPLE_RATE {
       type integer
       default 44100
   }
   # Format:
   # S16_LE, S24_LE, S24_3LE, S32_LE...
   # Defaults to S16_LE (CD Quality).
   @args.FORMAT {
       type string
       default S16_LE
   }
   # Resampling algorithm.
   # Defaults to samplerate_linear.
   @args.SAMPLE_RATE_CONVERTER {
       type string
       default samplerate_linear
   }
   # Periods per buffer.
   @args.BUFFER_PERIODS {
       type integer
       default 4
   }
   # Period size in time.
   # Defaults to 125ms (0.125 sec).
   # BUFFER_PERIODS * BUFFER_PERIOD_TIME = buffer time/size
   @args.BUFFER_PERIOD_TIME {
       type integer
       default 125000
   }
   type plug
   rate_converter $SAMPLE_RATE_CONVERTER
   slave {
       channels 2
       rate $SAMPLE_RATE
       format $FORMAT
       pcm {
           type dmix
           ipc_key 1024
           ipc_perm 0660
           ipc_gid audio
           slowptr true
           hw_ptr_alignment roundup
           slave {
               pcm {
                   type hw
                   card {
                       @func refer
                       name defaults.pcm.card
                   }
                   device {
                       @func refer
                       name defaults.pcm.device
                   }
                   subdevice {
                       @func refer
                       name defaults.pcm.subdevice
                   }
                   channels 2
                   rate $SAMPLE_RATE
                   format $FORMAT
               }
               channels 2
               period_size 0
               buffer_size 0
               buffer_time 0
               period_time $BUFFER_PERIOD_TIME
               periods $BUFFER_PERIODS
               rate $SAMPLE_RATE
               format $FORMAT
           }
           bindings {
               0 0
               1 1
           }
       }
   }
}

###############################################################################

# Change to the card number or name that you want to be the default control card.
# Default: 0
defaults.ctl.card 0

# Change to the card number or name that you want to be the default playback card.
# It should usually be the same as defaults.ctl.card.
# Default: 0
defaults.pcm.card 0

# Change to the device number that you want to be the default device on the default card.
# 0 or 1 is usually the correct device number.
# Default: 0
defaults.pcm.device 0

# Change to the subdevice number that you want to be the default subdevice on the default device.
# Should rarely need to be changed.
# Default: -1
defaults.pcm.subdevice -1

pcm.spotify {
   type plug
   # Optional args:
   # SAMPLE_RATE: default: 44100
   # FORMAT: default: S16_LE

   # SAMPLE_RATE_CONVERTER: default: samplerate_linear
   # SAMPLE_RATE_CONVERTER MAP:
   # low: samplerate_linear
   # medium: speexrate
   # High: speexrate_medium
   # Highest/Very High: speexrate_best

   # BUFFER_PERIODS: default: 4
   # BUFFER_PERIOD_TIME: default: 125000

   # Example:
   # 32 bit 96 kHz 1 sec buffer "high quality" sample rate conversion.
   "hqstereo20:SAMPLE_RATE=96000,FORMAT=S32_LE,SAMPLE_RATE_CONVERTER=speexrate_medium,BUFFER_PERIOD_TIME=250000"

   slave.pcm "hqstereo20"
}

###############################################################################

He also added:

Quote:With the above all that has to be overwritten is 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".

Hope this helps to improve Moode and have it glitch / spike / pop - free.
And of course look forward to be of any help regarding testing with a temporary asound.conf file.
Reply
#6
If other OS does not produce glitchy audio and ALSA version is same then maybe a different version of librespot is being used?
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
Actually to my surprise HiFiBerryOS is using https://github.com/Spotifyd/spotifyd
Thought it was Librespot too...
Reply
#8
Jason Gray here. If you have any questions or need any help testing things just point me to the relevant config files. Also I just noticed a typo in my asound.conf.

Code:
"hqstereo20:SAMPLE_RATE=96000,FORMAT=S32_LE,SAMPLE_RATE_CONVERTER=speexrate_medium,BUFFER_PERIOD_TIME=250000"

Should be commented out as it's just an example to show how the args work. My bad.


libasound2-plugins is also required to use speex software resampling.

Code:
sudo apt install -y --no-install-recommends libasound2-plugins
Reply
#9
You can also throw software volume control in the mix for cards that don't have hardware volume control. If you upped the bit depth (not to be confused with upsampling) to the max the card can handle you can give yourself like 48 dB of headroom before you have to start throwing away bit. This is superior to librespot's builtin software volume because gain reduction and volume control is done in 16 bit therefor it throws away bits.


Code:
###############################################################################

pcm.hqstereo20 {
   @args [
       SAMPLE_RATE FORMAT SAMPLE_RATE_CONVERTER
       BUFFER_PERIODS BUFFER_PERIOD_TIME VOL_MIN_DB
       VOL_MAX_DB VOL_RESOLUTION VOL_NAME
   ]
   # Sampling rate in Hz:
   # 44100, 48000, 88200, 96000...
   # Defaults to 44.1 kHz (CD Quality).
   @args.SAMPLE_RATE {
       type integer
       default 44100
   }
   # Format:
   # S16_LE, S24_LE, S24_3LE, S32_LE...
   # Defaults to S16_LE (CD Quality).
   @args.FORMAT {
       type string
       default S16_LE
   }
   # Resampling algorithm.
   # Defaults to samplerate_linear.
   @args.SAMPLE_RATE_CONVERTER {
       type string
       default samplerate_linear
   }
   # Periods per buffer.
   @args.BUFFER_PERIODS {
       type integer
       default 4
   }
   # Period size in time.
   # Defaults to 125ms (0.125 sec).
   # BUFFER_PERIODS * BUFFER_PERIOD_TIME = buffer time/size
   @args.BUFFER_PERIOD_TIME {
       type integer
       default 125000
   }
   # Minimal dB value of the software volume control.
   @args.VOL_MIN_DB {
       type real
       default -51.0
   }
   # Maximal dB value of the software volume control.
   @args.VOL_MAX_DB {
       type real
       default 0.0
   }
   # How many steps between min and max volume.
   @args.VOL_RESOLUTION {
       type integer
       default 256
   }
   # The name of the software volume control.
   # If your card does not have hardware volume control
   # naming it PCM will cause most apps that use alsa volume
   # to use the software volume control.
   @args.VOL_NAME {
       type string
       default Softvol
   }
   type plug
   rate_converter $SAMPLE_RATE_CONVERTER
   slave {
       channels 2
       rate $SAMPLE_RATE
       format $FORMAT
       pcm {
           type softvol
           min_dB $VOL_MIN_DB
           max_dB $VOL_MAX_DB
           resolution $VOL_RESOLUTION
           control {
               name $VOL_NAME
               card {
                   @func refer
                   name defaults.ctl.card
               }
           }
           slave {
               format $FORMAT
               pcm {
                   type dmix
                   ipc_key 1024
                   ipc_perm 0660
                   ipc_gid audio
                   slowptr true
                   hw_ptr_alignment roundup
                   slave {
                       pcm {
                           type hw
                           card {
                               @func refer
                               name defaults.pcm.card
                           }
                           device {
                               @func refer
                               name defaults.pcm.device
                           }
                           subdevice {
                               @func refer
                               name defaults.pcm.subdevice
                           }
                           channels 2
                           rate $SAMPLE_RATE
                           format $FORMAT
                       }
                       channels 2
                       period_size 0
                       buffer_size 0
                       buffer_time 0
                       period_time $BUFFER_PERIOD_TIME
                       periods $BUFFER_PERIODS
                       rate $SAMPLE_RATE
                       format $FORMAT
                   }
                   bindings {
                       0 0
                       1 1
                   }
               }
           }
       }
   }
}

###############################################################################

# Change to the card number or name that you want to be the default control card.
# Default: 0
defaults.ctl.card 0

# Change to the card number or name that you want to be the default playback card.
# It should usually be the same as defaults.ctl.card.
# Default: 0
defaults.pcm.card 0

# Change to the device number that you want to be the default device on the default card.
# 0 or 1 is usually the correct device number.
# Default: 0
defaults.pcm.device 0

# Change to the subdevice number that you want to be the default subdevice on the default device.
# Should rarely need to be changed.
# Default: -1
defaults.pcm.subdevice -1

pcm.spotify {
   type plug
   # Optional args:
   # SAMPLE_RATE: default: 44100
   # FORMAT: default: S16_LE
   # SAMPLE_RATE_CONVERTER: default: samplerate_linear
   # BUFFER_PERIODS: default: 4
   # BUFFER_PERIOD_TIME: default: 125000
   # VOL_MIN_DB: default: -51.0
   # VOL_MAX_DB: default: 0.0
   # VOL_RESOLUTION: default: 256
   # VOL_NAME: default: Softvol

   # Example:
   # hifiberry dac+ zero on a pi zero.
   # slave.pcm "hqstereo20:FORMAT=S32_LE,BUFFER_PERIOD_TIME=250000,VOL_MIN_DB=-48.0,VOL_NAME=PCM"

   slave.pcm "hqstereo20"
}

###############################################################################
  
This is basically the asound.config I use but I just override default so it's system wide. I use the settings in the example because I run librespot on a pi zero and a hifiberry dac+ zero.

works like a charm.

the only thing that could be tricky is that there are 2 versions of 24 bit, S24_LE which is exactly what it looks like and S24_3LE which is mostly used by USB DACs.
Reply
#10
Hi Jason,

Is it the app or is it ALSA that sets the period and buffer sizes?

Here is when MPD is playing. MPD is configured to output to hw:2,0
Code:
pi@rp3:~ $ cat /proc/asound/card2/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 5513
buffer_size: 22050

I don't have a Spotify Premium account so not able to test librespot but here is when Airplay renderer is playing. The period_size is same as that reported for when librespot is playing. Shairport-sync is configured to output to plughw:2,0
Code:
pi@rp3:~ $ cat /proc/asound/card2/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 256
buffer_size: 262144

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: