Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting silence does not work #38

Closed
nis65 opened this issue Dec 14, 2021 · 5 comments · Fixed by #74
Closed

Detecting silence does not work #38

nis65 opened this issue Dec 14, 2021 · 5 comments · Fixed by #74
Assignees

Comments

@nis65
Copy link
Collaborator

nis65 commented Dec 14, 2021

Ideally, the snapserver would go to state idle when no audio is to be played. I have currently three sources connected to the Loopback device:

  • an acable for bluetooth (no device streaming right now)
  • an acable for the analog input (for the rec out of my hifi amp, testing with vinyl turntable)
  • mpd

When I stop mpd and stop the analog acable systemctl stop [email protected], then the snapserver switches immediately to state idle, provided I have the following config in snapserver.conf:

source = alsa://?name=hifi&device=dsnoop:CARD=Loopback,DEV=1&send_silence=false&idle_threshold=100&silence_threshold_percent=0.2

The current state of the snapserver is best viewed in snapweb. Starting/Stopping mpd is followed by the
snapserver state immediately.

However, as long as the acable@analog-aloop service is running, snapserver stays on playing.

I assume that the silence_threshold_percent parameter is not yet implemented in the version we are getting from the bullseye repo, strings finds send_silence and idle_threshold, but not silence_threshold_percent in the snapserver binary.

I found a quite current bug report about exactly that feature.

@nis65
Copy link
Collaborator Author

nis65 commented Dec 15, 2021

It's clear

  • current bullseye package version: snapserver 0.23.0+dfsg1-1
  • Feature silence_threshold_percent only in 0.25

Will give it a try with a new snapserver package.

@nis65 nis65 self-assigned this Dec 15, 2021
@nis65
Copy link
Collaborator Author

nis65 commented Dec 15, 2021

Successfully tested on my setup with this deb

source = alsa://?name=hifi&device=dsnoop:CARD=Loopback,DEV=1&send_silence=false&idle_threshold=100&silence_threshold_percent=0.5

It looks like my setup is quite noisy, setting anything lower than 0.5 does not trigger idle, watch for these log entries:

Dec 15 16:35:49 hifi snapserver[16576]: onStateChanged (hifi): playing
Dec 15 16:35:53 hifi snapserver[16576]: onStateChanged (hifi): idle

Hint: The DEB above seems to need the following override, I assume this is different in the standard debian package:

# /etc/systemd/system/snapserver.service.d/override.conf
[Service]
User=_snapserver
Group=_snapserver

@nis65
Copy link
Collaborator Author

nis65 commented Dec 19, 2021

Another two pieces of information:

  • after having read the commit 216714b, 0.5 means only 0.5% (and not 50% as I first thought), so 0.5 is an acceptable default
  • however, having played a record with a song having a quite long and quiet intro, I had dropouts with the above settings. I didn't want to raise silence_threshold_percent even more so that even quiet parts are interpreted as music - but idle still needs a chance to kick in as soon as the pickup is lifted off the vinyl record. After having raised the idle_threshold to 1000 (1sec), the random static clicks from the record where enough to keep playing as long as the record was turning:
source = alsa://?name=hifi&device=dsnoop:CARD=Loopback,DEV=1&send_silence=false&idle_threshold=1000&silence_threshold_percent=0.5

@nis65
Copy link
Collaborator Author

nis65 commented Dec 31, 2021

There is actually another solution to this issue. Hifiberry has built a python alsaloop implementation with silence detection. So we would not depend on this feature in snapserver.

However, this is only an option if this alsaloop properly works with dsnoop and dmix devices. To be tested.

@nis65
Copy link
Collaborator Author

nis65 commented Feb 6, 2022

Latest merge in DEV solves the config issue in ansible that works with V0.25 of snapserver (see above).

Not marking as solved until V.025 is installable via some repo (or we have implemented the install process of V0.25 in ansible).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant