tawasuyu

tawasuyu/llimphi

Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.

Rust 660Markdown 302TOML 157RON 312382 Definiciones

⎇ main widgets/waveform/README.md Markdown · 44 líneas · 2.0 KB Historia crudo

chore: refresco desde el monorepo — 27 crates nuevos (anim, lottie, svg, mesh, image, layer, test, wire-view, widgets rag-sidebar/router/lazy-list/rive-button) y sync de los 95 existentes 93253cc22 · Sergio ·

1# llimphi-widget-waveform
2
3**Live waveform** viewer.
4
5The pattern is analogous to `llimphi-widget-timeline`: the widget keeps **no
6audio state** (no cpal, no `AudioProbe`, no ring buffer). The caller passes a
7`Fn(&mut Vec<f32>) -> u16` closure that fills a buffer with the latest samples
8and returns how many **interleaved channels** it carries; the widget folds to
9mono and draws a **min/max envelope per column** (a closed polygon with a faint
10fill plus a stroke above and below) over a **centre line** always present as the
11viewer's "ground". No mouse handlers — paint only.
12
13```text
14  ┌─────────────────────────────────────────────────┐
15  │   ▄▄▄    ▄  ▄▄▄  ▄▄    ▄▄  ▄                    │
16  │  ▄███▄  ▄█▄▄███▄▄██▄▄▄▄██▄▄█▄                   │
17  │──█████──███████████████████████─── centre ──────│
18  │  ▀███▀  ▀█▀▀███▀▀██▀▀▀▀██▀▀█▀                   │
19  │   ▀▀▀    ▀  ▀▀▀  ▀▀    ▀▀  ▀                    │
20  └─────────────────────────────────────────────────┘
21```
22
23Typical use (a player with an audio probe):
24
25```ignore
26use std::sync::Arc;
27let probe = audio_probe();        // the app's own Arc<AudioProbe>
28let palette = WaveformPalette::default();
29waveform_view(
30    move |out| {
31        let (_sr, ch) = probe.snapshot(out);
32        ch                         // interleaved channels
33    },
34    &palette,
35)
36```
37
38If the closure returns `0` channels (or does not fill the buffer), the widget
39paints only the centre line — useful to show "viewer alive, no signal" while the
40capture device has not come up yet.
41
42---
43
44Part of **llimphi** — see [llimphi](../../README.md).

README.md

llimphi-widget-waveform

Live waveform viewer.

The pattern is analogous to llimphi-widget-timeline: the widget keeps no audio state (no cpal, no AudioProbe, no ring buffer). The caller passes a Fn(&mut Vec<f32>) -> u16 closure that fills a buffer with the latest samples and returns how many interleaved channels it carries; the widget folds to mono and draws a min/max envelope per column (a closed polygon with a faint fill plus a stroke above and below) over a centre line always present as the viewer's "ground". No mouse handlers — paint only.

  ┌─────────────────────────────────────────────────┐
  │   ▄▄▄    ▄  ▄▄▄  ▄▄    ▄▄  ▄                    │
  │  ▄███▄  ▄█▄▄███▄▄██▄▄▄▄██▄▄█▄                   │
  │──█████──███████████████████████─── centre ──────│
  │  ▀███▀  ▀█▀▀███▀▀██▀▀▀▀██▀▀█▀                   │
  │   ▀▀▀    ▀  ▀▀▀  ▀▀    ▀▀  ▀                    │
  └─────────────────────────────────────────────────┘

Typical use (a player with an audio probe):

use std::sync::Arc;
let probe = audio_probe();        // the app's own Arc<AudioProbe>
let palette = WaveformPalette::default();
waveform_view(
    move |out| {
        let (_sr, ch) = probe.snapshot(out);
        ch                         // interleaved channels
    },
    &palette,
)

If the closure returns 0 channels (or does not fill the buffer), the widget paints only the centre line — useful to show "viewer alive, no signal" while the capture device has not come up yet.


Part of llimphi — see llimphi.