ALSA equalizer not working Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
zackdvd
Posts: 8
Joined: Sun May 09, 2021 9:45 am

ALSA equalizer not working

Post by zackdvd »

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.

Code: Select all

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!
User avatar
Joulinar
Posts: 4783
Joined: Sat Nov 16, 2019 12:49 am

Re: ALSA equalizer not working

Post by Joulinar »

@MichaIng
can you have a look pls. usually you are the sound expert ;)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
zackdvd
Posts: 8
Joined: Sun May 09, 2021 9:45 am

Re: ALSA equalizer not working

Post by zackdvd »

Thanks, hope he can help me :-)

Forgot to post some details about the system itself:

Code: Select all

 ─────────────────────────────────────────────────────
 DietPi v7.1.2 : 4 APT updates available
 ─────────────────────────────────────────────────────
 - Device model : RPi A+ (armv6l)
Status: No equalizer, sound is working:

Code: Select all

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"
User avatar
MichaIng
Site Admin
Posts: 2987
Joined: Sat Nov 18, 2017 6:21 pm

Re: ALSA equalizer not working

Post by MichaIng »

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

Can enable the equalizer and try the following:

Code: Select all

> /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
zackdvd
Posts: 8
Joined: Sun May 09, 2021 9:45 am

Re: ALSA equalizer not working

Post by zackdvd »

Yes, 3,5mm on-board jack.


you mean echo ?

Code: Select all

 [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...
zackdvd
Posts: 8
Joined: Sun May 09, 2021 9:45 am

Re: ALSA equalizer not working

Post by zackdvd »

I mean, I activate EQ, aplay fails. I deactivate it, aplay plays just fine.
Very strange...
User avatar
MichaIng
Site Admin
Posts: 2987
Joined: Sat Nov 18, 2017 6:21 pm

Re: ALSA equalizer not working

Post by MichaIng »

> file is an empty redirect, echo is not required for this but doesn't hurt either ;).

Okay, please try the following:

Code: Select all

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_
zackdvd
Posts: 8
Joined: Sun May 09, 2021 9:45 am

Re: ALSA equalizer not working

Post by zackdvd »

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.

Code: Select all

    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 :-)
User avatar
MichaIng
Site Admin
Posts: 2987
Joined: Sat Nov 18, 2017 6:21 pm

Re: ALSA equalizer not working

Post by MichaIng »

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:

Code: Select all

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.
zackdvd
Posts: 8
Joined: Sun May 09, 2021 9:45 am

Re: ALSA equalizer not working

Post by zackdvd »

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 :-)

Thanks again!
Post Reply