Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

Spatial_Audio_Framework

> 编程语言
Open source

A cross-platform framework for developing spatial audio algorithms and software in C/C++

737 stars0 likes1 views
WebsiteGitHub

About

A cross-platform framework for developing spatial audio algorithms and software in C/C++

  • git: https://github.com/leomccormack/Spatial_Audio_Framework
  • doxygen: https://leomccormack.github.io/Spatial_Audio_Framework/

About

The Spatial_Audio_Framework (SAF) is an open-source and cross-platform framework for developing spatial audio related algorithms and software in C/C++. Originally intended as a resource for researchers in the field, the framework has gradually grown into a large codebase comprising a number of distinct modules. Each module targets a specific sub-field of spatial audio, such as: Ambisonics encoding/decoding, spherical array processing, amplitude-panning (VBAP), HRIR processing, room simulation, etc. The framework also makes use of highly optimised linear algebra libraries (such as: Intel MKL, Apple Accelerate, OpenBLAS) as well as x86 SIMD intrinsics (SSE, AVX, AVX-512).

Several examples are also included in the repository, which serve to demonstrate the functionality of the framework and may also act as a starting point for new projects. These examples have also been realised as VST/LV2 audio plug-ins under the SPARTA banner.

Owing to its modular design, expanding the framework is relatively straightforward, and contributions from researchers and developers of spatial audio technologies is encouraged! :-)

Prerequisites

The framework requires the following external libraries:

  • Any library (or libraries) conforming to the CBLAS and LAPACK standards
  • (Optional) Intel's Integrated Performance Primitives (IPP) for the FFT and/or resampler
  • (Optional) FFTW for the FFT
  • (Optional) netCDF for loading very large SOFA files

In order to inform SAF which CBLAS/LAPACK supporting library/libraries you have linked to your project, simply add one of the following global pre-processor definitions:

…

Detailed instructions regarding how to build and link these libraries can be found here.

Framework structure

The framework comprises the following core modules (ISC License):

  • saf_hoa - a collection of higher-order Ambisonics binaural and loudspeaker decoders.
  • saf_sh - spherical harmonic and spherical array processing related functions.
  • saf_vbap - Vector-base Amplitude Panning (VBAP) functions.
  • saf_cdf4sap - Covariance Domain Framework for Spatial Audio Processing (CDF4SAP).
  • saf_hrir - HRIR/HRTF related functions (estimating ITDs, HRTF interpolation, diffuse-field EQ etc.).
  • saf_reverb - a collection of reverbs and room simulation algorithms.
  • saf_utilities - a collection of useful utility functions and cross-platform wrappers.

The framework also includes the following optional modules:

  • saf_sofa_reader - a simple SOFA file reader (ISC License).
  • saf_tracker - a particle-filtering based tracker (GPLv2 License).
  • saf_hades - for binaural rendering of Hearing-Assistive/Augmented-reality Devices (HADES) (GPLv2 License).

To enable optional framework modules, simply add the relevant pre-processor definition:

SAF_ENABLE_SOFA_READER_MODULE  # to enable saf_sofa_reader
SAF_ENABLE_TRACKER_MODULE      # to enable saf_tracker
SAF_ENABLE_HADES_MODULE        # to enable saf_hades

Additional options

The framework can be configured further with the following options:

SAF_USE_INTEL_IPP # To use Intel IPP for performing the DFT/FFTs and resampling
SAF_USE_FFTW      # To use the FFTW library for performing the DFT/FFTs 
SAF_ENABLE_SIMD   # To enable SIMD (SSE3, AVX2 and/or AVX512) intrinsics for certain vector operations
SAF_ENABLE_NETCDF # To enable the option to load SOFA files using netcdf (rather than libmysofa). Required for very large SOFA files.

Using the framework

Once a CBLAS/LAPACK flag is defined (and the correct libraries are linked to your project), add the files found in the framework folder to your project and add the following directory to your project's header search paths:

Spatial_Audio_Framework/framework/include  

The framework's master include header is then:

c
#include "saf.h"
#include "saf_externals.h"  /* (Optional) To also carry over CBLAS/LAPACK routines and other external functions. */

Building with CMake

The framework may also be included within an existing CMake workflow with simply:

add_subdirectory(Spatial_Audio_Framework)
target_link_libraries(${PROJECT_NAME} PRIVATE saf)

The available SAF-related CMake options (and their default values) are:

…

If using e.g. SAF_USE_INTEL_MKL_LP64 as the performance library, note that the default header and library search paths may be overridden according to your setup with:

-DINTEL_MKL_HEADER_PATH="path/to/mkl/headers"
-DINTEL_MKL_LIB="path/to/mkl/libs/mkl_rt(.so/.dylib/.lib)"   # OR:
-DINTEL_MKL_LIB="path/to/custom/mkl/lib/saf_mkl_custom_lp64(.so/.dylib/.lib)"

For Linux/MacOS users: the framework, examples, and unit testing program may be built as follows:

bash
# By default:
cmake -S . -B build 
# Or to also enable e.g. SSE3, AVX2, and/or AVX-512 intrinsics (for both C and C++ code):
cmake -S . -B build -DSAF_ENABLE_SIMD=1
# Or to build Universal binaries for macOS (ARM/x86), which must therefore use Apple Accelerate:
cmake -S . -B build -DSAF_PERFORMANCE_LIB=SAF_USE_APPLE_ACCELERATE -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
# Then to build and run the unit testing program:
cd build
make
test/saf_test 

Or for Visual Studio users (using x64 Native Tools Command Prompt for VS):

bash
# e.g. for VS2019:
cmake -S . -B build -G "Visual Studio 16" -A x64  
# e.g. for VS2017:
cmake -S . -B build -G "Visual Studio 15 2017" -DCMAKE_GENERATOR_PLATFORM=x64
# Then to build and run the unit testing program:
cd build
msbuild ALL_BUILD.vcxproj /p:Configuration=Release /m
cd test/Release
saf_test.exe  

Documentation

Doxygen-based documentation is generated via a GitHub Action everytime a commit is pushed to the master branch. The documentation is hosted here.

Alternatively, you may generate the documentation yourself (e.g. for the other branches) with the following commands:

bash
cd docs/doxygen
doxygen doxygen_config
# (optional) to also build the pdf version:
cd latex
make

Examples

Several examples have also been included in the repository, which may serve as a starting point for learning how to use the framework:

  • ambi_bin - a binaural Ambisonic decoder with built-in rotator. It supports the following decoding options: least-squares (LS), spatial re-sampling (SPR), Time-alignment (TA), Magnitude Least-Squares (MagLS).
  • ambi_dec - a frequency-dependent Ambisonic decoder. It supports the following decoding options: sampling Ambisonic decoder (SAD), AllRAD, Energy-Preserving decoder (EPAD), Mode-Matching decoder (MMD).
  • ambi_drc - a frequency-dependent dynamic range compressor (DRC) for Ambisonic signals.
  • ambi_enc - a basic Ambisonic encoder.
  • ambi_roomsim - an Ambisonic encoder that also includes reflections and source distance based on an image-source model of a shoebox room. Multiple sources and Ambisonic receivers are supported.
  • array2sh - converts microphone array signals into spherical harmonic signals (aka Ambisonic signals), based on theoretical descriptions of the array configuration and construction.
  • beamformer - a beamformer/virtual microphone generator for Ambisonic signals, with several different beam pattern options.
  • binauraliser - convolves input audio with interpolated HRTFs, which can be optionally loaded from a SOFA file.
  • binauraliser_nf - binauraliser, with the addition of proximity filtering for near field sound sources.
  • decorrelator - a basic multi-channel signal decorrelator.
  • dirass - a sound-field visualiser based on re-assigning the energy of beamformers. This re-assignment is based on the DoA estimates extracted from spatially-localised active-intensity vectors, which are biased towards each beamformer direction.
  • matrixconv - a basic matrix convolver with an optional partitioned convolution mode.
  • multiconv - a basic multi-channel convolver with an optional partitioned convolution mode.
  • tvconv - a time-varying partitioned convolution multi-channel convolver for SOFA files containing RIRs with multiple listener positions.
  • panner - a frequency-dependent VBAP panner, which accommodates a source loudness compensation (as a function of the room) option.
  • pitch_shifter - a basic multi-channel pitch shifter, based on the phase vocoder approach.
  • powermap - sound-field visualiser based on beamformer (PWD, MVDR) energy or subspace methods (MUSIC).
  • rotator - rotates spherical harmonic signals (aka Ambisonic signals) given yaw-pitch-roll Euler rotation angles.
  • sldoa - a sound-field visualiser based on directly depicting the DoA estimates extracted from multiple spatially-localised active-intensity vectors for multiple frequencies.
  • spreader - an arbitrary array panner (HRIRs, microphone array IRs, etc.) with coherent and incoherent spreading modes.

Many of these examples have also been released as VST audio plug-ins under the SPARTA banner. The following open-source projects also employ the framework: HADES, Super-Hearing, HO-SIRR-GUI, and CroPaC-Binaural.

Extras

The repository also includes the following extras:

  • matlab - a bunch of MATLAB scripts/functions to accompany the framework (a script to generate saf_default_hrirs.c, MATLAB versions of certain SAF functions, etc.).
  • safmex - a bunch of MATLAB MEX wrappers, which allow certain SAF functions to be used within MATLAB.
  • safpy - a bunch of Python wrappers, which allow certain SAF functions to be used within Python.
  • safwwise - a proof of concept regarding how one might integrate SAF into Wwise.

Contributing

Suggestions and contributions to the code are both welcomed and encouraged. It should be highlighted that the framework has been designed to be highly modular with plenty of room for expansion. Therefore:

  • if you are researcher who has developed a spatial-audio related method and want to integrate it into the framework... or
  • if you notice that an existing piece of code can be rewritten to make it clearer, faster, or to fix a bug...

then please feel free to do so and submit a pull request. We may also be able to help with the implementation if needed, just get in touch :- )

Contributors

  • Leo McCormack - C programming and algorithm design (contact: leo.mccormack(at)aalto.fi)
  • Symeon Delikaris-Manias - algorithm design
  • Archontis Politis - algorithm design
  • Ville Pulkki - algorithm design
  • Juhani Paasonen - C programming
  • Chris Hold - C programming and algorithm design
  • Janani Fernandez - C programming and algorithm design

License

This software is dual-licensed. By default, this software is provided permissively under the terms of the [ISC Li

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C3d-audioambisonicsmicrophone-array-processingmulti-source-tracking

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言