mochi
Overview
Windows system-tray app that plays real mechanical keyboard switch sounds as you type. Ultra-low-latency audio, 12 switch profiles, global hotkey, and a self-extracting ~17 MB installer.
Problem
Mechanical keyboard enthusiasts want authentic switch sounds while typing, but existing apps (Mechvibes) are unmaintained, bloated, or require Electron-level overhead. Users want a lightweight, low-latency system-tray app with multiple switch profiles and zero configuration.
Approach
Built a single-file C++17 Win32 app (~1.5 MB) that captures global keyboard/mouse input via Raw Input API and plays real mechanical switch audio through miniaudio's WASAPI backend. 12 switch profiles with real recorded audio. Runs silently in the system tray with a context menu for control.
Architecture
Win32 GUI app (no console) with four core modules: InputManager (Raw Input API capture with key-repeat suppression), AudioEngine (miniaudio voice pooling with round-robin, load-on-demand profiles), Config (JSON persistence to %APPDATA%, atomic writes, legacy migration), and TrayMenu (system tray context menu with profile switching, volume, mute). Optional webview-based settings UI built with Svelte 5. Python scripts generate C++ headers from profile config and synthesize mouse click sounds.
Challenges
Ultra-low-latency audio required WASAPI backend with voice pooling to prevent cutoff on rapid key presses. Two sound pack formats (single file with offset/duration vs per-key files) handled transparently. Global input capture via RIDEV_INPUTSINK with GetAsyncKeyState fallback for missed key-ups. Single-instance enforcement via named mutex. Self-extracting installer searches own binary for appended ZIP payload by scanning backwards for EOCD signature.
Results
A ~1.5 MB system-tray app with 12 mechanical switch profiles, 4 mouse click packs, global hotkey (Ctrl+Shift+M), per-profile volume, and runtime profile reloading. Self-extracting installer is ~17 MB including all sound packs.