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>
This commit is contained in:
1 parent
92ae5cdbfe
commit
f08f241edb
17 files changed
+503
-18
No files matched your search
+22
-1
@@ -7,6 +7,7 @@
|
||||
* widgets programmatically (mm_gtk_set_*), callbacks are suppressed so model
|
||||
* updates never echo back into PipeWire.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "moonbit.h"
|
||||
@@ -314,6 +315,22 @@ MOONBIT_FFI_EXPORT void mm_gtk_dropdown_set(GtkWidget *dd,
|
||||
g_suppress--;
|
||||
}
|
||||
|
||||
/* Thin 0..1 level bar for peak meters, without GTK's low/high/full colour
|
||||
* offsets (a quiet signal is not a warning). */
|
||||
MOONBIT_FFI_EXPORT GtkWidget *mm_gtk_levelbar_new(void) {
|
||||
GtkWidget *lb = gtk_level_bar_new_for_interval(0.0, 1.0);
|
||||
GtkLevelBar *l = GTK_LEVEL_BAR(lb);
|
||||
gtk_level_bar_remove_offset_value(l, GTK_LEVEL_BAR_OFFSET_LOW);
|
||||
gtk_level_bar_remove_offset_value(l, GTK_LEVEL_BAR_OFFSET_HIGH);
|
||||
gtk_level_bar_remove_offset_value(l, GTK_LEVEL_BAR_OFFSET_FULL);
|
||||
gtk_widget_set_hexpand(lb, TRUE);
|
||||
return lb;
|
||||
}
|
||||
|
||||
MOONBIT_FFI_EXPORT void mm_gtk_levelbar_set(GtkWidget *lb, double v) {
|
||||
gtk_level_bar_set_value(GTK_LEVEL_BAR(lb), v);
|
||||
}
|
||||
|
||||
/* ---- generic widget properties ------------------------------------------ */
|
||||
|
||||
MOONBIT_FFI_EXPORT void mm_gtk_widget_set_tooltip(GtkWidget *w,
|
||||
@@ -356,8 +373,10 @@ MOONBIT_FFI_EXPORT void mm_gtk_widget_set_valign_center(GtkWidget *w) {
|
||||
MOONBIT_FFI_EXPORT int32_t mm_gtk_save_png(GtkWidget *w, moonbit_bytes_t path) {
|
||||
int width = gtk_widget_get_width(w), height = gtk_widget_get_height(w);
|
||||
GtkNative *native = gtk_widget_get_native(w);
|
||||
if (width <= 0 || height <= 0 || !native)
|
||||
if (width <= 0 || height <= 0 || !native) {
|
||||
fprintf(stderr, "moonmix: save_png: not realized (%dx%d)\n", width, height);
|
||||
return 0;
|
||||
}
|
||||
GdkPaintable *paintable = gtk_widget_paintable_new(w);
|
||||
GtkSnapshot *snap = gtk_snapshot_new();
|
||||
gdk_paintable_snapshot(paintable, snap, width, height);
|
||||
@@ -368,6 +387,8 @@ MOONBIT_FFI_EXPORT int32_t mm_gtk_save_png(GtkWidget *w, moonbit_bytes_t path) {
|
||||
graphene_rect_t bounds = GRAPHENE_RECT_INIT(0, 0, width, height);
|
||||
GdkTexture *tex = gsk_renderer_render_texture(r, node, &bounds);
|
||||
ok = gdk_texture_save_to_png(tex, s(path));
|
||||
if (!ok)
|
||||
fprintf(stderr, "moonmix: save_png: writing %s failed\n", s(path));
|
||||
g_object_unref(tex);
|
||||
gsk_render_node_unref(node);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user