Audio normalization?
SawkeeReemo opened this issue · comments
This docker container works really well! Thank you. But I’m noticing that volume levels are all over the place from song to song. I noticed in the install instructions here that you can add “--enable-audio-normalisation” (specifically with the seemingly British spelling) as a run command in the docker compose. I did that, but it just errors out.
Does anyone know how to properly activate audio normalization for this container?
Happy that you like it.
Normalization definitely works (I am using it).
dubo@dacodac:~ $ docker run -d --rm \
> --name "spot" \
> --env "MOD_MDNS_NAME=Super Name For Your Spotify Connect Endpoint" \
> --volume /tmp \
> --group-add audio \
> --device /dev/snd \
> --net host \
> --cap-drop ALL \
> --read-only \
> index.docker.io/dubodubonduponey/spotify --enable-volume-normalisation
Unable to find image 'dubodubonduponey/spotify:latest' locally
latest: Pulling from dubodubonduponey/spotify
Digest: sha256:c65bcf104523e645d8570c6032390ea7ab42f02f4122922bd8048ecd20ea54ba
Status: Downloaded newer image for dubodubonduponey/spotify:latest
0f1571020d652709231864bd59a6e3c28936a1d68c8ff7c97038877d4ccc9943
dubo@dacodac:~ $ docker logs -f spot
[2024-01-12T21:52:25Z INFO librespot] librespot 0.4.2 22f8aed (Built on 2023-09-19, Build ID: 8BoXELKl, Profile: release)
[2024-01-12T21:52:55Z WARN librespot_core::apresolve] Ignoring blacklisted access point ap-gue1.spotify.com:443
[2024-01-12T21:52:55Z WARN librespot_core::apresolve] Ignoring blacklisted access point ap-gew4.spotify.com:80
[2024-01-12T21:52:55Z INFO librespot_core::session] Connecting to AP "ap-guc3.spotify.com:4070"
[2024-01-12T21:52:55Z INFO librespot_core::session] Authenticated as "XXXXXX" !
[2024-01-12T21:52:55Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
[2024-01-12T21:52:55Z INFO librespot_playback::convert] Converting with ditherer: tpdf
[2024-01-12T21:52:55Z INFO librespot_playback::audio_backend::alsa] Using AlsaSink with format: S16
[2024-01-12T21:52:55Z INFO librespot_core::session] Country: "US"
[2024-01-12T21:52:56Z INFO librespot_playback::player] Loading <Love Yourself (Self Confidence Exercise)> with Spotify URI <spotify:track:7e9OfKUx0ko2vnBFawlfxd>
[2024-01-12T21:52:57Z INFO librespot_playback::player] <Love Yourself (Self Confidence Exercise)> (289522 ms) loaded
I am not sure what you compose file is (also what error message do you get?), so, I cannot speak to that, but really, just pass it as an argument to be fed to the entrypoint, it should just work.
I found the issue and just came here to correct myself. Heh. I used composerize.com to convert the docker run command to a docker compose file. And it kept the leading double dashes in front of enable-audio-normalisation
which was causing the error. When I noticed that, I remove those and recreated the container. Seems like it’s up and running now! Sorry for the false alarm.
I found the issue and just came here to correct myself. Heh. I used composerize.com to convert the docker run command to a docker compose file. And it kept the leading double dashes in front of
enable-audio-normalisation
which was causing the error. When I noticed that, I remove those and recreated the container. Seems like it’s up and running now! Sorry for the false alarm.
It's all fine :).
Happy you figured it out.
Take care.
I found the issue and just came here to correct myself. Heh. I used composerize.com to convert the docker run command to a docker compose file. And it kept the leading double dashes in front of
enable-audio-normalisation
which was causing the error. When I noticed that, I remove those and recreated the container. Seems like it’s up and running now! Sorry for the false alarm.It's all fine :). Happy you figured it out.
Take care.
Hello, again! Sorry to bother you again about this, but was wondering if you might be able to help? It seems as though normalization is not working again for me. I've noticed these two errors in my logs:
WARN librespot_core::cache] Cannot save credentials to cache: Permission denied (os error 13)
WARN librespot_core::cache] Cannot save volume to cache: Permission denied (os error 13)
I'm not sure if that is related, but I checked the permissions on the volumes I have mounted, and they all seem to be correct. (Running this in docker on a raspberry pi 4.) But maybe the librespot_core cache is attempting to access a different directory somewhere? Would you have any idea how to address this? I would greatly appreciate the guidance. I've been searching for a bit, but haven't found anything relevant to this problem.
Here is my compose:
spotify:
image: index.docker.io/dubodubonduponey/spotify:latest
container_name: spotify
network_mode: host
command:
- enable-volume-normalisation
- bitrate 320
restart: unless-stopped
healthcheck:
test: curl --fail https://icanhazip.com || exit 1
interval: 15s
retries: 10
start_period: 20s
timeout: 10s
environment:
- NAME=Juebox
- MOD_MDNS_NAME=Jukebox
- PUID=${PUID}
- PGID=${PGID}
- TZ=${TZ}
labels:
- "com.centurylinklabs.watchtower.enable=true"
volumes:
- ${CONF_PATH}/spotify/tmp:/tmp
group_add:
- audio
devices:
- /dev/snd
cap_drop:
- ALL
read_only: true
When I first launch my container, and I grab the logs, I see this:
[2024-03-22T21:58:48Z INFO librespot] librespot 0.4.2 22f8aed (Built on 2024-02-28, Build ID: JylPVKKe, Profile: release)
[2024-03-22T21:58:48Z WARN librespot_core::apresolve] Ignoring blacklisted access point ap-gue1.spotify.com:443
[2024-03-22T21:58:48Z INFO librespot_core::session] Connecting to AP "ap-guc3.spotify.com:4070"
[2024-03-22T21:58:48Z INFO librespot_core::session] Authenticated as "redacted" !
[2024-03-22T21:58:48Z WARN librespot_core::cache] Cannot save credentials to cache: Permission denied (os error 13)
[2024-03-22T21:58:48Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
[2024-03-22T21:58:48Z WARN librespot_core::cache] Cannot save volume to cache: Permission denied (os error 13)
[2024-03-22T21:58:48Z INFO librespot_playback::convert] Converting with ditherer: tpdf
[2024-03-22T21:58:48Z INFO librespot_playback::audio_backend::alsa] Using AlsaSink with format: S16
[2024-03-22T21:58:48Z INFO librespot_core::session] Country: "US"
Any ideas? And thank you so much in advance, I really appreciate this image!
UPDATE: I was able to fix the permissions issues. But volume normalization still is not working for some reason. I'm listening to a playlist my friend made where the song Radioactive by Imagine Dragons is followed by Suicide Machine by Hum. The Hum song plays at least 50% quieter than the Imagine Dragons song.
I've tried removing the "bitrate" command and rebuilding the container, but I'm still having the volume issue. IS there anything else I can check?
Side note: I'm using a Schiit Modi DAC over USB, and have disabled all others. Not sure if that matters, but I wouldn't think that would affect volume normalization in this container.
**** List of PLAYBACK Hardware Devices ****
card 0: Modi [Schiit Modi+], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
Logs:
[2024-03-22T22:16:39Z INFO librespot] librespot 0.4.2 22f8aed (Built on 2024-02-28, Build ID: JylPVKKe, Profile: release)
[2024-03-22T22:16:39Z WARN librespot_core::apresolve] Ignoring blacklisted access point ap-gew4.spotify.com:80
[2024-03-22T22:16:39Z INFO librespot_core::session] Connecting to AP "ap-guc3.spotify.com:4070"
[2024-03-22T22:16:39Z INFO librespot_core::session] Authenticated as "XXXXXXX" !
[2024-03-22T22:16:39Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
[2024-03-22T22:16:39Z INFO librespot_playback::convert] Converting with ditherer: tpdf
[2024-03-22T22:16:39Z INFO librespot_playback::audio_backend::alsa] Using AlsaSink with format: S16
[2024-03-22T22:16:39Z INFO librespot_core::session] Country: "US"
[2024-03-22T22:17:01Z INFO librespot_playback::player] Loading <Radioactive> with Spotify URI <spotify:track:4G8gkOterJn0Ywt6uhqbhp>
[2024-03-22T22:17:01Z INFO librespot_playback::player] <Radioactive> (186813 ms) loaded
[2024-03-22T22:17:03Z INFO librespot_playback::player] Loading <Suicide Machine> with Spotify URI <spotify:track:58ID4EDYufCXgLt0iRJ9Rk>
[2024-03-22T22:17:03Z INFO librespot_playback::player] <Suicide Machine> (357760 ms) loaded
Looking soon. Sorry for the delay.
Ok, a few things:
First I really strongly suggest you do not use the tag "latest" (eg: index.docker.io/dubodubonduponey/spotify:latest) - please pick a date tag (like bookworm-2024-02-20)
If you stay on latest and if I change anything, or rename a variable, your stuff will stop working and it will take a lot of effort for you to revert to a working state (and warning: I am going to change a lot of things soon...)
Back on topic, this image is not doing anything wrt to volume-normalization - so, unless the argument is not passed correctly, that would be a librespot issue and not a docker / image one.
Let's verify that first then:
Can you run this below on the host?
ps aux | grep librespot
and copy the output here.
Thanks.
Once we have confirmed that the arguments are passed correctly, you should have a look at this:
https://github.com/librespot-org/librespot/wiki/Options#volume-normalisation
Specifically, dynamic is default for volume normalisation - and this might not be what you want...
You might want to have a look at:
- normalisation-method
- normalisation-gain-type
- and at least pregain and threshold
Hope that helps.