GithubHelp home page GithubHelp logo

mrdimas / hrir_sphere_builder Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 2.0 85.54 MB

Tool to create sphere from IRCAM HRIR database

License: MIT License

C 42.94% C++ 52.91% Batchfile 4.15%
hrir hrtf ircam auralization

hrir_sphere_builder's Introduction

HRIR Sphere Builder

Special tool to make HRIR sphere mesh from IRCAM http://recherche.ircam.fr/equipes/salles/listen/download.html base.

Pre-built database

I already converted all IRCAM database entries, you can find them in hrtf_base/IRCAM - just pick any of *.bin files. Description of each can be found in link up above.

Usage

hrir_sphere_builder <directory_path>

Output file will have this name: directory_name.bin and will be placed in parent directory of directory_path.

Why it is needed?

HRIR database sampled at fixed angles - in case of IRCAM it has 15 degress azimuthal resolution and variable elavation resolution. Such fact gives annoying "jumping" effect of sound source spatial positioning. Resolution can be effectively increased by interpolation of HRIR's from three closest points for given source's azimuth and elevation. Working in spherical coordinates is error prone and may lead to various bugs, to bypass this we can use cartesian coordinate system. To be able to work in cartesian coordinates we need to know triangulated surface of a HRIR sphere so we can find a triangle which is intersected by ray from listener to sound source position. Once we have a triangle, we can use barycentric coordinates of a ray's intersection point to get weights for interpolation.

How it works?

The tool reads file-by-file from database and extracts azimuth and elevation from file name, then tool translates spherical coordinates to cartesion and adds hrir point to point cloud. Each file contains head-related impulse response for left and right ears. Each channel gets converted into array of floats in [0; 1] range (normalized range). After all points were created, tool creates convex hull using these points. Finally, triangulated hrir sphere saved to disk.

File format

The tool produces binary file, first goes header:

Field Size Type Value
magic 4 uint32_t HRIR
sample_rate 4 uint32_t
length 4 uint32_t
vertex_count 4 uint32_t
index_count 4 uint32_t

Then goes indices:

Field Size Type
Indices 4 * index_count uint32_t

Finally goes vertex_count vertices, each vertex has this format:

Field Size Type
X 4 float
Y 4 float
Z 4 float
Left HRIR 4 * length float
Right HRIR 4 * length float

How to use produced sphere?

  • Translate vector from listener position to sound source position into listener coordinate system (by multiplying vector with listener view matrix)
  • Use this vector to find an intersection point and intersected triangle with sphere mesh
  • Calculate barycentric coordinates of intersection point
  • Use barycentric coordinates as weights for HRTF samples (as reference you can use this paper - http://www02.smt.ufrj.br/~diniz/conf/confi117.pdf)

How to build the tool?

g++ -std=c++17 -o hrir_sphere_builder ./src/hrtf_builder.cpp

hrir_sphere_builder's People

Contributors

andreiltd avatar mrdimas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hrir_sphere_builder's Issues

Build and run on Linux

I'm on Archlinux, I want to try rg3d-sound using an HRIR sphere.
But the build command(using g++) in the README seems to be not correct, the file doesn't exist.
And if I run g++ -o hrtf_builder hrtf_builder.cpp I get errors from g++.
I'm using g++ 9.3.0.

The errors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.