dtcooper/raspotify

Can`t find Raspotify on device list

jackobtone opened this issue · 99 comments

Compatible Device

  • I'm running Raspotify on a compatible Device

Are you sure?

  • I'm not trying to run Raspotify on a ARMv6 device

Compatible OS

  • I'm running Raspotify on a compatible OS

Compatible Configuration

  • I'm running Raspotify on a compatible Configuration

Latest Version

  • I'm running the latest version of Raspotify

Are you sure?

  • I'm not running Raspotify 0.31.8.1 on a on a Pi v1 or Pi Zero

Due Diligence

  • I have done my due diligence

What happened?

I will hook up to this topic. Recently I`ve installed DietPi + Alsa + Raspotify. Everything worked till todays update (got a prompt in the system). After it i cant find Raspberry in Spotify app. I have reinstalled the system, installed Alsa, installed Raspotify just like I did before and it didnt work. Command sudo service raspotify status give back a message:

root@DietPi:~# sudo service raspotify status
● raspotify.service - Raspotify (Spotify Connect Client)
Loaded: loaded (/lib/systemd/system/raspotify.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2022-12-05 18:39:34 GMT; 46s ago
Docs: https://github.com/dtcooper/raspotify
https://github.com/librespot-org/librespot
https://github.com/dtcooper/raspotify/wiki
https://github.com/librespot-org/librespot/wiki/Options
Process: 462 ExecStartPre=/bin/sleep 10 (code=exited, status=0/SUCCESS)
Main PID: 522 (librespot)
Tasks: 1 (limit: 4531)
CPU: 161ms
CGroup: /system.slice/raspotify.service
└─522 /usr/bin/librespot
Dec 05 18:39:24 DietPi systemd[1]: Starting Raspotify (Spotify Connect Client)...
Dec 05 18:39:34 DietPi systemd[1]: Started Raspotify (Spotify Connect Client).

I assume everything should work, but it doesnt

Relevant log output and/or the contents of /etc/raspotify/crash_report if any

root@DietPi:~# sudo journalctl -u raspotify -b
-- Journal begins at Mon 2022-12-05 18:39:12 GMT, ends at Mon 2022-12-05 18:40:55 GMT. --
Dec 05 18:39:24 DietPi systemd[1]: Starting Raspotify (Spotify Connect Client)...
Dec 05 18:39:34 DietPi systemd[1]: Started Raspotify (Spotify Connect Client).

Is the device you are trying to connect from on the same local network?

Can you ssh into the device running librespot?

What is the output of librespot -v I'm mostly concerned with things to do with zeroconf/mdns discovery.

What options/settings are you using?

  1. Yes, it is in the same local network. I have Asus AiMesh setup, Raspberry CM4 is connected directly to one of the routers.
  2. No idea what You mean, I`m green

root@DietPi:~# librespot -v
[2022-12-05T18:52:20Z INFO librespot] librespot 0.4.2 86743ea (Built on 2022-12-04, Build ID: 8yRuTOl9, Profile: release)
[2022-12-05T18:52:20Z TRACE librespot] Command line argument(s):
[2022-12-05T18:52:20Z TRACE librespot] v
[2022-12-05T18:52:20Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:38119
^C[2022-12-05T18:52:26Z INFO librespot] Gracefully shutting down

  1. Currently settings in terms of conf file are stock, didnt change anything in it after reinstallation of the system.
    Previously, after problems occured I tried adding my login and password -> Raspotify reappeared on the device list, but then after taping on it and trying to play something it disappeared again without playing the music

ssh stands for secure shell. You can use ssh to get a remote terminal so you can admin the device from another computer.

Is it possible that your router is blocking mdns?

Well, all the logs Ive pasted here are from Putty, so yes, I can ssh

Well, no idea. Main router is Asus AX89X, the seondary with which Raspberry is connected is AX86U. How can I check if they are blocking mdns?

Everything was working fine till today morning and this update, which I don`t even know what was about :)

The default behavior of the discovery code hasn't really changed in a long time but I did very recently backport a feature that allows a user to specify an IP address that mdns binds to. But that hasn't been an issue for me at all and the default behavior when that option is not set is exactly the same as before.

To clarify zeroconf was working fine for you before and now it's not?

Is there a firewall enabled on the device that's running librespot?

When it comes to zeroconf - earlier everything worked properly, without any issues, so I guess it worked, I didnt check zeroconf before problems occured, because there wasnt such need.

No, no firewall on DietPi/Raspberry CM4, but ofcourse firewall is set on on the router

If you haven't changed the firewall on the router and it worked before it should still work I imagine? You didn't have any specific rules before for the device before you reinstalled?

No, progress of reinstallation looked exactly the same as during the first time.
flashing software onto CM4 eMMC, startup, installing Alsa and Raspotify via DietPi (it has inbuilt list of software and installs all pointed software by itself). Install suceeded, no errors.

I mean on your router. Were/are there any device or protocol specific rules in place?

This next suggestion seems kinda silly but maybe power cycle everything.

I mean on your router. Were/are there any device or protocol specific rules in place?

No, nothing like that.

This next suggestion seems kinda silly but maybe power cycle everything.

Nothing to loose, will give it a go :)

The next steps are for me to install dietpi on my Pi and see if I can recreate the issue and for you to manually install an older release prior to the backport to see if that's the problem. If it is the problem I'm pretty sure I can approximate the feature with some systemd magic, revert the backport and issue a new release.

Meanwhile I will reinstall DietPi once again. During first system boot I used to do it with my Raspberry connected to the other router than the target one. Maybe this causes some trouble? But on the other hand I did exactly the same when was setting it up for the very first time and everything worked. Anyway i will give it a go

Fresh install - the additional update packages that DietPi installed itself during first startup

Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
binutils binutils-aarch64-linux-gnu binutils-common libbinutils
libctf-nobfd0 libctf0 libexpat1 libmpdec3 libpci3 libpython3-stdlib
libpython3.9-minimal libpython3.9-stdlib media-types pci.ids pciutils
python3 python3-minimal python3.9 python3.9-minimal
Suggested packages:
binutils-doc python3-doc python3-tk python3-venv python3.9-venv
python3.9-doc binfmt-support
Recommended packages:
flashrom
The following NEW packages will be installed:
binutils binutils-aarch64-linux-gnu binutils-common libbinutils
libctf-nobfd0 libctf0 libexpat1 libmpdec3 libpci3 libpython3-stdlib
libpython3.9-minimal libpython3.9-stdlib media-types pci.ids pciutils
python3 python3-minimal python3.9 python3.9-minimal rpi-eeprom

Decided, that I will install Alsamixer and Raspotify separetelly, begun with Alsa. After Alsa installation

root@DietPi:-# alsamixer
cannot open mixer: No such file or directory
root@DietPi:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Audio [McIntosh HD USB Audio], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Installed Raspotify:

DietPi-Software
─────────────────────────────────────────────────────
Step: Installing Raspotify: Spotify connect client
[ OK ] DietPi-Software | Checking URL: https://dtcooper.github.io/raspotify/key.asc
[ OK ] DietPi-Software | eval curl -sSfL 'https://dtcooper.github.io/raspotify/key.asc' | gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-raspotify.gpg --yes
[ OK ] DietPi-Software | eval echo 'deb https://dtcooper.github.io/raspotify/ raspotify main' > /etc/apt/sources.list.d/raspotify.list
[ INFO ] DietPi-Software | APT update, please wait...
Hit:1 https://deb.debian.org/debian bullseye InRelease
Hit:2 https://deb.debian.org/debian bullseye-updates InRelease
Hit:3 https://deb.debian.org/debian-security bullseye-security InRelease
Hit:4 https://deb.debian.org/debian bullseye-backports InRelease
Hit:5 https://archive.raspberrypi.org/debian bullseye InRelease
Get:6 https://dtcooper.github.io/raspotify raspotify InRelease [3143 B]
Get:7 https://dtcooper.github.io/raspotify raspotify/main arm64 Packages [915 B]
Fetched 4058 B in 2s (1641 B/s)
Reading package lists...
[ OK ] DietPi-Software | APT update
[ INFO ] DietPi-Software | APT install for: raspotify, please wait...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libasyncns0 libflac8 libogg0 libopus0 libpulse0 libsndfile1 libvorbis0a
libvorbisenc2 libwrap0 libxau6 libxcb1 libxdmcp6
Suggested packages:
opus-tools pulseaudio
The following NEW packages will be installed:
libasyncns0 libflac8 libogg0 libopus0 libpulse0 libsndfile1 libvorbis0a
libvorbisenc2 libwrap0 libxau6 libxcb1 libxdmcp6 raspotify
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 2813 kB of archives.
After this operation, 3565 kB of additional disk space will be used.
Get:1 https://deb.debian.org/debian bullseye/main arm64 libasyncns0 arm64 0.8-6+b2 [12.5 kB]
Get:2 https://deb.debian.org/debian bullseye/main arm64 libogg0 arm64 1.3.4-0.1 [26.3 kB]
Get:3 https://deb.debian.org/debian bullseye/main arm64 libflac8 arm64 1.3.3-2+deb11u1 [95.1 kB]
Get:4 https://deb.debian.org/debian bullseye/main arm64 libopus0 arm64 1.3.1-0.1 [169 kB]
Get:5 https://deb.debian.org/debian bullseye/main arm64 libvorbis0a arm64 1.3.7-1 [86.2 kB]
Get:6 https://archive.raspberrypi.org/debian bullseye/main arm64 libpulse0 arm64 14.2-2+rpt1 [244 kB]
Get:7 https://deb.debian.org/debian bullseye/main arm64 libvorbisenc2 arm64 1.3.7-1 [80.4 kB]
Get:8 https://deb.debian.org/debian bullseye/main arm64 libsndfile1 arm64 1.0.31-2 [179 kB]
Get:9 https://dtcooper.github.io/raspotify raspotify/main arm64 raspotify arm64 0.43.13-librespot.v0.4.2-86743ea [1678 kB]
Get:10 https://deb.debian.org/debian bullseye/main arm64 libwrap0 arm64 7.6.q-31 [58.7 kB]
Get:11 https://deb.debian.org/debian bullseye/main arm64 libxau6 arm64 1:1.0.9-1 [19.7 kB]
Get:12 https://deb.debian.org/debian bullseye/main arm64 libxdmcp6 arm64 1:1.1.2-3 [25.4 kB]
Get:13 https://deb.debian.org/debian bullseye/main arm64 libxcb1 arm64 1.14-3 [138 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 2813 kB in 1s (4751 kB/s)
Selecting previously unselected package libasyncns0:arm64.
(Reading database ... 17940 files and directories currently installed.)
Preparing to unpack .../00-libasyncns0_0.8-6+b2_arm64.deb ...
Unpacking libasyncns0:arm64 (0.8-6+b2) ...
Selecting previously unselected package libogg0:arm64.
Preparing to unpack .../01-libogg0_1.3.4-0.1_arm64.deb ...
Unpacking libogg0:arm64 (1.3.4-0.1) ...
Selecting previously unselected package libflac8:arm64.
Preparing to unpack .../02-libflac8_1.3.3-2+deb11u1_arm64.deb ...
Unpacking libflac8:arm64 (1.3.3-2+deb11u1) ...
Selecting previously unselected package libopus0:arm64.
Preparing to unpack .../03-libopus0_1.3.1-0.1_arm64.deb ...
Unpacking libopus0:arm64 (1.3.1-0.1) ...
Selecting previously unselected package libvorbis0a:arm64.
Preparing to unpack .../04-libvorbis0a_1.3.7-1_arm64.deb ...
Unpacking libvorbis0a:arm64 (1.3.7-1) ...
Selecting previously unselected package libvorbisenc2:arm64.
Preparing to unpack .../05-libvorbisenc2_1.3.7-1_arm64.deb ...
Unpacking libvorbisenc2:arm64 (1.3.7-1) ...
Selecting previously unselected package libsndfile1:arm64.
Preparing to unpack .../06-libsndfile1_1.0.31-2_arm64.deb ...
Unpacking libsndfile1:arm64 (1.0.31-2) ...
Selecting previously unselected package libwrap0:arm64.
Preparing to unpack .../07-libwrap0_7.6.q-31_arm64.deb ...
Unpacking libwrap0:arm64 (7.6.q-31) ...
Selecting previously unselected package libxau6:arm64.
Preparing to unpack .../08-libxau6_1%3a1.0.9-1_arm64.deb ...
Unpacking libxau6:arm64 (1:1.0.9-1) ...
Selecting previously unselected package libxdmcp6:arm64.
Preparing to unpack .../09-libxdmcp6_1%3a1.1.2-3_arm64.deb ...
Unpacking libxdmcp6:arm64 (1:1.1.2-3) ...
Selecting previously unselected package libxcb1:arm64.
Preparing to unpack .../10-libxcb1_1.14-3_arm64.deb ...
Unpacking libxcb1:arm64 (1.14-3) ...
Selecting previously unselected package libpulse0:arm64.
Preparing to unpack .../11-libpulse0_14.2-2+rpt1_arm64.deb ...
Unpacking libpulse0:arm64 (14.2-2+rpt1) ...
Selecting previously unselected package raspotify.
Preparing to unpack .../12-raspotify_0.43.13 librespot.v0.4.2-86743ea_arm64.deb ...
Unpacking raspotify (0.43.13librespot.v0.4.2-86743ea) ...
Setting up libxau6:arm64 (1:1.0.9-1) ...
Setting up libxdmcp6:arm64 (1:1.1.2-3) ...
Setting up libxcb1:arm64 (1.14-3) ...
Setting up libogg0:arm64 (1.3.4-0.1) ...
Setting up libflac8:arm64 (1.3.3-2+deb11u1) ...
Setting up libwrap0:arm64 (7.6.q-31) ...
Setting up libopus0:arm64 (1.3.1-0.1) ...
Setting up libvorbis0a:arm64 (1.3.7-1) ...
Setting up libasyncns0:arm64 (0.8-6+b2) ...
Setting up libvorbisenc2:arm64 (1.3.7-1) ...
Setting up libsndfile1:arm64 (1.0.31-2) ...
Setting up libpulse0:arm64 (14.2-2+rpt1) ...
Setting up raspotify (0.43.13
librespot.v0.4.2-86743ea) ...
Created symlink /etc/systemd/system/multi-user.target.wants/raspotify.service → /lib/systemd/system/raspotify.service.
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u5) ...
[ OK ] DietPi-Software | APT install for: raspotify
[ OK ] DietPi-Software | systemctl stop raspotify
DietPi-Software
─────────────────────────────────────────────────────
Step: Finalising install
[ OK ] DietPi-Software | systemctl daemon-reload
2022-12-05 22:05:22 [ INFO ] DietPi-RAMlog | Storing /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store...
2022-12-05 22:05:22 [ OK ] DietPi-RAMlog | Stored /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store.
[ SUB1 ] DietPi-Services > dietpi_controlled
[ OK ] DietPi-Services | dietpi_controlled : raspotify
[ OK ] DietPi-Services | dietpi_controlled : cron
DietPi-Software
─────────────────────────────────────────────────────
Step: Install completed
[ OK ] DietPi-Survey | Purging survey data
[ SUB1 ] DietPi-Services > restart
[ OK ] DietPi-Services | restart : raspotify
[ OK ] DietPi-Services | restart : cron

Raspotify test:

root@DietPi:~# sudo service raspotify status
● raspotify.service - Raspotify (Spotify Connect Client)
Loaded: loaded (/lib/systemd/system/raspotify.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2022-12-05 22:05:38 GMT; 5min ago
Docs: https://github.com/dtcooper/raspotify
https://github.com/librespot-org/librespot
https://github.com/dtcooper/raspotify/wiki
https://github.com/librespot-org/librespot/wiki/Options
Process: 5275 ExecStartPre=/bin/sleep 10 (code=exited, status=0/SUCCESS)
Main PID: 5276 (librespot)
Tasks: 1 (limit: 4531)
CPU: 229ms
CGroup: /system.slice/raspotify.service
└─5276 /usr/bin/librespot
Dec 05 22:05:28 DietPi systemd[1]: Starting Raspotify (Spotify Connect Client)...
Dec 05 22:05:38 DietPi systemd[1]: Started Raspotify (Spotify Connect Client).

Alsamixer works only under: "alsamixer -c 1", doesnt work under just "alsamixer", but it did before. Edit: OK, forgot to set USB DAC in system settings, "alsamixer" works, but still Raspotify isnt on device list

I believe it`s not Raspotify fault, but rather something with DietPi OS

Alsamixer works only under: "alsamixer -c 1", doesnt work under just "alsamixer", but it did before.

I believe it`s not Raspotify fault, but rather something with DietPi OS

Yep, Raspotify doesn't have anything to do with that.

Maybe just try Raspberry Pi OS Lite (64 bit) ?

At this point I'm not seeing a reason to have any faith in DietPi.

USB DAC in system settings, "alsamixer" works, but still Raspotify isnt on device list

Raspotify wouldn't be on the device list. It's not a device.

Yeah yeah, sorry, it was a mental shortcut. I mean my Raspberry based file transport isnt detected by Spotify Connect

I will try Raspberry Pi OS as you sugested

When you get that installed I'll walk you though configuring everything.

Make sure to install the "Lite" version so it's headless.

Here's a link to the official iso imager

https://downloads.raspberrypi.org/imager/imager_latest.exe (windows)

https://downloads.raspberrypi.org/imager/imager_latest.dmg (Mac)

You can click the little "gear" icon to preconfigure things like wifi, hostname, username password, enable ssh and whatnot.

Writing in progress. After it is complete, to install alsa i should use this code, right?

sudo apt update
sudo apt install alsa-utils libasound2-plugins

Writing in progress. After it is complete, to install alsa i should use this code?

sudo apt update
sudo apt install alsa-utils libasound2-plugins

You don't need to do that. Raspberry Pi OS already includes most if not all you need from ALSA and the Raspotify package will pull in whatever else it needs.

You only need libasound2-plugins if your DAC doesn't support a sampling rate of 44100. If your DAC does there is absolutely no point in resampling. Resampling NEVER improves sound quality.

If your DAC doesn't support 44100 then I would install libasound2-plugins with:

sudo apt install -y --no-install-recommends libasound2-plugins

--no-install-recommend prevents shit you don't need from being installed.

That`s awesome to know. Never used resampling. DAC accepts all formats up to DSD256

If librespot is the only thing that's going to use the DAC we can set up librespot to talk directly to the DAC.

librespot supports S16, S24, S24_3, S32, F32, and F64 at 44100. For bit depth you want the highest your DAC will support.

The reason being is that Spotify streams lossy audio and lossy audio doesn't have a real bit depth it has to be quantized back to having a bit depth while converting it back to PCM so the higher the bit depth the less quantization noise and the more headroom for digital volume control.

System woke up. So what first should I do?
I would also like to use my file transport as Roon Bridge

I`m curious if it will work, because some of the systems I tried didnt work with PCIe JCat Femto USB card connected to Raspberry. Anyway system woke up, thats a good sign

I would also like to use my file transport as Roon Bridge

Then we will need to set up dmix. You'll want to install libasound2-plugins as mentioned before that way you can accept different sampling rates.

So go ahead and do a sudo apt update && sudo apt dist-upgrade -y

Its done

I just looked up the PCIe JCat Femto USB card. That thing is pure snake oil. If it doesn't work just unplug it and just use one of the built in usb ports for your DAC.

Now install Raspotify:

sudo apt-get -y install curl && curl -sL https://dtcooper.github.io/raspotify/install.sh | sh

Its done

sudo apt install -y --no-install-recommends libasound2-plugins

If you haven't already.

I did, installed allready

Does Raspotify show up on a controlling device on your network?

Unfortunatelly it doesn`t. I will restart router and raspberry

Well shit.

Let's rule out that backport.

Remove the current version:

sudo apt purge -y raspotify

Assuming you installed the 64 bit version

Download the version before the backport:

curl -O -sL https://github.com/dtcooper/raspotify/releases/download/0.43.9/raspotify_0.43.9.librespot.v0.4.2-eb5e1a3_arm64.deb

Install that version:

sudo apt install -y ./raspotify_0.43.9.librespot.v0.4.2-eb5e1a3_arm64.deb

After that's done check to see if Raspotify shows up, and we can go from there.

Nope, still nothing

Well that's good news for me (I don't have to revert it,lol) and sorta bad news for you.

Now purge the old version and reinstall the latest version again:

sudo apt purge -y raspotify && sudo apt install -y raspotify

After that we're going to just disable discovery and use your creds. The downside to that is that it basically makes it a private player. No one else but that account will be able to see it.

I will reset this router

A neat side effect though is you don't have to be on the same network anymore to control it.

Go to your account overview page.

If you're in the US:

https://www.spotify.com/us/account/overview/

Or you can click the the account link in the web client:
Screenshot from 2022-12-05 17-47-10

I know my login and password, and i think i know what else I should do. I`m installing the newest version of Raspotify now. Then will edit conf file. If something fails I will let you know for sure :)

Thanks a lot for all your help, you are doing really good job with this project. Just keep on!

It's not that same as your login info.

Scroll down and look for your "username" (my username is just a bunch of numbers)

Screenshot from 2022-12-05 17-49-41

And then go to the device password page:

Screenshot from 2022-12-05 17-52-22

Click this:
Screenshot from 2022-12-05 17-54-13

Set your device password:
Screenshot from 2022-12-05 17-54-23

Next disable discovery by uncommenting this in the config:

#LIBRESPOT_DISABLE_DISCOVERY=

And enable cred caching to avoid nag emails everytime raspotify restarts by commenting this out:

LIBRESPOT_DISABLE_CREDENTIAL_CACHE=

Ok, Raspotify is visible again and works as it should. But what actually causes such problems?

After you put in your creds or just out of the blue?

Ok, Raspotify is visible again and works as it should. But what actually causes such problems?

Shit mdns implementations on actually a lot of wifi routers. My TP Link wifi router had similar problems. I ended up just buying a standalone router and just using the TP Link as a wifi AP.

It's also up in the air if libmdns (what librespot uses for mdns) is completely spec compliant?

Wow, I just tried another thing and it worked. I have uploaded onto Raspberry a "stock" conf file without Spotify password and login, logged into my router and fixed/connected MAC adress with IP and also changed previous IP adress of my Raspberry. It worked and Pi showed up on the device list, without necessity of logging in

That's because it's reading the previously cached creds.

Even after Raspbian reboot?

Yes. The token is saved to disk. That will work until the token expires and you'll be back to square one.

So I hope it will last long :)
Anyway to sum things up. Raspotify works perfectly, but routers are mad disturbers.
Once again thanks a lot for whole your help. For sure I will boder you again if something goes wrong :)
And I think this issue can be closed

Raspotify works perfectly, but routers are mad disturbers.

Well it's kinda sus + maybe sus. If the router is even the slightest bit finicky it may not be able to deal with libmdns.

So I hope it will last long :)

Why not just keep your creds in the config. Discovery still doesn't work so you gain nothing from having it enabled and as soon as the token expires librespot won't work anymore.

That’s true, but the case is other household members will use Raspotify as well (with their accounts), and if I understand correctly with my account’s data in config they wont be able to stream, right?

Correct. Without functioning discovery only the account that provides it's creds will be able to stream. No one else will be able to even see it.

While we're here let's set up your DAC and configure librespot for the best quality audio.

Sure, would be cool, but I`m not at home right now. If you could write me what can I do when at home, that would be awesome

Found a crash report file in raspotify folder

-- System Info --

Linux USBtransport 5.15.76-v8+ #1597 SMP PREEMPT Fri Nov 4 12:16:41 GMT 2022 aarch64 GNU/Linux

-- Logs --

Dec 07 11:00:40 USBtransport systemd[1]: Started Raspotify (Spotify Connect Client).
Dec 07 11:00:41 USBtransport librespot[706]: [2022-12-07T11:00:41Z ERROR librespot] Credentials are required if discovery is disabled.
Dec 07 11:00:41 USBtransport systemd[1]: raspotify.service: Main process exited, code=exited, status=1/FAILURE
Dec 07 11:00:41 USBtransport systemd[1]: raspotify.service: Failed with result 'exit-code'.
Dec 07 11:00:41 USBtransport systemd[1]: raspotify.service: Triggering OnFailure= dependencies.
Dec 07 11:00:51 USBtransport systemd[1]: Started Raspotify (Spotify Connect Client).
Dec 07 11:00:51 USBtransport systemd[1]: Stopping Raspotify (Spotify Connect Client)...
Dec 07 11:00:51 USBtransport systemd[1]: raspotify.service: Succeeded.
Dec 07 11:00:51 USBtransport systemd[1]: Stopped Raspotify (Spotify Connect Client).
Dec 07 11:00:51 USBtransport systemd[1]: Started Raspotify (Spotify Connect Client).
Dec 07 11:01:13 USBtransport systemd[1]: Stopping Raspotify (Spotify Connect Client)...
Dec 07 11:01:13 USBtransport systemd[1]: raspotify.service: Succeeded.
Dec 07 11:01:13 USBtransport systemd[1]: Stopped Raspotify (Spotify Connect Client).
Dec 07 11:01:13 USBtransport systemd[1]: Started Raspotify (Spotify Connect Client).
Dec 07 11:01:25 USBtransport systemd[1]: Stopping Raspotify (Spotify Connect Client)...
Dec 07 11:01:25 USBtransport systemd[1]: raspotify.service: Succeeded.
Dec 07 11:01:25 USBtransport systemd[1]: Stopped Raspotify (Spotify Connect Client).
Dec 07 11:01:30 USBtransport systemd[1]: Started Raspotify (Spotify Connect Client).
Dec 07 11:01:31 USBtransport librespot[461]: [2022-12-07T11:01:31Z WARN librespot] Could not initialise discovery: Setting up dns-sd failed: No such device (os error 19).
Dec 07 11:01:31 USBtransport librespot[461]: [2022-12-07T11:01:31Z ERROR librespot] Discovery is unavailable and no credentials provided. Authentication is not possible.
Dec 07 11:01:31 USBtransport systemd[1]: raspotify.service: Main process exited, code=exited, status=1/FAILURE
Dec 07 11:01:31 USBtransport systemd[1]: raspotify.service: Failed with result 'exit-code'.
Dec 07 11:01:31 USBtransport systemd[1]: raspotify.service: Triggering OnFailure= dependencies.

-- Config --

LIBRESPOT_QUIET=
LIBRESPOT_AUTOPLAY=
LIBRESPOT_DISABLE_AUDIO_CACHE=
LIBRESPOT_DISABLE_CREDENTIAL_CACHE=
LIBRESPOT_ENABLE_VOLUME_NORMALISATION=
LIBRESPOT_NAME="SpotifyConnect"
LIBRESPOT_BITRATE="320"
LIBRESPOT_FORMAT="S32"
LIBRESPOT_DEVICE_TYPE="avr"
LIBRESPOT_INITIAL_VOLUME="100"
LIBRESPOT_VOLUME_CTRL="fixed"
TMPDIR=/tmp

-- Ouput of aplay -l --

**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Audio [McIntosh HD USB Audio], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Discovery is unavailable and no credentials provided. Authentication is not possible. means that you have not added your creds back into the config.

I know, but anyway everything works. Raspotify is visible on the Spotify Connect list, I am able to stream.

While we're here let's set up your DAC and configure librespot for the best quality audio.

So what else can I do to achieve the best quality audio?

I assume you want to use:

card 2: Audio [McIntosh HD USB Audio], device 0: USB Audio [USB Audio]

I do, its McIntosh DAC 1 removable module sitting in McIntosh MA9000

OK, what is the output of aplay -L

null
Discard all samples (playback) or generate zero samples (capture)
default
Default Audio Device
sysdefault
Default Audio Device
lavrate
Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Hardware device with all software conversions
default:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
sysdefault:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct sample mixing device
usbstream:CARD=vc4hdmi0
vc4-hdmi-0
USB Stream Output
hw:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
Direct hardware device without any conversions
plughw:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
Hardware device with all software conversions
default:CARD=Audio
McIntosh HD USB Audio, USB Audio
Default Audio Device
sysdefault:CARD=Audio
McIntosh HD USB Audio, USB Audio
Default Audio Device
front:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
Front output / input
surround21:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
Direct sample mixing device
usbstream:CARD=Audio
McIntosh HD USB Audio
USB Stream Output
hw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Hardware device with all software conversions
default:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
sysdefault:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct sample mixing device
usbstream:CARD=vc4hdmi1
vc4-hdmi-1
USB Stream Output

OK your DAC is:

hw:CARD=Audio,DEV=0
McIntosh HD USB Audio, USB Audio
Direct hardware device without any conversions

The important part is:

hw:CARD=Audio,DEV=0

Now run:

aplay -Dhw:CARD=Audio,DEV=0 --dump-hw-params /dev/zero

It will probably throw an error but that's OK if it doesn't Control+C to exit it. What you're after is something that looks like this (this is for my DAC your specific info will probably be different):

HW Params of device "hw:CARD=D10s,DEV=0":
--------------------
ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT:  S32_LE SPECIAL DSD_U32_BE
SUBFORMAT:  STD
SAMPLE_BITS: 32
FRAME_BITS: 64
CHANNELS: 2
RATE: [44100 384000]
PERIOD_TIME: [125 1000000]
PERIOD_SIZE: [8 384000]
PERIOD_BYTES: [64 3072000]
PERIODS: [2 1024]
BUFFER_TIME: (41 2000000]
BUFFER_SIZE: [16 768000]
BUFFER_BYTES: [128 6144000]
TICK_TIME: ALL

Thats how output looks like:

HW Params of device "hw:CARD=Audio,DEV=0":


ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE S32_LE S24_3LE
SUBFORMAT: STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 64]
CHANNELS: 2
RATE: [32000 384000]
PERIOD_TIME: [125 1000000]
PERIOD_SIZE: [8 384000]
PERIOD_BYTES: [64 3072000]
PERIODS: [2 1024]
BUFFER_TIME: (41 2000000]
BUFFER_SIZE: [16 768000]
BUFFER_BYTES: [64 6144000]
TICK_TIME: ALL

Looks good. What is the most common sampling rate of the music you listen to?

My own CD RIPs in uncompressed 16/44,8 (mainly) , but also SACD rips in DSD128

Your DAC doesn't support DSD128. If you can do DSD to PCM conversion in Roon I'd do that, otherwise you might not be able to play those files. I'm not sure if the ALSA plug plugin can convert from DSD to PCM?

Hmm when I was using Moode Audio with native DSD set it worked and on the MA9000 screen i saw sampling saying its currently playing DSD128. That`s strange

Hmm when I was using Moode Audio with native DSD set it worked and on the MA9000 screen i saw sampling saying its currently playing DSD128. That`s strange

They must be using some magic/complex configs. Either that or aplay itself just doesn't support DSD128 so it's not even on it's radar?

We can pretend that it does for now and test it when we're done and see if it actually works.

Ok, so what am I supposed to do now? :)

Anyway now we're going to see if can use some reasonable buffer setting with your DAC. We want a decent buffer to avoid crazy high CPU usage but small enough that you don't notice a lot of input lag. IMHO 500ms (1/2 sec) works pretty well.

Run this to see if it works. Hopefully this will not throw an error. Use Control+C to exit if it doesn't:

aplay -Dhw:CARD=Audio,DEV=0 -fS32_LE -r44100 -c2 -B500000 -F100000 --dump-hw-params /dev/zero

The output:

Playing raw data '/dev/zero' : Signed 32 bit Little Endian, Rate 44100 Hz, Stereo
HW Params of device "hw:CARD=Audio,DEV=0":
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE S32_LE S24_3LE
SUBFORMAT: STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 64]
CHANNELS: 2
RATE: [32000 384000]
PERIOD_TIME: [125 1000000]
PERIOD_SIZE: [8 384000]
PERIOD_BYTES: [64 3072000]
PERIODS: [2 1024]
BUFFER_TIME: (41 2000000]
BUFFER_SIZE: [16 768000]
BUFFER_BYTES: [64 6144000]
TICK_TIME: ALL

Good deal looking real nice. Hold on a sec I need to write you a /etc/asound.conf.

OK, open /etc/asound.conf with whatever text editor (the file does not exist by default). and paste this into it:

# /etc/asound.conf
defaults.pcm.rate_converter speexrate_medium

pcm.!default {
    type plug
    slave.pcm {
        type dmix
        ipc_key {
            @func refer
            name defaults.pcm.ipc_key
        }
        ipc_gid {
            @func refer
            name defaults.pcm.ipc_gid
        }
        ipc_perm {
            @func refer
            name defaults.pcm.ipc_perm
        }
        slave {
            pcm {
                type hw
                nonblock {
                    @func refer
                    name defaults.pcm.nonblock
                }
                card Audio
                device 0
            }
            channels 2
            period_size 0
            buffer_size 0
            periods 0
            buffer_time 500000
            period_time 100000
            rate 44100
            format S32_LE
        }
        bindings {
            0 0
            1 1
        }
    }
}

ctl.!default {
    type hw
    card Audio
}

and then run this to test it.

aplay -fS32_LE -r44100 -c2 -B500000 -F100000 --dump-hw-params /dev/zero

It should show that it supports basically everything since now it's running though a software mixer and converter.

It works

ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U3 2_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_B E S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_ 3BE
SUBFORMAT: STD
SAMPLE_BITS: [4 64]
FRAME_BITS: [4 640000]
CHANNELS: [1 10000]
RATE: [4000 4294967295)
PERIOD_TIME: 100000
PERIOD_SIZE: [400 429496730)
PERIOD_BYTES: [200 4294967295)
PERIODS: (0 5368710)
BUFFER_TIME: [1 4294967295]
BUFFER_SIZE: [800 2147483647]
BUFFER_BYTES: [400 4294967295]
TICK_TIME: ALL

Looks like it works :)

As long as it didn't throw an error it's working.

Thank you very much for all your help and efforts :)

So now in /etc/raspotify/conf you no longer need to manually specify LIBRESPOT_DEVICE since your DAC is now your "default" device. You do however want LIBRESPOT_FORMAT to be LIBRESPOT_FORMAT="S32" (make sure it's also uncommented ofc)

From now on for all other audio "things" you want to use the "default" device.

If possible I would set the individual source softwares to convert to 2 channel 32 bit 44100 PCM. I'm willing to bet that Roon and friends have better converters than ALSA and it will save some CPU cycles on the Pi if it's converted before it's streamed to the Pi.

But in any event if the source sampling rate is 44100 the converter in ALSA will be bypassed.

Now for the subject of volume control. I know this is going to fly in the face of conventional audiophile wisdom, but correctly implemented software volume control is objectively superior to hardware volume control. Especially if your dealing with 16 bits of headroom as you are. That translates to theoretically 96dB of digital headroom before you have to throw away a bit of actual audio.

Basically don't adjust the volume with your DAC's hardware volume in alsamixer or set librespot to use hardware volume control. Use software volume control in librespot (software volume control in librespot uses 64bit float precision) if you use volume control at all.

So I should set LIBRESPOT_VOLUME_CTRL back to "log" from currently set "fixed"?

So I should set LIBRESPOT_VOLUME_CTRL back to "log" from currently set "fixed"?

librespot defaults to software volume control. I'm just saying don't fall for the lie that hardware volume control is always better than software volume control.

I personally set:

LIBRESPOT_INITIAL_VOLUME="100" and LIBRESPOT_VOLUME_CTRL="fixed" because I just use the volume control on my receiver. But that's just personal preference.

Okey, all seems to be clear, thanks!

You're welcome.