A native Rust/wgpu counterpart to the WebView audio-reactive FFT workflow: microphone capture, FFT and waveform analysis, beat detection, GPU analysis textures, and live audio-reactive graphics.
Microphone
↓ CPAL native capture
Mono sample ring
↓ RustFFT / analysis worker
FFT + waveform + bass/mid/treble + beat pulse
↓ shared analysis frame
RGBA8 spectrum / waveform textures
↓ wgpu / WGSL
Authoritative native render target
↓
Scaled native preview
The audio callback performs only sample conversion and bounded ring-buffer insertion. FFT work stays off the real-time audio callback.
This revision pins wgpu = 29.0.4 and uses the wgpu 29 CurrentSurfaceTexture / Queue::present surface API.
npm install
npm run dev
Two windows open:
0.00 rad/s. Rotation must stop. Positive and negative values must rotate in opposite directions.All modes consume the same native FFT and waveform textures while interpreting them differently.
Multiplies the captured mono signal before FFT and waveform analysis.
Temporal FFT smoothing. 0 follows new bins immediately; higher values retain more of the previous frame.
Compares current low-frequency energy against an adaptive low-frequency floor.
Minimum time between detected beats.
Scales the amount of spectral and band-energy displacement in the WGSL visual.
Actual angular velocity in radians per second:
0 = stoppedOffsets the procedural palette without changing the underlying FFT analysis.
The authoritative render target can be selected independently from the preview window:
Unsupported texture dimensions are disabled according to the adapter-reported limit. A selectable resolution is not a promise that the machine can sustain it at 60 FPS; use the renderer FPS and frame-time telemetry.
Changing preview presentation does not change the authoritative render target.
src-tauri/Info.plist contains NSMicrophoneUsageDescription. macOS should ask for microphone access on the first capture attempt. If access was denied previously, review System Settings → Privacy & Security → Microphone.
Ensure desktop applications are allowed to use microphone devices in Windows privacy settings.
CPAL normally uses ALSA on Linux. Development packages may be required:
sudo apt install libasound2-dev
PipeWire systems may expose devices through the ALSA compatibility layer.
The renderer receives:
256 × 1 RGBA8Unorm texture512 × 1 RGBA8Unorm textureThe textures are updated with queue.write_texture and sampled directly by WGSL.
Microphone permission, device availability, and external routing are environment-dependent. The generated signal lets the graphics pipeline remain inspectable before a microphone is connected. It is explicitly reported as an idle/demo state and does not masquerade as captured audio.
src/
index.html
styles.css
app.js
src-tauri/src/
main.rs Tauri commands and window lifecycle
audio.rs CPAL capture, sample ring, FFT, beat analysis
renderer.rs native wgpu renderer and analysis-texture upload
visuals.wgsl six audio-reactive visual modes
preview.rs native presentation sink
preview.wgsl fit/fill/stretch/pixel presenter
config.rs preview-mode contract
npm run build
Pinned to wgpu 29.0.4. Surface acquisition uses CurrentSurfaceTexture; successful frames are presented with SurfaceTexture::present(), which is the wgpu 29 presentation API.