Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.8.11 - 2026-11-16

- Adjust left/right balance with the Balance button next to the output
selector.
- Balance stays active during A/B Compare and remembers your setting across
presets and outputs. Mono outputs stay centered.

## 0.8.10 - 2026-10-29

- Remember the A/B Compare setting across restarts, including at login.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ sample rate; EQ processing is not pinned to 48 kHz.
- GTK/Libadwaita interface with a compact 10-band fader workflow.
- PipeWire routing and default-output tracking through pipewire-gobject.
- PipeWire filter-chain DSP using builtin biquad filters.
- Left/right **Balance** next to the EQ output selector follows output and preset
changes and stays active during A/B Compare. Mono outputs play centered and
Mini EQ restores your balance when you return to stereo.
- Optional spectrum analyzer and LUFS loudness readout through a PipeWire monitor
capture stream.
- Auto preset links can follow the detected PipeWire port when available and
Expand Down
12 changes: 10 additions & 2 deletions data/io.github.bhack.mini-eq.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,26 @@
</description>
<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/bhack/mini-eq/v0.8.10/docs/screenshots/mini-eq.png</image>
<image>https://raw.githubusercontent.com/bhack/mini-eq/v0.8.11/docs/screenshots/mini-eq.png</image>
<caption>Adjust sound output with equalizer controls</caption>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/bhack/mini-eq/v0.8.10/docs/screenshots/mini-eq-dark.png</image>
<image>https://raw.githubusercontent.com/bhack/mini-eq/v0.8.11/docs/screenshots/mini-eq-dark.png</image>
<caption>Use the equalizer with dark style</caption>
</screenshot>
</screenshots>
<url type="homepage">https://github.com/bhack/mini-eq</url>
<url type="bugtracker">https://github.com/bhack/mini-eq/issues</url>
<url type="vcs-browser">https://github.com/bhack/mini-eq</url>
<releases>
<release version="0.8.11" date="2026-11-16">
<description>
<ul>
<li>Adjust left/right balance with the Balance button next to the output selector.</li>
<li>Balance stays active during A/B Compare and remembers your setting across presets and outputs. Mono outputs stay centered.</li>
</ul>
</description>
</release>
<release version="0.8.10" date="2026-10-29">
<description>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mini-eq"
version = "0.8.10"
version = "0.8.11"
description = "Compact PipeWire system-wide parametric equalizer for Linux desktops."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
3 changes: 2 additions & 1 deletion src/mini_eq/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ def on_ready() -> None:

try:
if args.auto_route:
controller.route_system_audio(True, preserve_eq_state=True)
# Startup confirms the output before calling on_ready.
controller.route_system_audio(True, refresh_output=False, preserve_eq_state=True)
except Exception as exc:
exit_code = 1
print(str(exc), file=sys.stderr)
Expand Down
1 change: 1 addition & 0 deletions src/mini_eq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
EQ_Q_MAX = 6.0
EQ_PREAMP_MIN_DB = -24.0
EQ_PREAMP_MAX_DB = 6.0
OUTPUT_BALANCE_MAX = 100
PRESET_STORAGE_DIR: Path | None = None
OUTPUT_PRESET_LINKS_PATH: Path | None = None

Expand Down
56 changes: 56 additions & 0 deletions src/mini_eq/filter_chain.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import math

from .core import (
EQ_PREAMP_MAX_DB,
EQ_PREAMP_MIN_DB,
FILTER_TYPES,
MAX_BANDS,
OUTPUT_BALANCE_MAX,
OUTPUT_CLIENT_NAME,
SAMPLE_RATE,
VIRTUAL_SINK_DESCRIPTION,
Expand All @@ -20,6 +23,7 @@

BIQUAD_CONTROL_NAMES = ("b0", "b1", "b2", "a0", "a1", "a2")
BIQUAD_CONFIG_SAMPLE_RATES = (44100.0, 48000.0, 96000.0, 192000.0)
BALANCE_SMOOTHING_SECONDS = 0.004
NATIVE_BIQUAD_LABELS = {
FILTER_TYPES[name]: label
for name, label in {
Expand Down Expand Up @@ -67,8 +71,11 @@ def native_biquad_control_values(
preamp_db: float,
eq_enabled: bool,
sample_rate: float = SAMPLE_RATE,
*,
balance: int = 0,
) -> dict[str, float]:
controls = builtin_biquad_preamp_control_values(preamp_db, eq_enabled)
controls.update(balance_control_values(balance))
solo_active = bands_have_solo(bands)
for index, band in enumerate(bands[:MAX_BANDS]):
controls.update(native_biquad_band_control_values(index, band, eq_enabled, sample_rate, solo_active))
Expand Down Expand Up @@ -156,6 +163,49 @@ def preamp_node_name(side: str) -> str:
return f"preamp_{side}"


def balance_control_values(balance: int) -> dict[str, float]:
position = clamp(balance / OUTPUT_BALANCE_MAX, -1.0, 1.0)
return {
"balance_target_l:Add": 1.0 - max(0.0, position),
"balance_target_r:Add": 1.0 + min(0.0, position),
}


def balance_smoothing_coefficients(sample_rate: float) -> BiquadCoefficients:
# Filter the gain envelope at the audio sample rate. Its state carries over
# when the slider moves again, including a reversal before the gain settles.
decay = math.exp(-1.0 / (sample_rate * BALANCE_SMOOTHING_SECONDS))
return BiquadCoefficients(b0=1.0 - decay, b1=0.0, b2=0.0, a0=1.0, a1=-decay, a2=0.0)


def build_balance_stages(output_l: str, output_r: str, balance: int) -> tuple[str, str]:
nodes: list[str] = []
links: list[str] = []
controls = balance_control_values(balance)
by_rate = {rate: balance_smoothing_coefficients(rate) for rate in BIQUAD_CONFIG_SAMPLE_RATES}
for side, output in (("l", output_l), ("r", output_r)):
target = f"balance_target_{side}"
smooth = f"balance_smooth_{side}"
gain = f"balance_{side}"
nodes.extend(
(
f" {{ type = builtin name = {target} label = linear "
f"control = {{ Mult = 0 Add = {spa_float(controls[f'{target}:Add'])} }} }}",
build_biquad_node(smooth, by_rate),
f" {{ type = builtin name = {gain} label = mult }}",
)
)
links.extend(
(
f' {{ output = "{output}:Out" input = "{target}:In" }}',
f' {{ output = "{target}:Out" input = "{smooth}:In" }}',
f' {{ output = "{output}:Out" input = "{gain}:In 1" }}',
f' {{ output = "{smooth}:Out" input = "{gain}:In 2" }}',
)
)
return "\n".join(nodes), "\n".join(links)


def preamp_biquad_coefficients(preamp_db: float, eq_enabled: bool) -> BiquadCoefficients:
if not eq_enabled:
return identity_biquad_coefficients()
Expand Down Expand Up @@ -319,6 +369,7 @@ def build_builtin_biquad_filter_chain_module_args(
output_sink: str,
native_biquads: bool = False,
capture_as_stream: bool = False,
balance: int = 0,
) -> str:
graph_bands = bands[:MAX_BANDS]
band_count = len(graph_bands)
Expand All @@ -339,6 +390,11 @@ def build_builtin_biquad_filter_chain_module_args(
rate_property = "" if native_biquads else f" audio.rate = {int(SAMPLE_RATE)}\n"
output_l = biquad_node_name("l", output_index) if output_index is not None else preamp_node_name("l")
output_r = biquad_node_name("r", output_index) if output_index is not None else preamp_node_name("r")
if native_biquads:
balance_nodes, balance_links = build_balance_stages(output_l, output_r, balance)
nodes = f"{nodes}\n{balance_nodes}"
links = f"{links}\n{balance_links}" if links else balance_links
output_l, output_r = "balance_l", "balance_r"

return f"""{{
node.description = {pipewire_quote(VIRTUAL_SINK_DESCRIPTION)}
Expand Down
19 changes: 17 additions & 2 deletions src/mini_eq/pipewire_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
from collections.abc import Callable
from dataclasses import dataclass, field
from dataclasses import dataclass, field, replace
from typing import Any

from .pipewire_routes import DEVICE_ROUTE_PARAM_NAME, PipeWireOutputRoute, PipeWireRouteMixin
Expand All @@ -16,6 +16,7 @@
PIPEWIRE_NODE_INTERFACE = "PipeWire:Interface:Node"
PIPEWIRE_DEVICE_INTERFACE = "PipeWire:Interface:Device"
PIPEWIRE_LINK_INTERFACE = "PipeWire:Interface:Link"
PIPEWIRE_PORT_INTERFACE = "PipeWire:Interface:Port"
STREAM_OUTPUT_AUDIO = "Stream/Output/Audio"
AUDIO_SINK = "Audio/Sink"
LINK_STATE_ACTIVE = "active"
Expand Down Expand Up @@ -133,6 +134,14 @@ def parse_positive_int(value: str | None) -> int:
return parsed if parsed > 0 else 0


def audio_input_port_node_id(global_) -> int:
if not hasattr(global_, "is_interface") or not global_.is_interface(PIPEWIRE_PORT_INTERFACE):
return 0
if global_.dup_property("port.direction") != "in" or not global_.dup_property("audio.channel"):
return 0
return parse_positive_int(global_.dup_property("node.id"))


def parse_rate_from_latency(value: str | None) -> int:
if not value or "/" not in value:
return 0
Expand Down Expand Up @@ -991,7 +1000,13 @@ def move_named_output_stream_to_target(self, stream_node_name: str, target_node_
def audio_sink_by_name(self, node_name: str) -> PipeWireNode | None:
for sink in self.list_audio_sinks():
if sink.node_name == node_name:
return sink
# The registry can omit audio.channels on the sink itself. Count
# its current playback channels without including monitor ports.
ports = self._registry.dup_globals_by_interface(PIPEWIRE_PORT_INTERFACE)
channels = sum(audio_input_port_node_id(port) == sink.bound_id for port in self._iterate_model(ports))
return (
replace(sink, properties={**sink.properties, "audio.channels": str(channels)}) if channels else sink
)

return None

Expand Down
Loading
Loading