spotify-connect-web icon indicating copy to clipboard operation
spotify-connect-web copied to clipboard

Respect non-default devices when using the --mixer option

Open vrob01 opened this issue 8 years ago • 7 comments

In console_callbacks.py, line 87 a new mixer instance is created. If the desired mixer, as set by the "--mixer" option is not on found on the default card with cardindex=0, this will critically fail. If the user chooses a different card via the "--device" option this should be respected here and the mixer should be sought after on the card given by "--device" using the "cardindex" parameter. Or give the user a mean of selecting the card on which the given mixer is to be found.

vrob01 avatar May 29 '16 22:05 vrob01

I have my --device hw:1,0 and --mixer PCM. When I change volume in Spotify no volume is changed for my selected card. Instead – same named mixer for cardindex=0 volume is changed. Specifying device for mixer would be very useful.

cadavre avatar Jun 01 '16 19:06 cadavre

Just made a new release with --playback_device and --mixer_device_index options. https://github.com/Fornoth/spotify-connect-web/releases/tag/0.0.3-alpha --playback_device is a replacement for --device and uses the names from aplay -L --mixer_device_index takes the device index of the card outputting the audio, like the 1 in hw:1,0 I'm not sure if there's a way to automatically determine the correct mixer index from the device

Fornoth avatar Jul 05 '16 04:07 Fornoth

@Fornoth - This is just awesome. I was working with a lot of small hacks, to get it working with Volumio. After reading multiple guides, and nothing gave me the final goal - i just saw this post.

Thanks for making this possible! :-)

Everyting is running fine.

Troubling with finding the right options for your setup? Give this a try (Look below this line)

I used the following options, to activate my device, and enabling volume-control. --playback_device default:CARD=DAC --mixer_device_index 5

Option nr 1:

--playback_device default:CARD=DAC

  • Run the command: aplay -L
  • Look at the output, to find the right name.

Now i know, that the option should be: default:CARD=DAC

image

Option nr 2:

--mixer_device_index 5

  • Run the command: alsamixer
  • Press F6 to open the overview

As you can see, here is my USB Audio DAC number 5. Now i know, that the option should be: 5

image

Run as service (Start on boot)

I prefer having a script with my options, and call that scipt - Can't explain why. So here we go:

  • Open a new file, and give it a name like: cd /home/volumio && sudo nano run_spotify.sh
  • Paste in the options you like. Here is a EXAMPLE!
#!/bin/bash
cd /home/volumio/spotifyconnect
./spotify-connect-web --name Livingroom --username USERNAMEGOESHERE --password PASSWORDGOESHERE--bitrate 320  --playback_device default:CARD=DAC --mixer_device_index 5
  • Save the file, and close it by pressing Ctrl + O > Enter > Ctrl + X.
  • Make it executable: sudo chmod u+x run_spotify.sh
  • Check if it works, if you like by running the following code: ./run_spotify.sh

Works? Great! Or? Start over.. Now we can make a simpel service, by doing the following tricks:

  • Open a new file, and give is a name (the service): sudo nano /usr/lib/systemd/system/spotifyconnect.service
  • Paste in, the following information. Remember to change the filename in the script, if you managed to find out a better name or so.
[Unit]
Description=Spotify Connect
After=network.target

[Service]
ExecStart=/home/volumio/run_spotify.sh
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20

[Install]
WantedBy=multi-user.target

Still holding on? Cool! If you like, you could start up by cleaning the deamon: systemctl daemon-reload

  • Let's test the service: systemctl start spotifyconnect Did it show up on the phone/tablet? Great!
  • Let's enable the service: systemctl enable spotifyconnect

Now you're good to go. Do a soft reboot by typing sudo reboot. If you sometime in the future like to disable the service, you just have to make a systemctl disable spotifyconnect

Multi-user support

If you need support for multiple Spotify users, this will do it.

  • First we need to install avahi-utils, so that we're able to run the avahi-publish-service: sudo apt-get update && sudo apt-get install avahi-utils
  • Test with the following command: avahi-publish-service Livingroom _spotify-connect._tcp 4000 VERSION=1.0 CPath=/login/_zeroconf If other users are able to see the Spotify Connect device, you're good to go.

Lets enable the service at startup (in Avahi)!

  • Avahi support services, so it's a very easy job. Make a new file called spotifyconnect.service sudo nano /etc/avahi/services/spotifyconnect.service
  • Paste in the following code.
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">Spotify-connect at %h</name>
 <service>
   <type>_spotify-connect._tcp</type>
   <port>4000</port>
   <txt-record>VERSION=1.0</txt-record>
   <txt-record>CPath=/login/_zeroconf</txt-record>
 </service>
</service-group>

You don't even have to restart. Look at the guest tablet. All good? Awesome!

I will recommend making a restart with sudo reboot when all set. If something isn't working like it should, you may will find sudo journalctl -f useful.

Hopefully is could be helpfully for someone out there :-)

exetico avatar Aug 04 '16 18:08 exetico

@Fornoth If the device is specified as hw:a,b, then the mixer index is a. If the device is specified as default:CARD=card,DEV=d, then the mixer index is alsa.pcms().index(card) No?

awiouy avatar Aug 12 '16 07:08 awiouy

@exetico no problem! @awiouy Not exactly (for me at least) see http://larsimmisch.github.io/pyalsaaudio/libalsaaudio.html#alsaaudio.mixers

Fornoth avatar Oct 02 '16 04:10 Fornoth

I have the same problem . with -- device suni4codec --mixer_device_index 0 i can not change volume

corected_playback_volume: 100 playback_volume: 49151 corected_playback_volume: 100 playback_volume: 65535 corected_playback_volume: 100 playback_volume: 43908 corected_playback_volume: 100 playback_volume: 5242 corected_playback_volume: 100 That says the log.

atze09 avatar Feb 10 '17 13:02 atze09

@atze09 if you're trying to do this on a CHIP, try --playback_device 'default:CARD=sun4icodec' --mixer 'Power Amplifier'

Fornoth avatar Jan 15 '18 17:01 Fornoth