32 releases (breaking)

0.25.0 Sep 13, 2021
0.23.0 Jul 12, 2021
0.21.0 Mar 29, 2021
0.18.0 Dec 2, 2020
0.2.2 Nov 18, 2019

#104 in Game dev

Download history 8/week @ 2021-06-02 81/week @ 2021-06-09 22/week @ 2021-06-16 20/week @ 2021-06-23 30/week @ 2021-06-30 124/week @ 2021-07-07 101/week @ 2021-07-14 76/week @ 2021-07-21 176/week @ 2021-07-28 79/week @ 2021-08-04 166/week @ 2021-08-11 95/week @ 2021-08-18 99/week @ 2021-08-25 32/week @ 2021-09-01 116/week @ 2021-09-08 94/week @ 2021-09-15

365 downloads per month
Used in rg3d

MIT license

2MB
10K SLoC

rg3d-sound

Sound library for games and interactive applications written in Rust.

NOTE: even though this crate has rg3d prefix in its name, it can be used separately without any issues.

Key features

  • Generic and Spatial sound sources.
  • Built-in streaming for large sounds.
  • Raw samples playback support.
  • WAV format support (non-compressed).
  • Vorbis/ogg support (using lewton).
  • HRTF support for excellent positioning and binaural effects.
  • Reverb effect.

Examples

Examples can be found in ./examples. Make sure you run examples with --release flag, debug version is very slow and may cause tearing of output sound.

Supported OS

  • Windows (DirectSound)
  • Linux (alsa)
  • macOS (CoreAudio)
  • WebAssembly (WebAudio)

HRTF

This library has full HRTF support, it uses HRIR spheres generated using IRCAM HRIR database. HRIR spheres are produced using a small tool written in C++ - hrir_sphere_builder. It is very important to find HRTF that suits you because they're very individual and the overall perception is fully defined by the use of correct HRTF.

Contributions

Any contributions are very appreciated! Check the Issues page to see how can you help the project.

License

MIT

References

This library wouldn't have been ever created without work of these people. Thank you all!

  1. Digital signal processing and filters
  2. Physical Audio Signal Processing
  3. Hannes Gamper, "Head-related transfer function interpolation in azimuth, elevation, and distance", The Journal of the Acoustical Society of America 134, EL547 (2013); doi: 10.1121/1.4828983
  4. Fábio P. Freeland, Luiz W. P. Biscainho, Paulo S. R. Diniz, "Interpolation of Head-related transfer function (HRTFS): A Multi-source approarch"
  5. IRCAM Head-related impulse response database
  6. Reverb
  7. Overlap-add convolution - not used anymore due to significant distortions at segment boundary when impulse response changes.
  8. Overlap-save convolution - works much better when impulse response changes, there are only phase shift issues which are more or less acceptable.
  9. OpenAL Specification - distance models and general design considerations.
  10. http://csoundjournal.com/issue9/newHRTFOpcodes.html - some ideas to remove clicks in hrtf renderer
  11. https://phaidra.kug.ac.at/open/o:11024

Dependencies

~9.5MB
~190K SLoC