Skip to content

Commit cbe02db

Browse files
authored
Support alsa equal (#340)
* Install libasound2-plugin-equal along with libasound2 * Install libasound2-plugin-equal in more builds (standard alsa and full) * Add alsa-utils * Add equalizer.md document * Fix some Dockerfile issues * Autogenerate asound config file, take #1 * Autogenerate asound config file, add formatting and dump generate file * Doesn't work if container is not running as root * #338 improvements, an asound.conf is now not strictly required (though it might be useful)
1 parent 24db149 commit cbe02db

7 files changed

Lines changed: 118 additions & 73 deletions

File tree

Dockerfile

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG BASE_IMAGE
2-
FROM ${BASE_IMAGE} AS BASE
2+
FROM ${BASE_IMAGE:-debian:stable-slim} AS base
33
# BUILD_MODE: [ std, sf, r2, bt ]
44
ARG BUILD_MODE
55
# BINARY_MODE: [ "full", "pulse", "alsa", "alsa-bt" ]
@@ -56,7 +56,7 @@ RUN rm -rf /var/lib/apt/lists/*
5656
RUN rm -Rf /app/install
5757

5858
FROM scratch
59-
COPY --from=BASE / /
59+
COPY --from=base / /
6060

6161
LABEL maintainer="GioF71"
6262
LABEL source="https://github.com/GioF71/squeezelite-docker"
@@ -67,57 +67,59 @@ RUN mkdir -p /app/conf
6767
RUN mkdir -p /app/doc
6868
RUN mkdir -p /app/assets
6969

70-
ENV SQUEEZELITE_MODE ""
71-
ENV SQUEEZELITE_AUDIO_DEVICE ""
72-
ENV SQUEEZELITE_MIXER_DEVICE ""
73-
ENV SQUEEZELITE_MAC_ADDRESS ""
74-
ENV DISABLE_MAC_ADDRESS_GENERATION ""
75-
ENV SQUEEZELITE_NAME ""
76-
ENV SQUEEZELITE_MODEL_NAME ""
77-
ENV SQUEEZELITE_TIMEOUT ""
78-
ENV SQUEEZELITE_DELAY ""
79-
80-
ENV STARTUP_DELAY_SEC ""
81-
82-
ENV SQUEEZELITE_SERVER_PORT ""
83-
84-
ENV SQUEEZELITE_RATES ""
85-
ENV SQUEEZELITE_UPSAMPLING ""
86-
87-
ENV PRESET ""
88-
89-
ENV SQUEEZELITE_PARAMS ""
90-
ENV SQUEEZELITE_CODECS ""
91-
ENV SQUEEZELITE_EXCLUDE_CODECS ""
92-
ENV SQUEEZELITE_PRIORITY ""
93-
ENV SQUEEZELITE_STREAM_AND_OUTPUT_BUFFER_SIZE ""
94-
ENV SQUEEZELITE_BUFFER_SIZE ""
95-
ENV SQUEEZELITE_UNMUTE ""
96-
ENV SQUEEZELITE_VOLUME_CONTROL ""
97-
ENV SQUEEZELITE_LINEAR_VOLUME ""
98-
ENV SQUEEZELITE_VISUALIZER ""
99-
ENV SQUEEZELITE_READ_FORMATS_FROM_HEADER ""
100-
101-
ENV SQUEEZELITE_LOG_CATEGORY_ALL ""
102-
ENV SQUEEZELITE_LOG_CATEGORY_SLIMPROTO ""
103-
ENV SQUEEZELITE_LOG_CATEGORY_STREAM ""
104-
ENV SQUEEZELITE_LOG_CATEGORY_DECODE ""
105-
ENV SQUEEZELITE_LOG_CATEGORY_OUTPUT ""
106-
ENV SQUEEZELITE_LOG_CATEGORY_IR ""
70+
ENV SQUEEZELITE_MODE=""
71+
ENV SQUEEZELITE_EQ_AUDIO_DEVICE=""
72+
ENV SQUEEZELITE_AUDIO_DEVICE=""
73+
ENV SQUEEZELITE_EQ_AUDIO_DEVICE=""
74+
ENV SQUEEZELITE_MIXER_DEVICE=""
75+
ENV SQUEEZELITE_MAC_ADDRESS=""
76+
ENV DISABLE_MAC_ADDRESS_GENERATION=""
77+
ENV SQUEEZELITE_NAME=""
78+
ENV SQUEEZELITE_MODEL_NAME=""
79+
ENV SQUEEZELITE_TIMEOUT=""
80+
ENV SQUEEZELITE_DELAY=""
81+
82+
ENV STARTUP_DELAY_SEC=""
83+
84+
ENV SQUEEZELITE_SERVER_PORT=""
85+
86+
ENV SQUEEZELITE_RATES=""
87+
ENV SQUEEZELITE_UPSAMPLING=""
88+
89+
ENV PRESET=""
90+
91+
ENV SQUEEZELITE_PARAMS=""
92+
ENV SQUEEZELITE_CODECS=""
93+
ENV SQUEEZELITE_EXCLUDE_CODECS=""
94+
ENV SQUEEZELITE_PRIORITY=""
95+
ENV SQUEEZELITE_STREAM_AND_OUTPUT_BUFFER_SIZE=""
96+
ENV SQUEEZELITE_BUFFER_SIZE=""
97+
ENV SQUEEZELITE_UNMUTE=""
98+
ENV SQUEEZELITE_VOLUME_CONTROL=""
99+
ENV SQUEEZELITE_LINEAR_VOLUME=""
100+
ENV SQUEEZELITE_VISUALIZER=""
101+
ENV SQUEEZELITE_READ_FORMATS_FROM_HEADER=""
102+
103+
ENV SQUEEZELITE_LOG_CATEGORY_ALL=""
104+
ENV SQUEEZELITE_LOG_CATEGORY_SLIMPROTO=""
105+
ENV SQUEEZELITE_LOG_CATEGORY_STREAM=""
106+
ENV SQUEEZELITE_LOG_CATEGORY_DECODE=""
107+
ENV SQUEEZELITE_LOG_CATEGORY_OUTPUT=""
108+
ENV SQUEEZELITE_LOG_CATEGORY_IR=""
107109

108110
ENV SQUEEZELITE_POWER_SCRIPT=""
109111
ENV SQUEEZELITE_RPI_GPIO=""
110112

111-
ENV DISPLAY_PRESETS ""
113+
ENV DISPLAY_PRESETS=""
112114

113-
ENV PUID ""
114-
ENV PGID ""
115-
ENV AUDIO_GID ""
115+
ENV PUID=""
116+
ENV PGID=""
117+
ENV AUDIO_GID=""
116118

117-
ENV SELECT_CUSTOM_BINARY_ALSA ""
118-
ENV SELECT_CUSTOM_BINARY_PULSE ""
119+
ENV SELECT_CUSTOM_BINARY_ALSA=""
120+
ENV SELECT_CUSTOM_BINARY_PULSE=""
119121

120-
ENV INSTALL_BLUETOOTH_LIBRARIES ""
122+
ENV INSTALL_BLUETOOTH_LIBRARIES=""
121123

122124
COPY app/bin/run-squeezelite.sh /app/bin/
123125
COPY app/bin/run-squeezelite-alsa.sh /app/bin/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ PUID||User ID which will be used to run squeezelite in user mode, defaults to `1
9494
PGID||Group ID which will be used to run squeezelite in user mode, defaults to `1000`
9595
AUDIO_GID||This group id is mandatory with alsa output when running in user mode. It must be set to the group id associated to the `audio` group. See more [here](https://github.com/GioF71/squeezelite-docker/blob/main/doc/example-alsa-user-mode.md).
9696
PRESET||You can now choose to set variables using predefined presets. Presets can currently tune the values of `SQUEEZELITE_AUDIO_DEVICE`, `SQUEEZELITE_RATES`, `SQUEEZELITE_UPSAMPLING`, `SQUEEZELITE_CODECS` and `SQUEEZELITE_EXCLUDE_CODECS` for you. See the [Available presets](#available-presets) table for reference. Presets can be combined (the separator must be a comma `,`), but keep in mind that the first preset setting a variable has the priority: once set by a preset, a variable cannot be overwritten by subsequent presets.
97+
SQUEEZELITE_EQ_AUDIO_DEVICE||The Audio device used for the custom asound file for equalizer. Use something like `plughw:DAC`, `plughw:0` depending on your hardware. Leave `SQUEEZELITE_AUDIO_DEVICE` blank or set it to `equal`
9798
SQUEEZELITE_AUDIO_DEVICE|-o|The audio device. Common examples for alsa mode: `hw:CARD=x20,DEV=0` or `hw:CARD=DAC,DEV=0` for usb dac based on XMOS. If left empty, the default device is used.
9899
SQUEEZELITE_MIXER_DEVICE|-O|Specify mixer device, defaults to `output device` (`SQUEEZELITE_AUDIO_DEVICE`)
99100
SQUEEZELITE_PARAMS|-a|Please refer to the squeezelite's man page for `-a`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ctl.equal {
2+
type equal;
3+
}
4+
5+
pcm.plugequal {
6+
type equal;
7+
slave.pcm "plughw:DAC";
8+
}
9+
10+
pcm.equal {
11+
type plug;
12+
slave.pcm plugequal;
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ctl.equal {
2+
type equal;
3+
}
4+
5+
pcm.plugequal {
6+
type equal;
7+
slave.pcm "plughw:CARD=DAC,DEVICE=0";
8+
}
9+
10+
pcm.equal {
11+
type plug;
12+
slave.pcm plugequal;
13+
}

app/bin/run-squeezelite-alsa.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ else
165165
echo "Final SQUEEZELITE_VOLUME_CONTROL = $SQUEEZELITE_VOLUME_CONTROL"
166166
fi
167167

168+
if [[ -n "${SQUEEZELITE_EQ_AUDIO_DEVICE}" ]]; then
169+
echo "SQUEEZELITE_EQ_AUDIO_DEVICE has been set to [${SQUEEZELITE_EQ_AUDIO_DEVICE}]"
170+
if [[ -z "${SQUEEZELITE_AUDIO_DEVICE}" ]]; then
171+
echo "SQUEEZELITE_AUDIO_DEVICE empty, setting to 'equal'"
172+
SQUEEZELITE_AUDIO_DEVICE=equal
173+
fi
174+
fi
175+
176+
168177
cmdline-server-port
169178
cmdline-player-name
170179
cmdline-model-name
@@ -345,6 +354,35 @@ fi
345354
handle_mac_address
346355
cmdline_mac_address
347356

357+
# write /etc/asound.conf or ~/.asoundrc if needed
358+
if [[ -n "${SQUEEZELITE_EQ_AUDIO_DEVICE}" ]]; then
359+
echo "SQUEEZELITE_EQ_AUDIO_DEVICE has been set to [${SQUEEZELITE_EQ_AUDIO_DEVICE}], creating custom asound file"
360+
ASOUND_FILE_NAME=/etc/asound.conf
361+
if [[ $current_user_id != 0 ]]; then
362+
# user mode, file will be ~/.asoundrc
363+
echo "Cannot create custom asound.conf file when running with user [$current_user_id] ..."
364+
exit 5
365+
fi
366+
echo "ASOUND_FILE_NAME=${ASOUND_FILE_NAME}"
367+
# write content
368+
echo "# custom asound file for eq mode" > $ASOUND_FILE_NAME
369+
echo "ctl.equal {" >> $ASOUND_FILE_NAME
370+
echo "type equal" >> $ASOUND_FILE_NAME
371+
echo "}" >> $ASOUND_FILE_NAME
372+
echo "pcm.plugequal {" >> $ASOUND_FILE_NAME
373+
echo " type equal;" >> $ASOUND_FILE_NAME
374+
echo " slave.pcm \"${SQUEEZELITE_EQ_AUDIO_DEVICE}\";" >> $ASOUND_FILE_NAME
375+
echo "}" >> $ASOUND_FILE_NAME
376+
echo "pcm.equal {" >> $ASOUND_FILE_NAME
377+
echo "type plug;" >> $ASOUND_FILE_NAME
378+
echo "slave.pcm plugequal;" >> $ASOUND_FILE_NAME
379+
echo "}" >> $ASOUND_FILE_NAME
380+
# show the generated file
381+
echo "--- BEGIN $ASOUND_FILE_NAME ---"
382+
cat $ASOUND_FILE_NAME
383+
echo "--- END $ASOUND_FILE_NAME ---"
384+
fi
385+
348386
echo "Command Line: ["$CMD_LINE"]"
349387

350388
if [[ $actual_user_mode -eq 1 ]]; then

doc/equalizer.md

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,6 @@ Look at [this](https://forums.lyrion.org/forum/user-forums/general-discussion/17
66

77
## Example configuration
88

9-
### Custom asound.conf file
10-
11-
Create a file (it's not required it to be at /etc/asound.conf), similar to the following:
12-
13-
```text
14-
ctl.equal {
15-
type equal;
16-
}
17-
18-
pcm.plugequal {
19-
type equal;
20-
slave.pcm "plughw:DAC";
21-
}
22-
23-
pcm.equal {
24-
type plug;
25-
slave.pcm plugequal;
26-
}
27-
```
28-
29-
Replace the line that says `slave.pcm "plughw:DAC"` with your dac information. You might need to set something like `slave.pcm "plughw:0"`, `slave.pcm "plughw:1,0"`. YMMV.
30-
Save the file as (e.g.) eq-asound.conf in the same directory where you are going to save your docker-compose.yaml file.
31-
329
### Compose file
3310

3411
A simple compose file should look like the following:
@@ -44,16 +21,16 @@ services:
4421
- PUID=1000
4522
- PGID=1000
4623
- AUDIO_GID=29
47-
- SQUEEZELITE_AUDIO_DEVICE=equal
24+
- SQUEEZELITE_EQ_AUDIO_DEVICE=plughw:CARD=DAC,DEVICE=0
4825
- SQUEEZELITE_NAME=Aune X1S
4926
- SQUEEZELITE_MODEL_NAME=Aune X1S Manjaro i5
5027
- SQUEEZELITE_SERVER_PORT=${SQUEEZELITE_SERVER_PORT:-}
51-
volumes:
52-
- ./eq-asound.conf:/etc/asound.conf:ro
5328
restart: unless-stopped
5429
```
5530

56-
I am using the typical values for PUID, PGID and AUDIO_GID. Again, this depends on your setup. Retrieve the id of the audio group using:
31+
There is no need to mount a custom file as `/etc/asound.conf`. The file is generated automatically.
32+
Tune the content of the variable `SQUEEZELITE_EQ_AUDIO_DEVICE` according to your audio device. Refer to the output of `aplay -l`.
33+
For PUID, PGID and AUDIO_GID, I am using typical values in my example. Again, this depends on your setup. Retrieve the id of the audio group using:
5734

5835
```text
5936
getent group audio

doc/release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Older build might be dropped in order to save space on docker-hub and incur in l
1010

1111
Date|Type|Description
1212
:---|:---|:---
13+
2025-06-30|Improvement|Complete support for alsa equalizer plugin, we do not require to create a custom asound.conf file anymore (see [#338](https://github.com/GioF71/squeezelite-docker/issues/338))
1314
2025-06-28|Improvement|Add support for alsa equalizer plugin (see [#338](https://github.com/GioF71/squeezelite-docker/issues/338))
1415
2025-06-26|Update|Sourceforge binaries version bump (see [#336](https://github.com/GioF71/squeezelite-docker/issues/336))
1516
2025-04-07|Update|Sourceforge binaries version bump (see [#334](https://github.com/GioF71/squeezelite-docker/issues/334))

0 commit comments

Comments
 (0)