Add cross-platform system volume control with linear amplification mapping

- New mediahive/volume_control.py module controls master volume on
  Windows (IAudioEndpointVolume via ctypes), macOS (osascript), and
  Linux/PipeWire (wpctl).
- UI slider x in [0, 1.5] maps to linear amp via:
    amp = 0.02*x            if x < 0.1
    amp = (exp(6*x)-1)/402.42879349  otherwise
- PipeWire supports >100% amplification natively (up to x=1.5).
- Windows and macOS clamp at x=1.0 (100%) since their system mixers
  do not support amplification above unity.
- Gamepad D-pad up/down now controls system volume in 0.01 steps.
- JsApi exposes set_volume(), get_volume(), and volume_max() for the
  frontend to query platform limits and control volume directly.
- No external dependencies: uses ctypes on Windows, subprocess on
  Linux/macOS. No PulseAudio fallback.
- Add ruff ignore rules for ctypes COM boilerplate patterns.
This commit is contained in:
2026-05-29 18:21:18 +00:00
parent cac3348ec1
commit 359ca0c5b4
3 changed files with 508 additions and 4 deletions
+8
View File
@@ -107,4 +107,12 @@ ignore = [
"D415",
"D400",
"ANN401",
# Allow en-dash in docstrings (used for list formatting)
"RUF002",
# Allow ctypes COM variable names (CLSID_*, IID_*, etc.)
"N806",
# Allow inline comments that describe output formats
"ERA001",
# Allow unused local variables in ctypes COM boilerplate
"F841",
]