Spatial audio test window with real-time playback based on click position.
MagicMouser is an interactive spatial audio demo that maps mouse clicks within a 2D window to binaural audio cues using KEMAR impulse responses. It enables intuitive exploration of spatial sound perception through a simple graphical interface, acting as a platform for experimentation, demonstration, and further development in 3D audio rendering.
🎓 This project is the culmination of a thesis in Applied Mathematics and Computer Science, aiming to bridge spatial audio rendering and real-time user interaction in a minimalist interface.
- 🚀 Real-time playback of spatialized audio
- 🖱️ Click-based directionality mapping
- 🌐 +300 unique directions simulated using KEMAR HRTFs
- 📏 Scalable window interface — input maps adaptively to direction
- 📦 Lightweight C implementation using
libsndfile,GLFW, andPipeWire/pw-play
-
Click Mapping:
-
The 2D window captures click coordinates.
-
These coordinates are mapped to azimuth and elevation:
- Azimuth: from -90° to +90°, sampled every 5°
- Elevation: from -40° to +40°, sampled every 10°
-
-
Impulse Selection:
- For each position, a corresponding stereo impulse response (IR) is selected from a precomputed dataset derived from KEMAR HRTFs.
-
Convolution and Playback:
- The selected IR is convolved with a mono audio sample.
- The result is saved as a stereo
.wavfile. - Playback is handled via
pw-play, a PipeWire tool for simple audio output.
- GCC (with support for sanitizers)
libsndfileGLFWPipeWire(withpw-playinstalled)
⚠️ Ensure PipeWire is running and your user has audio playback permissions.
make -j$(nproc)make runThen click anywhere inside the window to hear a spatialized version of the sound from that direction.
- Uses
-fsanitize=address,undefinedfor runtime safety - Use
make cleanto clear object files and binaries
Current implementation is Linux-only via pw-play. Planned expansions:
- 🎯 Cross-platform support (CoreAudio/macOS, WASAPI/Windows)
- 🎛️ In-app audio engine (remove
pw-playdependency) - 📡 Head-tracking support
- 🧠 Neural HRTF switching
- 🛠️ CLI for batch processing or remote trigger
magicmouser/
├── impulses/ # Impulse responses
├── main.c # Entry point
├── core.c # Audio processing
├── Makefile # Build system
├── noise.wav # Click sound
└── README.md # This file
A waveform comparison between original and convolved audio.
Future will includes:
- A diagram mapping azimuth/elevation to window coordinates
Playback is sandboxed via direct invocation (posix_spawn) of pw-play from /usr/bin/, avoiding unsafe shell evaluations. Future plans include embedding playback to reduce surface exposure.
This project is licensed under the GNU General Public License (GPL) version 3.0 or later. You are free to use, modify, and share this software under the terms of this license.
For more details, please refer to the LICENSE file in this repository or visit GNU GPL v3.
Daniel a.k.a. [iPowerWheels] — Punk engineer exploring audio spatiality and low-level computing. This project is dedicated to all the underground tech nerdZ who want to hear the world around them like never before.
Z-U in stereo 🎧

