Giter Club home page Giter Club logo

libbasicsofa's Introduction

libBasicSOFA

A very basic library for reading Spatially Oriented Format for Acoustics (SOFA) files, a format for storing HRTFs and/or BRIRs for binuaral audio reproduction.
More information on this format can be found in the SOFA Conventions website or in the AES standard document, AES69-2015. For those looking for a more comprehensive library, check out libMySofa

Library Constraints

Listeners and Sources

The SOFA specification allows for multiple sound sources and listeners. A listener can have multiple view vectors (orientation of head). However, this library only supports one view vector. A head rotation should be reflected only by the data in ListenerPosition. Alternatively, multiple sources surrounding the head are reflected by the data in SourcePosition.

Coordinates

Only spherical coordinates are supported in this library. Cartesian coordinates are NOT supported

Conventions

The following chart outlines the spherical coordinate system used in the SOFA specification.
coordinates

From the following paper by César D. Salvador

Building

Dependencies

libBasicSOFA depends on the HDF5 API. MacOS users can obtain this API through Homebrew:

brew install hdf5

Build Instructions

A CMake file is in the works. In the meantime, to build on MacOS, create a new library project, add the libBasicSOFA source files and build.

Using the Library

The following code snippet demonstrates instantiating a libBasicSOFA object, reading a SOFA file, getting some properties and finally getting an impulse response for a given channel and spherical coordinate (theta, phi, radius):

BasicSOFA::BasicSOFA sofa;

bool success = sofa.readSofaFile("/path/to/sofa/file.sofa");
if (!success)
    return;
    
auto samplingFrequency = sofa.getFs();
auto numSourcePositions = sofa.getM();

auto theta = 150.0;
auto phi = 0.0;
auto radius = 1.0;
auto channel = 0;

const double *impulseResp = sofa.getHRIR(channel, theta, phi, radius);
if (impulseResp == nullptr)
    return;

Unit Testing

libBasicSOFA uses the Catch2 test framework. Ensure that you have this framework installed before running the tests.

As the SOFA files used in unit testing are large in size, they are not included in this repository. The supported SOFA file example can be downloaded here while the unsupported SOFA file example can be downloaded here.

To run the unit tests on MacOS, ensure you have a copy of the libBasicSOFA library built. Create a new XCode project, import the source files in BasicSOFATest into your project, specify the SOFA file paths and run.

libbasicsofa's People

Contributors

superkittens avatar

Stargazers

Baby Commando (JP) avatar kkk avatar Yuan-Man avatar Mel Massadian avatar Dimitri Diakopoulos avatar Oli Larkin avatar Gregor McWilliam avatar Christof avatar Malik Enes Şafak avatar Tatsuya Shiozawa avatar  avatar Ilias Ibnyahya avatar

Watchers

James Cloos avatar

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.