NixOS / nixos-hardware

A collection of NixOS modules covering hardware quirks.
Creative Commons Zero v1.0 Universal
2.08k stars 641 forks source link

framework: Add `hardware.framework.laptop13.audioEnhancement` option #1253

Closed miketth closed 1 week ago

miketth commented 1 week ago
Description of changes

This PR adds the hardware.framework.laptop13.audioEnhancement option, which adds filters that enhance the audio coming from the laptop speakers. This config yields vastly enhanced audio, including much better bass.

These techniques are heavily inspired by the Asahi project's asahi-audio repo and contains an equalizer transformed from the "Lappy McTopface" preset from ee-framework-presets (both MIT-licensed).

I am unsure about putting the option under hardware.framework.laptop13, but this applies to Framework Laptop 13, but not the 16 and there wasn't an existing option for this subset.

I had this in my personal config for quite a bit of time, but decided to upstream it, in case it helps others. It isn't perfect by all means, but it makes the speakers sound much better than their defaults.

Things done
Mic92 commented 1 week ago

@mergify queue

mergify[bot] commented 1 week ago

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at *672ac2ac86f7dff2f6f3406405bddecf960e0db6*
leo60228 commented 6 days ago

I tested this on my device and the filtering is also applied to headphones, which doesn't seem like the expected behavior.

Mic92 commented 5 days ago

@miketth @leo60228 any idea how to avoid this? Are you using the headphone jack? I mostly do bluetooth headphones, so I missed that bit.

marcan commented 5 days ago

See the most recent commit to asahi-audio, that avoids having to use the automatic PipeWire node name. You need to target the specific device you want to use as the raw device in the matcher, which can be done via multiple property matches.

However, that depends on at least the PCM being different. If this is one of those setups where the ALSA PCM for speakers and headphones is the same and it just switches in hardware (or driven by software/UCM) on jack hotplug (do those exist still? I thought most modern machines had separate PCMs) then I have no idea how you'd fix it. If it's HDA then hopefully separate PCMs at least exist and it should be possible to write a UCM config to drive them independently instead of muxing a single PCM.

leo60228 commented 5 days ago

The instructions from https://github.com/luisbocanegra/linux-guide-split-audio-ports seem to work to split it into separate PCMs, but are quite a few steps.

leo60228 commented 5 days ago

I'm not sure this is the best solution for nixos-hardware, but I added this to my personal configuration: https://github.com/leo60228/dotfiles/commit/d8edbb9871c73be79761a3220706bb03678472f4

leo60228 commented 4 days ago

Using UCM instead of ACP seems to have the side effect of making headphones and speakers appear as separate PipeWire nodes, even though it doesn't change that they use the underlying PCM. This patch achieves this, though I'm not sure it should be upstreamed: https://github.com/leo60228/alsa-ucm-conf/commit/616f1eb856149047e642d58ea2a03bbdc92631f0

(Instead of rebuilding the world, you can override the path to the ucm2 folder with the ALSA_CONFIG_UCM2 environment variable. This does not appear to be mentioned in documentation.)

miketth commented 2 days ago

Sorry, I missed that part completely as I don't use the headphone jack either... I'll look into this soon-ish, but if I don't find anything cleaner, it might be the best to go with the solution from @leo60228

Mic92 commented 2 days ago

If the audio configuration becomes more complex than this, it might be worth considering starting a new project. Audio filters and equalizer is a bit of a different skill set from what we usually have in nixos-hardware. It would be cool to host these profiles in a separate repository and maybe reference them here? Just my thoughts, nothing set in stone.

Titaniumtown commented 2 days ago

Cool stuff! I did this myself using easyeffects: https://git.gardling.com/titaniumtown/dotfiles/src/commit/555a049637da8d679e0f5712f366e19a976ddd16/home-manager/progs/framework-13-easyeffects.nix

I'll switch over to doing it through nixos-hardware. glad to see other people found this useful.

EDIT: This doesn't work at all and I get no audio output :( I'm on a framework 13 12th gen intel

taha-yassine commented 2 days ago

EDIT: This doesn't work at all and I get no audio output :( I'm on a framework 13 12th gen intel

It worked for me after a reboot.

Titaniumtown commented 2 days ago

Rebooting also didn't fix it :(