4

The facts below come from experience with Ubuntu 13.10 on a 64-bit laptop.

Context/problem: bad speakers

As many people know, laptop speakers have "highly unequal frequency response" as audio professional would say. Normal people say: "they sound very bad".

First-step solution: equalization

Equalizing provides a valuable workaround, dramatically improving sound quality with a one-time effort. For example, I installed PulseAudio Equalizer from Web Upd8.

For good results, equalization values should be chosen based on measurements, but that's another story (I could do it with Ubuntu alone though it's tricky, ask me for details).

Remaining problem: equalization curve is output-dependent

Equalization values are attached to the whole chain, though generally only the speakers are a major source of unequal response.

This means I have two equalization profiles:

  • one for laptop speakers (with wildly varying equalization curve)
  • another (much flatter curve, so disabling equalization is often acceptable) when an external stereo is plugged to e.g. a 3.5mm jack.

Current situation in practice: auto un/mute, good but insufficient

  • When plugging the 3.5mm jack to the external stereo, internal speakers are automatically muted and volume adjusted by the Ubuntu stack. This is good but insufficient.
  • When unplugging, internal speakers are automatically activated again. This is good but insufficient.

Improvement: not only auto-mute but auto-select eq curve

It would be much better to have the correct equalizer preset applied when un/plugging the 3.5mm jack. Plug the external stereo, the flat curve is selected. Unplug the stereo, internal speaker get their correction curve.


Questions

How to make a quick-and-dirty hack ? How to detect jack plug from a script ?

How to make a clean setup: assign the equalization curve to internal speaker, not just plug event.

For example, say I plug a USB audio device and play audio through it. The quick-and-dirty hack would change EQ curve whenever the 3.5mm jack is un/plugged, though the audio actually continued to go to the USB audio device not the internal speaker, making eq curve change irrelevant.

In a "clean" setup, an equalization profile would be cleanly assigned to the internal speaker, making the thing more robust. Whatever the situation, it would be always (and only) applied when needed.

Is anyone working on it ? Any hint ?

Thank you for your attention.

3

Because I have a similar problem i have made a "quick and dirty" python script which uses pulseaudio's DBus-Events to detect when to activate which equalizer profile.

Installation

To use it you have to add the following line to /etc/pulse/default.pa:

load-module module-dbus-protocol

Then disable the equalizer via pulseaudio-equalizer-gtk and click on "Apply settings", now close the GUI.

Download apply-equalizer.py save it somewhere and make it executable.

Execute it as user (!). Maybe you need to install some additional python modules. Also you may want to automatically start it on login (i dont know what is the best way to do that).

Usage

The script creates per-port [1] equalizer-configurations under ~/.config/apply-equalizer and symlinks them if a device changes the output port (i.e. headphones plugged in or out).

[1]: many sound cards have different ports, e.g. one speaker-port and one headphone-port

So:

  1. Unplug headphones.
  2. Open pulseaudio-equalizer GUI
  3. Customize equalizer-settings until it sounds good
  4. "Apply Settings" will then assign the configuration you made (including if the equalizer is enabled at all) to the current port (speakers in this case)
  5. close the GUI and repeat from step 2 for every port you want to assign (headphones not plugged in)

Now the equalizer settings get automatically adjusted whenever your switch between speakers and headphones.

| improve this answer | |
  • Great! I'll try that and report! Thanks for sharing. – Stéphane Gourichon Mar 10 '14 at 17:14
  • Here's what I did : instead of changing /etc/pulse/default.pa I changed ~/.config/pulse/default.pa. Then pactl exit then run script, and ... after a first "current device has no ports!" it worked! – Stéphane Gourichon Mar 10 '14 at 17:21
  • It works but only after a ActivePortUpdated event. Line executed at script start time port_addr = fb_sink.Get('org.PulseAudio.Core1.Device', 'ActivePort', dbus_interface=dbus.PROPERTIES_IFACE) fails every time. That's a great progress anyway ! – Stéphane Gourichon Mar 10 '14 at 17:32
  • You mean it first displays "current device has no ports!" but then if you trigger an ActivePortUpdated-Event it works? – Euro Mar 11 '14 at 1:35
  • 1
    i have made a github repo: github.com/nullEuro/apply-equalizer – Euro Mar 11 '14 at 13:01
1

Here a manual solution to switch between Equalizor ON (with your favorite settings) and OFF:

if [ "$(pulseaudio-equalizer status | grep "Equalizer status" | cut -d"[" -f2 | cut -d"]" -f1)" == "enabled" ]; then
    pulseaudio-equalizer disable
else
    pulseaudio-equalizer enable
fi

Save as a file as a bash script, create a new panel starter to by able to start the script directly from desktop or your menu panel.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.