badaix / snapcast

Synchronous multiroom audio player
GNU General Public License v3.0
6.26k stars 457 forks source link

Equalizer option on client side #917

Open mincequi opened 3 years ago

mincequi commented 3 years ago

Because of differences of speakers and volumes, it is desirable to be able to equalize clients.

I am willing to prepare a pull request to realize this feature. I am also wondering if you are willing to accept third-party libraries (as git sub-modules). So, a lot of effort can be saved. There is a media/signal processing library wrote from my side, that could easily solve the task: https://github.com/mincequi/libcornrow

Looking forward to your feedback.

efung1232 commented 3 years ago

Use this command line to dump the PCM devices: aplay -L Here is my PCM devices: null Discard all samples (playback) or generate zero samples (capture) btaplay_dmix alsaequal plug_alsaequal btstream crossfeed plug_bs2b eqfa4p plug_eqfa4p invpolarity default:CARD=sndrpihifiberry snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0 Default Audio Device Then, you can run snapclient with equaliser as the command line below: snapclient --daemon --logsink=file:$LOGFILE -s eqfa4p

0x0lli commented 2 years ago

@efung1232: which eq did you install and how is that controlled? I just found this but htis appears to be for moOde audio: https://www.bitlab.nl/page_id=540

I am using snapcast on raspberry pi0, pi3 and pi4s that are either connected to merus12070p or hifiberry AMPs, so I would prefer a shell tool as I pipe spotify directly from the phone or PC onto the snapcast-server, I have no moOde or volumio running. alsaeq wouldn't work with snapcast-client the way described by hifiberry to use an EQ and I would love to know how you brought them to work https://www.hifiberry.com/docs/software/guide-adding-equalization-using-alsaeq/

Mr. Pete addressed this in https://github.com/badaix/snapcast/issues/424 but this doenst work for me as either the alsa-eq id isnt even shown via:

pi@pi0-DAC2Pro-AAMP60-nuVero5:~ $  lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@pi0-DAC2Pro-AAMP60-nuVero5:~ $  cat /proc/asound/modules
 0 snd_soc_hifiberry_dacplus
pi@pi0-DAC2Pro-AAMP60-nuVero5:~ $  cat /proc/asound/cards
 0 [sndrpihifiberry]: HifiberryDacp - snd_rpi_hifiberry_dacplus
                      snd_rpi_hifiberry_dacplus

or when it is

pi@pi0-DAC2Pro-AAMP60-nuVero5:~ $ snapclient -l

0: null
Discard all samples (playback) or generate zero samples (capture)
1: default
2: plugequal
3: equal
4: sysdefault:CARD=sndrpihifiberry
snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0
Default Audio Device
5: dmix:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0
Direct sample mixing device
6: dsnoop:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0
Direct sample snooping device
7: hw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0
Direct hardware device without any conversions
8: plughw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0
Hardware device with all software conversions

and I address it in /etc/default/snapclient to run via parameter "-s 2" I get an error:

ALSA lib control.c:1375:(snd_ctl_open_noupdate) Invalid CTL equal
cannot open mixer: No such file or directory
efung1232 commented 2 years ago

@0x0lli

I address it in /etc/default/snapclient to run via parameter "-s 2" I get an error Try " -s 3 " instead

Type "uname -a" in my reaspberry pi gets: Linux soundberry 5.10.11-v7l+ #1399 SMP Thu Jan 28 12:09:48 GMT 2021 armv7l GNU/Linux

which eq did you install and how is that controlled? "sudo apt-get download caps" gets caps_0.9.26-1_armhf.deb, so, you need to install caps to get EqFA4p; http://quitte.de/dsp/caps.html

cat /etc/alsa/conf.d/eqfa4p.conf : pcm.eqfa4p { type plug slave.pcm "plug_eqfa4p" }

pcm.plug_eqfa4p { type ladspa slave.pcm "plughw:0,0"; path "/usr/lib/ladspa"; plugins [ { id 2609 label EqFA4p input { controls [ 1 63 1 3 0 200 1 0 0 2000 1 0 0 11700 1 0 0 ] } } ] } the above config is for 3db gain at 63Hz (1 63 1 3); bass booster.

I use "aplay -L" to list the sound cards: null Discard all samples (playback) or generate zero samples (capture) btaplay_dmix alsaequal plug_alsaequal btstream crossfeed plug_bs2b eqfa4p plug_eqfa4p invpolarity default:CARD=sndrpihifiberry

snapclient -l gets 0: null Discard all samples (playback) or generate zero samples (capture) 1: btaplay_dmix 2: alsaequal 3: plug_alsaequal 4: btstream 5: crossfeed 6: plug_bs2b 7: eqfa4p 8: plug_eqfa4p 9: invpolarity 10: default:CARD=sndrpihifiberry snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0 Default Audio Device

my snapclient commands in shell script: /usr/bin/snapclient --daemon --logsink=file:$LOGFILE -s eqfa4p /usr/bin/snapclient --daemon --logsink=file:$LOGFILE -s alsaequal

I think the "equal" in the list of your sound cards is same as my alsaequal. You need to use command line to configure the graphical EQ.

cat /etc/alsa/conf.d/alsaequal.conf pcm.alsaequal { type plug slave.pcm "plug_alsaequal"; }

ctl.alsaequal { type equal controls "/usr/local/bin/alsaequal.bin"; }

pcm.plug_alsaequal { type equal slave.pcm "plughw:0,0"; controls "/usr/local/bin/alsaequal.bin"; }