Enabling Equalizer on Handsfree Sending Audio with ALSA equal plugin


This post shows steps to enable equalizer on Bluetooth handsfree (HFP) sending audio by using ALSA equal plugin.

 

Contents
– Prerequisites
– Steps
1. Equalizer Plugin Installation
2. ALSA Configuration
3. PulseAudio Configuration
4. Connect your phone and make a call
5. Adjust equalizer
– Reference

 

Prerequisites
Bluetooth Handsfree profile needs to be enabled first. If it’s not done yet, please refer this post.

 

Steps
1. Equalizer Plugin Installation

 

2. ALSA Configuration
2-1. Load the kernel module of ALSA loopback device.

The following command enables the module at boot time,

2-2. Create .asoundrc.

2-3. Add the lines below, save and close the file.

1-4. Reload .asoundrc by entering the command below:

 

3. PulseAudio Configuration
3-1. Launch PulseAudio if it’s not running yet.

3-2. Add modules and set default source as below:

 

4. Connect your phone and make a call
4-1. Connect your phone via bluetooth by using bluetoothctl.

4-2. Make a call by using your phone, or oFono.

 

5. Adjust equalizer
Now adjust the equalizer by using alsamixer command and listen the audio on the far-end.

 

Reference
– Redirect an audio stream with aloop
https://blog.getreu.net/projects/snd-aloop-device/body.html

 

 

One Comment

  1. Hello Max!

    First, I want to thank you for teaching us this thing, you have a good knowledge and knows how to write in a simple and complete way. I’ve used your HSP/HFP with Bluetooth and Raspberry + oFono to make and receive calls, it works perfectly. Many places over the internet do show how to setup components, but you made it all in one place, which helps a lot.

    Now, talking about this tutorial, I’ve tried it but no success. I mean, there is no error in the process, I can open the alsamixer -D equal and it shows that screen with frequency controls, but changing them make no difference in sound being played.
    The first problem I’ve got was the .asoundrc file, in the /home/pi/.asoundrc (or simply ~/.asoundrc). Any changes that I made in that file was, for some reason, overwritten with some default values (pcm!default type hw and card 1). This problem I solved by disabling the “auto” audio routing, in advanced settings by calling “sudo raspi-config”.
    The second problem was with the Loopbacks. By looking only at “aplay -l” or “pactl list devices(?) short” It’s not clear to see what is hooked to what, then I installed pavucontrol. There you can see all the Loopback devices and from who they are sinking and to who they are sourcing.

    Before I try your post, with ALSA Equal, I’ve tried to use pulseaudio-equalizer module, altogether with module-dbus. And none worked. Now, I’ve tried both, and it works!
    My final solution involved all the steps you provided plus some settings: First I need to load module-dbus and module-equalizer-sink into pulseaudio, with the “pactl load-module” command. Then, after that, I went to pavucontrol and did the following: The audio which has been captured in the “record” tab, in the Bluetooth device input control, was been captured from my phone (if music is playing, the bar keeps moving accordingly) and sent out directly to my USB audio card (the reason why equalizers didn’t work), so I set it to send to the Loopback Analog Input. Then, in other control in the same tab, I had another Loopback which was capturing sound from itself, which made no sense to me, I changed it to capture from the other Loopback, the Analog input (entry point). And finally, my USB Card Loopback, that was also capturing from the first Bluetooth device, I changed to the second Loopback (just loopback). The final layout was something like this:
    BT Device > Loopback Analog Input > Loopback > USB Card. By doing this, I had my audio being equalized.
    But I keep testing, and found another solution, I don’t know yet if it works without the loopbacks, but I will try. The pulseaudio-equalizer that I’ve tried before (by opening “qpaeq”), also didn’t change the audio stream. But trough pavucontrol I have a new option. I can source my USB Card from a device called FFT and sink this same FFT from my BT device, such like this: BT Device > FFT Virtual Device > USB Card. Then with this, I can use the “qpaeq”, which opens a graphical, better, interface to control equalization and works too. Now it just bugs me because it quickly cuts audio every few seconds, its annoying after some time. And it seems to lower the audio quality.
    Thats all for now. I’ll check and if I have any news, I’ll post here again.

Leave a Reply

Your email address will not be published. Required fields are marked *