Add per-laptop speaker tunings, starting with the XPS 14
Laptop speakers ship voiced by the vendor's Windows DSP layer, which Linux does not get. A tuning restores that as a PipeWire filter-chain in front of the internal speaker sink, matched to the machine by DMI string and expected sink. Adding a laptop is a directory under default/audio/tunings with two files and no new code: matching is data. The XPS 14 DA14260 tuning included here was derived by measuring the xps-audio-linux EasyEffects profile (MIT) and fitting a biquad chain to it, so no impulse response or other upstream asset is redistributed. It measures 1.24 dB RMS against that reference, and matches its dynamic range within 0.1 LU -- the reference's multiband compressor turned out to contribute nothing, so a linear chain replaces it. Bass Q is capped deliberately: a closer magnitude fit swung group delay 31 ms across 63-80 Hz, which smears bass transients. The graph runs as its own PipeWire client under its own config name rather than loading into the audio daemon. The daemon only reads its config at startup, so a daemon-loaded tuning could only be switched by restarting PipeWire -- which drops every PulseAudio client's connection, and applications that do not reconnect (Spotify) then have to be restarted by hand. Hosting it separately also contains failure, since a malformed tuning breaks only that service. Three things about the surrounding audio graph needed fixing for this to behave: - Volume must live downstream of the tuning. omarchy-audio-output-sink is now the single definition of which sink an output's volume really uses, shared by the volume keys, the output switcher's OSD and the audio panel, so they cannot disagree. It resolves the current default output, which keeps it correct when headphones are selected while a tuning exists. - The tuning's own output is a movable sink input, so rerouting "all streams" to a newly selected output would drag the processing onto headphones, or into the tuning's own sink, which is a cycle. It is pinned, and stream moves are limited to streams carrying an application.name. - The physical sink a tuning fronts is not independently selectable, since picking it would only bypass the tuning, so it is kept out of the output list. Applying happens at first-run, not finalize-user, because finalize-user also runs in the ISO chroot where there is no audio server and nothing would retry. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
248659de5a
commit
aa9f0c54c5
@@ -46,7 +46,11 @@ Panel {
|
||||
var list = []
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var n = nodes[i]
|
||||
if (n && n.isStream && isPlaybackStream(n)) list.push(n)
|
||||
if (!n || !n.isStream || !isPlaybackStream(n)) continue
|
||||
// A tuning's output is a playback stream too, but it is the processing
|
||||
// itself rather than an application, so it does not belong in the list.
|
||||
if (String(n.name || "").indexOf("omarchy_speaker_tuning") === 0) continue
|
||||
list.push(n)
|
||||
}
|
||||
return list
|
||||
}
|
||||
@@ -105,8 +109,39 @@ Panel {
|
||||
property var displayAudioSources: []
|
||||
property var displayAudioStreams: []
|
||||
|
||||
readonly property real outputVolume: sink && sink.audio ? sink.audio.volume : 0
|
||||
readonly property bool outputMuted: sink && sink.audio ? sink.audio.muted : false
|
||||
// A DSP sink -- a speaker tuning, or EasyEffects -- can be the selected output
|
||||
// without being where loudness lives: changing its volume alters the level going
|
||||
// *into* the processing, so the slider would move while the speakers did not,
|
||||
// and on a chain with a limiter it would change the tone as well.
|
||||
//
|
||||
// omarchy-audio-output-sink resolves the *current* default output through any
|
||||
// such sink to the physical one, which is the same definition the volume keys
|
||||
// and the output switcher use. Resolving the default (rather than "whatever a
|
||||
// tuning fronts") is what keeps this correct when headphones or HDMI are
|
||||
// selected while a tuning still exists.
|
||||
property string volumeSinkName: ""
|
||||
|
||||
readonly property var volumeSink: {
|
||||
if (volumeSinkName === "" || !sink) return sink
|
||||
if (volumeSinkName === String(sink.name)) return sink
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var n = nodes[i]
|
||||
if (n && n.isSink && !n.isStream && String(n.name) === volumeSinkName && n.audio)
|
||||
return n
|
||||
}
|
||||
return sink
|
||||
}
|
||||
|
||||
// Re-resolve whenever the selected output changes; the timer below is only a
|
||||
// safety net for the tuning being applied or removed underneath us.
|
||||
onSinkChanged: resolveVolumeSink()
|
||||
|
||||
function resolveVolumeSink() {
|
||||
if (!volumeSinkProc.running) volumeSinkProc.running = true
|
||||
}
|
||||
|
||||
readonly property real outputVolume: volumeSink && volumeSink.audio ? volumeSink.audio.volume : 0
|
||||
readonly property bool outputMuted: volumeSink && volumeSink.audio ? volumeSink.audio.muted : false
|
||||
readonly property real inputVolume: source && source.audio ? source.audio.volume : 0
|
||||
readonly property bool inputMuted: source && source.audio ? source.audio.muted : false
|
||||
|
||||
@@ -377,7 +412,7 @@ Panel {
|
||||
|
||||
function setOutputVolume(v) {
|
||||
if (!sink || !sink.audio) return
|
||||
sink.audio.volume = Math.max(0, Math.min(1, v))
|
||||
volumeSink.audio.volume = Math.max(0, Math.min(1, v))
|
||||
}
|
||||
|
||||
function setInputVolume(v) {
|
||||
@@ -386,7 +421,7 @@ Panel {
|
||||
}
|
||||
|
||||
function toggleOutputMute() {
|
||||
if (sink && sink.audio) sink.audio.muted = !sink.audio.muted
|
||||
if (volumeSink && volumeSink.audio) volumeSink.audio.muted = !volumeSink.audio.muted
|
||||
}
|
||||
|
||||
function toggleInputMute() {
|
||||
@@ -525,6 +560,15 @@ Panel {
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: volumeSinkProc
|
||||
command: ["omarchy-audio-output-sink"]
|
||||
stdout: StdioCollector {
|
||||
waitForEnd: true
|
||||
onStreamFinished: root.volumeSinkName = String(text).trim()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 5000
|
||||
running: root.opened
|
||||
@@ -533,6 +577,17 @@ Panel {
|
||||
onTriggered: if (!sinkAvailabilityProc.running) sinkAvailabilityProc.running = true
|
||||
}
|
||||
|
||||
// Runs whether or not the panel is open: the bar shows and scrolls the output
|
||||
// volume too, so an unresolved sink there would read and change the virtual
|
||||
// tuning sink instead of the speakers.
|
||||
Timer {
|
||||
interval: 15000
|
||||
running: true
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: root.resolveVolumeSink()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: audioModelRefreshTimer
|
||||
interval: 75
|
||||
|
||||
Reference in New Issue
Block a user