A standalone Tauri 2 + Rust/wgpu example showing how native MIDI messages become reusable renderer parameters rather than hard-coded controller assignments.
MIDI device / virtual port
↓
midir callback
↓
Rust mapping registry
• MIDI learn
• channel + source matching
• min / max remapping
• inversion
• temporal smoothing
↓
normalized renderer state
• 8 scalar parameters
• 128 note velocities
• pitch bend
• channel pressure
↓
wgpu uniform + storage buffers
↓
Metal / Vulkan / DX12 surface
npm install
npm run dev:metal # macOS
Or let wgpu select the backend:
npm run dev
Other backend launchers:
npm run dev:vulkan
npm run dev:dx12
| Target | Normalized behavior |
|---|---|
| Hue | Color position from 0–1 |
| Zoom | Camera scale |
| Rotation | Full negative-to-positive rotation range |
| Field strength | Procedural field energy |
| Turbulence | Spatial distortion |
| Trail persistence | Note-release decay |
| Exposure | Output brightness/tone response |
| Pulse decay | Note-on flash duration |
The values remain normalized in the Rust registry. The WGSL shader converts them to useful renderer ranges. This keeps MIDI, OSC, automation, presets, and future input sources compatible with the same parameter contract.
MIDI learn accepts:
One learned mapping replaces the previous mapping for that target. The mapping table can then change:
The optional starter map demonstrates conventional assignments:
| MIDI source | Renderer target |
|---|---|
| CC 1 | Field strength |
| CC 7 | Exposure |
| CC 10 | Hue |
| CC 74 | Turbulence |
| Pitch bend | Rotation |
Use MIDI learn for devices that send different CC numbers or channels.
Save in browser stores the current mapping list in the controls WebView’s local storage. Load saved sends that list back into the Rust registry. This keeps the example self-contained and avoids adding filesystem permissions solely for a mapping demonstration.
midir uses CoreMIDI. For virtual ports:
midir uses the Windows multimedia MIDI services. Hardware and virtual ports should appear after Refresh.
midir uses ALSA. Debian/Ubuntu development builds generally require:
sudo apt install libasound2-dev
src-tauri/src/midi.rs
MidiInputConnection.MidiSnapshot for the renderer.src-tauri/src/renderer.rs
src-tauri/src/midi.wgsl
A fixed MIDI map is useful for one controller. A parameter registry is reusable infrastructure. The same normalized targets can later be driven by:
That makes this example the input-routing foundation for larger Junkpile instruments.