#sound #binaural #transfer #signal #audio-samples #spatial

hrtf

HRTF (Head-Related Transfer Function) audio signal processor

9 releases (breaking)

0.8.1 Oct 17, 2023
0.8.0 Jan 22, 2022
0.7.0 Jul 29, 2021
0.6.0 Jan 10, 2021
0.2.0 Oct 12, 2020

#104 in Audio

Download history 2205/week @ 2024-07-19 2220/week @ 2024-07-26 2387/week @ 2024-08-02 2842/week @ 2024-08-09 2509/week @ 2024-08-16 2124/week @ 2024-08-23 2451/week @ 2024-08-30 2767/week @ 2024-09-06 2518/week @ 2024-09-13 3355/week @ 2024-09-20 3186/week @ 2024-09-27 2890/week @ 2024-10-04 3151/week @ 2024-10-11 3690/week @ 2024-10-18 4281/week @ 2024-10-25 3295/week @ 2024-11-01

14,987 downloads per month
Used in 17 crates (4 directly)

MIT license

39KB
716 lines

Head-Related Transfer Function (HRTF) audio signal processor.

Overview

HRTF stands for Head-Related Transfer Function and can work only with spatial sounds. For each of such sound source after it was processed by HRTF you can definitely tell from which location sound came from. In other words HRTF improves perception of sound to the level of real life.

HRIR Spheres

This crate uses Head-Related Impulse Response (HRIR) spheres to create HRTF spheres. HRTF sphere is a set of points in 3D space which are connected into a mesh forming triangulated sphere. Each point contains spectrum for left and right ears which will be used to modify samples from each spatial sound source to create binaural sound. HRIR spheres can be found here. HRIR spheres from the base are recorded in 44100 Hz sample rate, this crate performs automatic resampling to your sample rate.

Performance

HRTF is heavy, this is essential because HRTF requires some heavy math (fast Fourier transform, convolution, etc.) and lots of memory copying.

Known problems

This renderer still suffers from small audible clicks in very fast moving sounds, clicks sounds more like "buzzing" - it is due the fact that hrtf is different from frame to frame which gives "bumps" in amplitude of signal because of phase shift each impulse response have. This can be fixed by short cross fade between small amount of samples from previous frame with same amount of frames of current as proposed in here

Clicks can be reproduced by using clean sine wave of 440 Hz on some source moving around listener.

Algorithm

This crate uses overlap-save convolution to perform operations in frequency domain. Check this link for more info.

Dependencies

~3.5MB
~65K SLoC