Add live peak meters (pavucontrol-style level bars)
CI / check (push) Successful in 10s
CI / native (push) Successful in 1m39s

Each row on Playback, Output Devices and Input Devices gets a level bar
under its slider. A meter is a small capture pw_stream on WirePlumber's
pw_core with the properties pipewire-pulse gives pavucontrol's peak
streams (stream.monitor, target.object, stream.capture.sink for sinks);
its process callback folds samples into a peak that a 40 ms GUI timer
reads, maps with the slider's cubic curve and decays smoothly.

- Only the visible tab is metered; output/stream meters are passive.
- stream.monitor nodes (ours and pavucontrol's) are hidden from the tabs.
- moonmix-probe gains `meter <id>`; the smoke test now plays noise and
  checks the stream and sink meters see it.
- Screenshot mode holds the meters still before capturing, since a
  constantly redrawing window never yields a frame under broadway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-11-22 16:33:12 -08:00
1 parent 92ae5cdbfe
commit f08f241edb
17 files changed
+503 -18

No files matched your search

+26 -1
View File
@@ -9,6 +9,8 @@
// moonmix-probe mute <id> <0|1>
// moonmix-probe default <id> make sink/source the default
// moonmix-probe move <stream> <dev> route a stream to a device
// moonmix-probe meter <id> peak level of a sink/source/playback
// stream over ~1.5 s (exit 6 if silent)
///|
extern "C" fn c_exit(code : Int32) = "exit"
@@ -99,6 +101,7 @@ fn main {
let argv = @env.args()
let args = if argv.length() > 1 { argv[1:].to_owned() } else { [] }
let state = @model.State::new()
let meter_id : Ref[Int32] = { val: -1, }
@wp.on_event(fn(ev) {
for e in @wp.to_model_events(ev) {
let _ = state.apply(e)
@@ -108,7 +111,20 @@ fn main {
Ready => @wp.timeout(300, 2)
Timeout(2) => {
print_state(state)
if args.length() > 0 {
if args is ["meter", id] {
let id = resolve(state, id)
let kind = match state.nodes.get(id) {
Some(n) => n.kind()
None => Other
}
meter_id.val = id
let ok = @wp.meter_start(id, kind)
println("== meter \{id}: \{if ok { "started" } else { "FAILED" }}")
if !ok {
c_exit(6)
}
@wp.timeout(1500, 3)
} else if args.length() > 0 {
let ok = act(state, args)
println(
"== action \{args.join(" ")}: \{if ok { "ok" } else { "FAILED" }}",
@@ -118,6 +134,15 @@ fn main {
@wp.quit()
}
}
Timeout(3) => {
let peak = @wp.meter_take(meter_id.val).unwrap_or(0.0)
println("== meter \{meter_id.val}: peak \{peak}")
@wp.meter_stop(meter_id.val)
if peak <= 0.0 {
c_exit(6)
}
@wp.quit()
}
Timeout(1) => {
print_state(state)
@wp.quit()