Files
nandiandClaude Opus 5.5 f08f241edb
CI / check (push) Successful in 10s
CI / native (push) Successful in 1m39s
Add live peak meters (pavucontrol-style level bars)
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>
2026-11-22 16:33:12 -08:00

37 lines
979 B
MoonBit

// Peak meter display: maps a linear sample peak to the bar position and
// lets the bar fall back smoothly instead of flickering.
///|
/// How much of the full bar a falling meter drops per update (~25 updates
/// per second, so silence empties a full bar in about a second).
pub const METER_DECAY : Double = 0.04
///|
/// Bar position 0..1 for a linear peak. Uses the same cubic curve as the
/// volume sliders, so a full-scale signal at 50% volume shows at half the bar
/// and quiet sounds are still visible.
pub fn meter_level(linear_peak : Double) -> Double {
if linear_peak <= 0.0 {
0.0
} else if linear_peak >= 1.0 {
1.0
} else {
@math.cbrt(linear_peak)
}
}
///|
/// Next bar position: jump up at once, fall by at most METER_DECAY.
pub fn meter_step(shown : Double, level : Double) -> Double {
if level >= shown {
level
} else {
let fallen = shown - METER_DECAY
if fallen > level {
fallen
} else {
level
}
}
}