hrtf

Head-Related Transfer Function processor for binaural spatial audio in Rust

Library
Cargo
v0.9.0
97stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
44/100Fair
Development Activity52
Maintenance8
Community36
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture78
Code Quality72
Innovation75
Learning Curve66

hrtf is a Rust crate that implements a Head-Related Transfer Function (HRTF) audio signal processor for rendering convincing binaural spatial sound. After a spatial sound source is processed through HRTF, a listener can clearly perceive the direction the sound is coming from, bringing 3D audio close to real-life perception.

The crate works with Head-Related Impulse Response (HRIR) spheres — triangulated meshes of 3D points, each carrying left- and right-ear spectra — and automatically resamples the 44.1 kHz reference data to your output sample rate. It performs the underlying FFT, convolution, and interpolation, and is used by the Fyrox game engine for spatial audio. It is released under the MIT license.

What You Get

  • A binaural HRTF renderer driven by HRIR sphere data
  • Automatic resampling of reference impulse responses to your sample rate
  • FFT-based convolution and interpolation between sphere points
  • Direction-aware processing for 3D positional audio

Common Use Cases

  • Adding realistic 3D positional audio to games over headphones
  • Rendering binaural spatial sound for VR and AR experiences
  • Building immersive audio tools that convey sound direction
  • Processing spatial sources within a game or audio engine

Under The Hood

Architecture - hrtf loads an HRIR sphere (a triangulated set of 3D points, each with left/right-ear spectra), then for a given source direction it finds the surrounding sphere points, interpolates their impulse responses, and convolves incoming samples via FFT to produce a binaural output pair. It resamples the 44.1 kHz base data to the target rate automatically.

Tech Stack - Pure Rust leveraging an FFT implementation for fast convolution and vector math for the sphere geometry; distributed as the hrtf crate on crates.io.

Code Quality - A focused, single-purpose crate with clear documentation of its algorithm, performance characteristics, and known limitations (e.g. audible clicks on very fast-moving sources); development has been inactive since 2023.

API Design - The API centers on constructing an HRTF processor from a sphere file and feeding it sample blocks with a source position, keeping the heavy DSP behind a small, purpose-built interface.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search