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.
How to make a quick-and-dirty hack ? How to detect jack plug from a script ?
Regarding detecting the plugging event. I could not find documentation on the web, plus the keyword "jack" returns results regarding the jack software suite, irrelevant here. Meager starting points: sound - How to automatically change volume level when un-/plugging headphones? - Ask Ubuntu Jack detection for audio : Blueprints : Ubuntu
Regarding changing the equalizer curve I could not find any documentation about
pulseaudio-equalizer-gtk. A proof-of-concept script fiddling with files then calling
pulseaudio-equalizer interface.applysettingscould change the settings, but the GUI wouldn't be aware.
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.
acpi_listen, but I have no idea how to implement that in a script of any language