ALSA equalizer not working

Hi all,
just recently discovered dietpi and in general I’m very very happy with it! So many tweaks and config options, I’m blazed!

This includes having the option to activate the alsa equalizer. I did id some time ago with rasperry pi os and there it’s a lot of work by hand.

So I configured and activated die Equalizer with dietpi-config. It did change something (volume went up) and I’m able to start alsamixer with equalizeroptions, but any change has no effekt.
Addionally, after a reboot, I cannot play anything.

E.g.

dietpi@DietPi:~ $ aplay piano2.wav
Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
ALSA lib pcm_params.c:2226:(snd1_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:1310: Broken configuration for this PCM: no configurations available

After disabling EQ, rebooting, sound is available again.

Summary: Activating is fine, sound still there, but changing EQ has no effect. After reboot, sound not available at all.

Any hints on that? Do you suggest any tests I should do ? Any idea where the problem may have it’s source?



Thank you!

MichaIng
can you have a look pls. usually you are the sound expert :wink:

Thanks, hope he can help me :slight_smile:

Forgot to post some details about the system itself:

 ─────────────────────────────────────────────────────
 DietPi v7.1.2 : 4 APT updates available
 ─────────────────────────────────────────────────────
 - Device model : RPi A+ (armv6l)

Status: No equalizer, sound is working:

dietpi@DietPi:~ $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
dmix:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample mixing device
dsnoop:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample snooping device
hw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Hardware device with all software conversions

There is only one difference when eq is on: Added a third line with “default”

To be sure, you use the onboard 3.5mm jack, right?

Can enable the equalizer and try the following:

> /var/lib/dietpi/dietpi-config/.alsaequal.bin # Clear equalizer settings
alsamixer -D eq # Adjust settings
ls -l /var/lib/dietpi/dietpi-config/.alsaequal.bin # Check whether this file is now not empty, hence settings have been stored

Yes, 3,5mm on-board jack.


you mean echo ?

 [b]echo [/b]> /var/lib/dietpi/dietpi-config/.alsaequal.bin # Clear equalizer settings

Tried echo, but mixer doesnt’t like it. rm did it.

So yes, file is getting created. Settings are persistent between two starts of alsamixer.
BUT: Any changes I make does not affect the sound…

I mean, I activate EQ, aplay fails. I deactivate it, aplay plays just fine.
Very strange…

file is an empty redirect, echo is not required for this but doesn’t hurt either :wink:.

Okay, please try the following:

cat << _EOF_ > /etc/asound.conf
ctl.eq {
	type equal
	controls "/var/lib/dietpi/dietpi-config/.alsaequal.bin"
}
pcm.plugequal {
	type equal
	slave.pcm {
		type plug
		slave.pcm {
			type hw
			card 0
			device 0
		}
	}
	controls "/var/lib/dietpi/dietpi-config/.alsaequal.bin"
}
pcm.!default {
	type plug
	slave.pcm plugequal
	slave.channels 2
}
ctl.!default {
	type hw
	card 0
}
_EOF_

OK, let’s just forget about my comment on the “missing” echo… :facepalm:


And for you asound.conf:
Yes, that absolutely did the trick! Everything is working.

What was the reason?
I see an added nesting of slave.pcm.

    slave.pcm {
        type plug
        slave.pcm {

Anyway, thank you!


If you are curious what I’m doing: I built a webradio, streaming with mplayer. You can also connect via airplay, radio stops as long as airplay is running. And for the mixer: I’ve a bass and treble box inside and doing a SW-frequency control for the loudspeakers :slight_smile:

Nice, I see the need for an equalizer then.

The type plug ALSA plugin does software conversion of channels, rate and format, when required for the sound card/driver. That is already used in the first place, as pcm.!default is type plug as well but in some cases it seems to be required (again) after the equalizer. I wonder if it would be possible like that as well to avoid having the conversion plugin two times in the pipe:

pcm.!default {
	type equal
	slave.pcm {
		type plug
		slave.pcm {
			type hw
			card 0
			device 0
		}
	}
	controls "/var/lib/dietpi/dietpi-config/.alsaequal.bin"
}

But the way you have it now matches the official instructions, and I’ll adjust our implementation accordingly: https://github.com/bassdr/alsaequal

EDIT:

Further reading in the repo:

sound card to output to, will probably have to be a plug since alsaequal only supports floating point numbers, a “plug” will convert the data type, outputig directly to hw won’t;

You will also probably need to pump the data through a plug to change the format to float, which is all alsaequal supports.

I lack insights about how the audio stream looks like but it seems like the equalizer supports only a specific format (floating point numbers) while the audio source might be in a different format and the sound card/driver requires a different format as well. So there needs to be a “plug” first to convert the audio source into floating point numbers and one afterwards to convert it into a format supported by the sound device. Sounds like a nasty overhead, but since it is the intended setup, it doesn’t seem to have a significant negative impact.

Solved with: https://github.com/MichaIng/DietPi/pull/4366
This also removes the fixed two channels which should now be based on audio source instead.

So I’m not sure if that should work out of the box, but if I try it does not work.

I stick now with your first solution which is now working for me :slight_smile:

Thanks again!

Sorry to bother you again, but shairport-sync won’t play. From verbose logging:

0.008741000 "audio_alsa.c:442" *warning: alsa: error -16 ("Device or resource busy") opening alsa device "default".

So I tried a bit:

# sudo -u shairport-sync aplay piano2.wav
aplay: main:828: audio open error: Operation not permitted



# sudo -u shairport-sync alsamixer

→ Works

# sudo -u shairport-sync amixer -D eq
amixer: Mixer attach eq error: Operation not permitted

→ not working

# groups shairport-sync
shairport-sync : shairport-sync audio

I may can let shairport-sync run as dietpi, but I think others will have the failure and I’m curious what it is.
My first guess was shairport-sync not in audio group, but that was fine from the beginning…


Thanks.

You mean the above config starting with

pcm.!default {
	type equal

does not work? That confirms my guess that incoming and outgoing streams must both be piped through a “type plug” plugin, which is also the solution I added to our code.

Hmm, has shairport-sync read access to the equalizer config?

sudo -u shairport-sync cat /var/lib/dietpi/dietpi-config/.alsaequal.bin
ls -al /var/lib/dietpi/dietpi-config

Hi,

Same trouble with non working Alsa equalizer.

Quite a difference anyway i use an usb FDA and play sound with raspotify and it works like a charm without eq

Already tried the code posted above, (switching from hw 0 to hw 1 in my case) into asound.conf.

and added OPTIONS= --device eq into the raspotify conf file.

No sound at all.

Have to disable eq with justboom to have it back.

Which config did you try exactly? That one worked: https://dietpi.com/forum/t/alsa-equalizer-not-working/5291/7

Hi,
I tested the one you quoted.

raspotify status is sending this :


mai 23 20:46:51 DietPi librespot[9529]:   17:   0x57b304 - <librespot_playback::
player::PlayerInternal as futures::future::Future>::poll::he6e04a5bccf94e34
mai 23 20:46:51 DietPi librespot[9529]:   18:   0x4df300 - futures::task_impl::s
td::set::hab1c1811473e3998
mai 23 20:46:51 DietPi librespot[9529]:   19:   0x4d5838 - std::sys_common::back
trace::__rust_begin_short_backtrace::h8286c5a0fd04a387
mai 23 20:46:51 DietPi librespot[9529]:   20:   0x4f04f4 - core::ops::function::
FnOnce::call_once{{vtable.shim}}::h76e6c7604d7daced
mai 23 20:46:51 DietPi librespot[9529]:   21:   0x91c940 - <alloc::boxed::Box<F>
 as core::ops::function::FnOnce<A>>::call_once::h6b7ad05f87ff90ae
mai 23 20:46:51 DietPi librespot[9529]:                        at /rustc/7eac88a
bb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
mai 23 20:46:51 DietPi librespot[9529]:   22:   0x91c940 - <alloc::boxed::Box<F>
 as core::ops::function::FnOnce<A>>::call_once::he9130e675b8d97ee
mai 23 20:46:51 DietPi librespot[9529]:                        at /rustc/7eac88a
bb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
mai 23 20:46:51 DietPi librespot[9529]:   23:   0x91c940 - std::sys::unix::threa
d::Thread::new::thread_start::h7a3f6590d8e03e95
mai 23 20:46:51 DietPi librespot[9529]:                        at /rustc/7eac88a
bb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys/unix/thread.rs:87

Hmm, does playing a local file via aplay (wav) or mpg123 (mp3) so work?

Yes it does work, eq too.

Seems to be raspotify librespot issue.

Maybe OPTIONS=–device eq is not the good thing to place into raspotify conf but leaving default settings doesn’t work either

The device is still called “default”. “eq” is only used by mixers to control the equalizer settings.

Ok, so there is nothing to change into raspotify conf ?
Already tried to leave it as it was.
Still no sound with it ans with the error posted previously.

It should work OOTB. The foreground audio interface is the same, only the middle- and back-end changed. You can try to use OPTIONS=–device=default explicitly, but that indeed should be default when nothing is set.

Can you try to remove slave.channels 2 from /etc/asound.conf? Not sure why we forced stereo in the past, I removed that part to have it based on the actual audio source. Probably that is already the issue Raspotify has, when source channels are not two.

Another thing, when you copy&paste the config. Is card 0 and device 0 actually the correct sound card?
Check the IDs via aplay -l.