AUDIO
Source snapshot · 12 October 2026

Native UI messages, device settings and snapshots

The examples combine a local HTML editor, a main-thread Rust bridge and an independently owned audio callback. ui/mod.rs owns devices and JSON; ui/audio.rs owns prepared rendering.

Open the window without opening devices

The entry point selects Synth, Effect, MPE or MIDI 2.0 mode. ravet_webview::StandaloneWindow embeds the editor and its callbacks. The standard title-bar Audio/MIDI settings popup is enabled by default. Creating the window only enumerates settings; a Start action is required to open and play an output.

The MIDI 2.0 tab is an inspector. It creates and decodes packets but does not send them to an instrument or an external device.

Validate a page message

The bridge refuses messages larger than 4,096 bytes before parsing JSON. State::handle dispatches by message type. Synth and delay controls validate a candidate whole patch before committing UI state. MIDI input validates the short-message bytes. The inspector checks group, channel, key and full-resolution numeric bounds before constructing a typed packet.

Do not trust an HTML min/max attribute as validation: the Rust boundary checks again. The page's native bridge reports unavailability explicitly rather than silently accepting edits.

Start and stop audio

Starting stops the old owner, verifies the selected device's f32 channel/rate/buffer capabilities, validates selected channel pairs and opens at most 16 unique MIDI inputs. A selected audio input uses the clocked duplex adapter; output-only operation uses the output adapter.

The producer sends the prepared patch or delay controls before playback. Any setup or play failure triggers cleanup. Changing the example mode also stops audio. The page releases held on-screen notes when settings open, the mode changes or the window loses those interactions.

Refresh the display

The callback publishes word snapshots. State::snapshot reads the latest complete record and constructs JSON for controls, meters, voice expression, packets and settings. ravetUpdate updates controls without sending those refreshed values back as edits.

The editor walkthrough explains each HTML/JavaScript line, including keyboard ownership, pitch-bend encoding and the uniformly scaled 900×780 design canvas.