balbuze / volumio-plugins

volumio's plugins from balbuze
190 stars 60 forks source link

volspotconnect2 doesn't show current song on webUI #229

Closed Pejosonic closed 5 years ago

Pejosonic commented 5 years ago

Hi! i'm new posting on this community, so sorry if this is not the place for this commit.

Since last update of Volumio Spotify Connect2 (0.9.1) the web UI doesn't show up the current playing song. It's like Volumio doesn't know that it's playing music. This issue has a many side effects, one of them is when using the Amplifier Switch plugin.

Another issue i have noted on this version of Spotify Connect is a problem with volume control from Spotify, less important.

Thanks!

ashthespy commented 5 years ago

Could you share logs?

Pejosonic commented 5 years ago

I have just tried to reinstall connect2 plugin from this repository and the main problem seems to be solved.

There is only the volume control issue. For me this is less important

ashthespy commented 5 years ago

And what is the issue with the volume?

Pejosonic commented 5 years ago

When i change volume from Spotify there is no change on sound. After that, when i go to the webui and change volume, there's first a big jump to the volume set from Spotify.

It's like when changing volume from Spotify the change is set but not applied.

ashthespy commented 5 years ago

Could you share logs? Preferable from a fresh reboot and repeating the steps to recreate the issue you are facing.

Pejosonic commented 5 years ago

Sure but i don't know how to get the logs.

ashthespy commented 5 years ago

Did you have a look at the link from https://github.com/balbuze/volumio-plugins/issues/229#issuecomment-488276616?

Pejosonic commented 5 years ago

Sorry, i miss this out. I wast just reading the same article.

Here is the log.

Restarted Volumio (volume started at 40) Play a track from spotify (volume read 40 at Spotify) Change volume from Spotify, to 68 (see the change in webui but hear no difference) Press volume down on webui (jump to 62 and hear the change in volume from 40 to 62).

ashthespy commented 5 years ago

Hmm, so logs show that the daemon does change the volume, but probably on the wrong device?

Some debugging ideas:

  1. Check card/mixer

    Counter check if we can have the right card
    According to the logs: [Vollibrespot] : Setting up new mixer: card:hw:1 mixer:Digital index:0

    So could you share the outputs of the following?

    amixer controls
    amixer contents
    amixer get -c 1 "Digital "
    cat /tmp/getvolume

EDIT: mpd also seems to be grumbling about a missing PCM mixer control, wonder if that also needs to be investigated, or some standard warning.


# cat /var/log/mpd.log ---------------
May 01 16:36 : zeroconf: No global port, disabling zeroconf
May 01 16:36 : client: [0] opened from local
May 01 16:36 : exception: No such directory
May 01 16:37 : client: [1] opened from 127.0.0.1:40864
May 01 16:37 : exception: Failed to read mixer for 'alsa': no such mixer control: PCM
Pejosonic commented 5 years ago

My current setup is a RPi 3 + Allo Piano 2.1+ Kali Reclocker. Maybe that's related to the missing PCM control.

volumio@volumio:~$ amixer controls

numid=27,iface=MIXER,name='Master Playback Switch'
numid=26,iface=MIXER,name='Master Playback Volume'
numid=6,iface=MIXER,name='DSP Program'
numid=3,iface=MIXER,name='Analogue Playback Boost Volume'
numid=2,iface=MIXER,name='Analogue Playback Volume'
numid=10,iface=MIXER,name='Auto Mute Mono Switch'
numid=11,iface=MIXER,name='Auto Mute Switch'
numid=8,iface=MIXER,name='Auto Mute Time Left'
numid=9,iface=MIXER,name='Auto Mute Time Right'
numid=7,iface=MIXER,name='Clock Missing Period'
numid=5,iface=MIXER,name='Deemphasis Switch'
numid=4,iface=MIXER,name='Digital Playback Switch'
numid=1,iface=MIXER,name='Digital Playback Volume'
numid=22,iface=MIXER,name='Dual Mode Route'
numid=23,iface=MIXER,name='Lowpass Route'
numid=20,iface=MIXER,name='Max Overclock DAC'
numid=19,iface=MIXER,name='Max Overclock DSP'
numid=18,iface=MIXER,name='Max Overclock PLL'
numid=25,iface=MIXER,name='Subwoofer Playback Switch'
numid=24,iface=MIXER,name='Subwoofer Playback Volume'
numid=21,iface=MIXER,name='Subwoofer mode Route'
numid=16,iface=MIXER,name='Volume Ramp Down Emergency Rate'
numid=17,iface=MIXER,name='Volume Ramp Down Emergency Step'
numid=12,iface=MIXER,name='Volume Ramp Down Rate'
numid=13,iface=MIXER,name='Volume Ramp Down Step'
numid=14,iface=MIXER,name='Volume Ramp Up Rate'
numid=15,iface=MIXER,name='Volume Ramp Up Step'

volumio@volumio:~$ amixer contents

numid=27,iface=MIXER,name='Master Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=26,iface=MIXER,name='Master Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=207,step=0
  : values=189,189
  | dBscale-min=-103.50dB,step=0.50dB,mute=1
numid=6,iface=MIXER,name='DSP Program'
  ; type=ENUMERATED,access=rw------,values=1,items=5
  ; Item #0 'FIR interpolation with de-emphasis'
  ; Item #1 'Low latency IIR with de-emphasis'
  ; Item #2 'High attenuation with de-emphasis'
  ; Item #3 'Fixed process flow'
  ; Item #4 'Ringing-less low latency FIR'
  : values=0
numid=3,iface=MIXER,name='Analogue Playback Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=1,step=0
  : values=1,1
  | dBscale-min=0.00dB,step=0.80dB,mute=0
numid=2,iface=MIXER,name='Analogue Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=1,step=0
  : values=1,1
  | dBscale-min=-6.00dB,step=6.00dB,mute=0
numid=10,iface=MIXER,name='Auto Mute Mono Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=11,iface=MIXER,name='Auto Mute Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=8,iface=MIXER,name='Auto Mute Time Left'
  ; type=ENUMERATED,access=rw------,values=1,items=8
  ; Item #0 '21ms'
  ; Item #1 '106ms'
  ; Item #2 '213ms'
  ; Item #3 '533ms'
  ; Item #4 '1.07s'
  ; Item #5 '2.13s'
  ; Item #6 '5.33s'
  ; Item #7 '10.66s'
  : values=0
numid=9,iface=MIXER,name='Auto Mute Time Right'
  ; type=ENUMERATED,access=rw------,values=1,items=8
  ; Item #0 '21ms'
  ; Item #1 '106ms'
  ; Item #2 '213ms'
  ; Item #3 '533ms'
  ; Item #4 '1.07s'
  ; Item #5 '2.13s'
  ; Item #6 '5.33s'
  ; Item #7 '10.66s'
  : values=0
numid=7,iface=MIXER,name='Clock Missing Period'
  ; type=ENUMERATED,access=rw------,values=1,items=8
  ; Item #0 '1s'
  ; Item #1 '2s'
  ; Item #2 '3s'
  ; Item #3 '4s'
  ; Item #4 '5s'
  ; Item #5 '6s'
  ; Item #6 '7s'
  ; Item #7 '8s'
  : values=0
numid=5,iface=MIXER,name='Deemphasis Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=4,iface=MIXER,name='Digital Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=1,iface=MIXER,name='Digital Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=207,step=0
  : values=189,189
  | dBscale-min=-103.50dB,step=0.50dB,mute=1
numid=22,iface=MIXER,name='Dual Mode Route'
  ; type=ENUMERATED,access=rw------,values=1,items=3
  ; Item #0 'None'
  ; Item #1 'Dual-Mono'
  ; Item #2 'Dual-Stereo'
  : values=2
numid=23,iface=MIXER,name='Lowpass Route'
  ; type=ENUMERATED,access=rw------,values=1,items=15
  ; Item #0 '60'
  ; Item #1 '70'
  ; Item #2 '80'
  ; Item #3 '90'
  ; Item #4 '100'
  ; Item #5 '110'
  ; Item #6 '120'
  ; Item #7 '130'
  ; Item #8 '140'
  ; Item #9 '150'
  ; Item #10 '160'
  ; Item #11 '170'
  ; Item #12 '180'
  ; Item #13 '190'
  ; Item #14 '200'
  : values=0
numid=20,iface=MIXER,name='Max Overclock DAC'
  ; type=INTEGER,access=rw------,values=1,min=0,max=40,step=0
  : values=0
numid=19,iface=MIXER,name='Max Overclock DSP'
  ; type=INTEGER,access=rw------,values=1,min=0,max=40,step=0
  : values=0
numid=18,iface=MIXER,name='Max Overclock PLL'
  ; type=INTEGER,access=rw------,values=1,min=0,max=20,step=0
  : values=0
numid=25,iface=MIXER,name='Subwoofer Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=24,iface=MIXER,name='Subwoofer Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=207,step=0
  : values=189,189
  | dBscale-min=-103.50dB,step=0.50dB,mute=1
numid=21,iface=MIXER,name='Subwoofer mode Route'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'None'
  ; Item #1 '2.0'
  ; Item #2 '2.1'
  ; Item #3 '2.2'
  : values=0
numid=16,iface=MIXER,name='Volume Ramp Down Emergency Rate'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 '1 sample/update'
  ; Item #1 '2 samples/update'
  ; Item #2 '4 samples/update'
  ; Item #3 'Immediate'
  : values=0
numid=17,iface=MIXER,name='Volume Ramp Down Emergency Step'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 '4dB/step'
  ; Item #1 '2dB/step'
  ; Item #2 '1dB/step'
  ; Item #3 '0.5dB/step'
  : values=0
numid=12,iface=MIXER,name='Volume Ramp Down Rate'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 '1 sample/update'
  ; Item #1 '2 samples/update'
  ; Item #2 '4 samples/update'
  ; Item #3 'Immediate'
  : values=0
numid=13,iface=MIXER,name='Volume Ramp Down Step'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 '4dB/step'
  ; Item #1 '2dB/step'
  ; Item #2 '1dB/step'
  ; Item #3 '0.5dB/step'
  : values=2
numid=14,iface=MIXER,name='Volume Ramp Up Rate'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 '1 sample/update'
  ; Item #1 '2 samples/update'
  ; Item #2 '4 samples/update'
  ; Item #3 'Immediate'
  : values=0
numid=15,iface=MIXER,name='Volume Ramp Up Step'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 '4dB/step'
  ; Item #1 '2dB/step'
  ; Item #2 '1dB/step'
  ; Item #3 '0.5dB/step'
  : values=2

volumio@volumio:~$ amixer get -c 1 "Digital"

Simple mixer control 'Digital',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 207
  Mono:
  Front Left: Playback 189 [91%] [-9.00dB] [on]
  Front Right: Playback 189 [91%] [-9.00dB] [on]

volumio@volumio:~$ cat /tmp/getvolume

#!/bin/bash
volume=`/usr/bin/amixer -M get -c 1 "Digital" | awk '$0~/%/{print}' | cut -d '[' -f2 | tr -d '[]%' | head -1`
if [ "$volume" = "0" ]; then
echo "1"
else
echo $volume
fi
ashthespy commented 5 years ago

Hmm, don't see any obvious issues right away from that. Right, level 2 debug ;=)

  1. Counter check with amixer/alsamixer

    Run the backend daemon directly

    sudo systemctl stop volspotconnect2.service
    chmod +x /data//plugins/music_service/volspotconnect2/startconnect.sh
    ./data//plugins/music_service/volspotconnect2/startconnect.sh

    On another terminal, monitor the Digital mixer for card hw:1 either with alsamixer or amixer for amixer that would look like:

    amixer -M get -c 1 "Digital"

    Attempting to change volume via Spotify should give you information on the volume that you can compare the amixer output:

    [Vollibrespot] : Current alsa volume: 159[i64] MilliBel(-2400)
    [Vollibrespot] : Mapping volume [41.999%] 27524 [u16] ->> Alsa [-1092.271%] -22.61 [dB] - -2261 [i64]
Pejosonic commented 5 years ago

I think that this is the output about volume change:

This is the output when changing volume from Spotify:

[Vollibrespot] : Current alsa volume: 159[i64] MilliBel(-2400)
[Vollibrespot] : Mapping volume [16.999%] 11140 [u16] ->> Alsa [-2230.918%] -46.18 [dB] - -4618 [i64]

And this is the output for amixer -M get -c 1 "Digital"

volumio@volumio:~$ amixer -M get -c 1 "Digital"
Simple mixer control 'Digital',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 207
  Mono:
  Front Left: Playback 173 [52%] [-17.00dB] [on]
  Front Right: Playback 173 [52%] [-17.00dB] [on]

This says something to you?

Remember that when i change from Spotify, the volumen also moves on Volumio UI, but no changes on sound until touching the volume on the webui.

ashthespy commented 5 years ago

This is the output when changing volume from Spotify:

[Vollibrespot] : Current alsa volume: 159[i64] MilliBel(-2400)
[Vollibrespot] : Mapping volume [16.999%] 11140 [u16] ->> Alsa [-2230.918%] -46.18 [dB] - -4618 [i64]

I wonder why it's always stuck at this 159 and -23.00dB value. Does it correspond to 40% volume?

This says something to you?

No, as it would actually need output from before and after changing volume to compare. Maybe it's simpler for you to check with alsamixer to monitor any change in real time. Which reminds me, I made a small test program some time back that monitors the volume to help balbuze debug as I don't have DACs with hardware mixers, I will dig it up if you are willing to help debug!

Remember that when i change from Spotify, the volumen also moves on Volumio UI, but no changes >on sound until touching the volume on the webui.

Ah yes of course, I forgot to mention to disable the plugin first from the WebUI before manually starting it else it hooks into the volume events sent from the daemon. ~Although this behaviour is also quite interesting, as the way the webUI updates is via the volumioupdatevolume method, which in theory should also set the volume and doesn't seem to be working in your case.~ Not actually true, the method just updates the statemachine, and doesn't actually set the volume.

Pejosonic commented 5 years ago

Ah yes of course, I forgot to mention to disable the plugin first from the WebUI before manually starting it else it hooks into the volume events sent from the daemon. Although this behaviour is also quite interesting, as the way the webUI updates is via the volumioupdatevolume method, which in theory should also set the volume and doesn't seem to be working in your case.

This is what looks more stranger for me. It looks like a problem outside spotifyconnect2, but it happnes only in this scenario.

Monitoring the output of amixer -M get -c 1 "Digital" before and after changin volume from Spotify shows the volume change set in spotify and also displayed on webui.

Putting volume on 40%

[Vollibrespot] : Current alsa volume: 163[i64] MilliBel(-2200)
[Vollibrespot] : Mapping volume [40.000%] 26214 [u16] ->> Alsa [-1153.623%] -23.88 [dB] - -2388 [i64]

Putting volume on 60%

[Vollibrespot] : Current alsa volume: 178[i64] MilliBel(-1450)
[Vollibrespot] : Mapping volume [60.000%] 39321 [u16] ->> Alsa [-643.478%] -13.32 [dB] - -1332 [i64]

The number that you saw was the default volume after restarting the system.

ashthespy commented 5 years ago

This is what looks more stranger for me. It looks like a problem outside spotifyconnect2, but it happnes only in this scenario.

Not really - I just rechecked, the volumioupdatevolume just updates the value used by the WebUI display.

Monitoring the output of amixer -M get -c 1 "Digital" before and after changin volume from Spotify >shows the volume change set in spotify and also displayed on webui.

Putting volume on 40%

What are the corresponding outputs from amixer for these?

Pejosonic commented 5 years ago

Volume at 40% from Spotify

volumio@volumio:~$ amixer get -c 1 "Digital"
Simple mixer control 'Digital',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 207
  Mono:
  Front Left: Playback 159 [77%] [-24.00dB] [on]
  Front Right: Playback 159 [77%] [-24.00dB] [on]

Volume at 60%:

volumio@volumio:~$ amixer get -c 1 "Digital"
Simple mixer control 'Digital',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 207
  Mono:
  Front Left: Playback 180 [87%] [-13.50dB] [on]
  Front Right: Playback 180 [87%] [-13.50dB] [on]
ashthespy commented 5 years ago

That looks (you missed the -M flag that should output 40% instead of 77%) like it's doing it job properly - just probably on the wrong mixer.

From the piano Dac's documentation, you could also try by changing the mixer to Master which sets the volume for all mixers. This you can do by editing startconnect.sh

Pejosonic commented 5 years ago

That change did the trick!

Thank you!

ashthespy commented 5 years ago

That change did the trick!

To make the change survive plugin restarts, you should make your changes in volspotconnect2.tmpl

Out of curiosity, what mode are you using the DAC in? i.e do you have something connected to the sub outputs as well?

Pejosonic commented 5 years ago

I'm using only one stereo pair of the outputs. In Volumio>Playback Options it's set the Dual Stereo mode.

A couple of weeks ago after installing the Kali board suddenly the audio stop playing from the main out and started on the secondary out. At that time i have tried changing modes on Volumio but nothing happend. Right now, after changing config on volspotconnect2.tmpl and restarting many times the audio come back to the main output, also it's fixed the problem of the volume control (when the output switched i have reverted the changes to volspotconnect2.tpml). I think that there was a driver issue that was generating both problems.

A little bit after installing Kali, there was a main volumio update and also a SpotifyConnect2 update. So i didn't had time to identify why outptuts switched.

ashthespy commented 5 years ago

Okay! volspotconnect2 doesn't change any of the audio settings, just tries to derive the proper mixer and device setup from Volumio's exposed controls.

Eitherway, the reason why it worked when you set the volume via the WebUI is because Volumio explicitly sets the volume for the Subwoofer mixer as well. Maybe it would a good idea to start an issue or a forum post to propose using the Master mixer directly? That way we wouldn't need to add such hacky solutions here..

Pejosonic commented 5 years ago

I think that i understand the problem but there two things that want to ask. 1- nowadays every user of Piano 2.1 using both outs will have a similar problem?

2-why the current method use a workaround to detect if it's a Piano and then sets the subwoofer vol? So you say that it's better to use the Master mixer instead of Digital, it sound that it would be a better workaround than talking to Subwoofer mixer in a different line. I think that there is a limitation.

In my case unfortunatelly there was a problem in the Piano 2.1 output routing happening at the same time. I don't really know if they where connected. I have the feeling that it got solved after many reboots.

ashthespy commented 5 years ago

1- nowadays every user of Piano 2.1 using both outs will have a similar problem?

Yes, if you are using the Sub outputs, since Volumio only reports Digital as the mixer, this plugin won't be aware of the second Subwoofer mixer and hence won't be able to control that.

2-why the current method use a workaround to detect if it's a Piano and then sets the subwoofer vol?

That is a question for the people who wrote the code ;-) But I am guessing initially the Piano drivers didn't expose the Master control, and had only separate controls for the two outputs.

So you say that it's better to use the Master mixer instead of Digital, it sound that it would be a better workaround than talking to Subwoofer mixer in a different line. I think that there is a limitation.

I would imagine so - but I am not the expert, so!

In my case unfortunatelly there was a problem in the Piano 2.1 output routing happening at the same time. I don't really know if they where connected. I have the feeling that it got solved after many reboots.

Search the forums (https://forum.volumio.org/help.html) you might find others with similar issues