SOFA Reader
Overview
SOFA Reader is the main entry point in BRT for loading SOFA files into the internal data structures used by the rendering engine. SOFA format is widely adopted in spatial audio applications due to its flexibility and compatibility with 3D audio systems.
It provides a unified interface to read different types of spatial audio data from SOFA files (e.g., HRTFs, BRIRs, directivity, filters) and converts them into BRT service modules such as: CSphericalFIRTable, CSphericalInterpolatedFIRTable or CSphericalSOSTable.
Internally, it relies on a wrapper around libmysofa to parse SOFA files and then adapts the data to the BRT conventions.
Loaders Overview
The SOFA Reader class provides several specialized loaders depending on the intended use of the data.
HRTF Loaders
- Load Head-Related Transfer Functions.
- Can produce:
- Interpolated HRTF datasets: A grid of interpolated data is generated from the IR values read from the file. For further information, please see here.
- Raw datasets: The stored data matches that read from the file . For further information, please see here.
- It supports any HRTF convention using FIR or FIR-E data types, although it has been extensively tested with SimpleFreeFieldHRIR.
BRIR Loader
- Loads Binaural Room Impulse Responses.
- It supports any BRIR convention using FIR or FIR-E data types, although it has been extensively tested with SingleRoomMIMOSRIR.
- It allows the BRIR to be adjusted using fade-in and fade-out parameters. To achieve this, a rectangular window with smooth edges is applied, using high-cosine progressive input and output transitions with a configurable slope. This process allows early impulse components to be attenuated and/or late impulse components to be clipped. For further details, see here.
FIR Filter Loader
- Loads generic impulse responses from SOFA files.
- Used for arbitrary IR-based processing.
- It supports any convention using FIR or FIR-E data types, although it has been extensively tested with GeneralFIR.
SOS Filter Loader
- Loads IIR filters (Second Order Sections).
- Typically used for:
- Near-Field Correction filters
- Perfomn any filtering based on second-order sections
- It supports any SOS convention, although it has been extensively tested with SimpleFreeFieldHRSOS.
Directivity Loaders
- Load source directivity patterns.
- Requires specific SOFA convention:
SourceDirectivityFIR.
- Can produce:
- Interpolated directivity: A grid of interpolated data is generated from the IR values read from the file. For further information, please see here.
- Raw directivity.The stored data matches that read from the file . For further information, please see here.
- It works with the new SourceDirectivityFIR convention. This convention is currently under development, so this loader will adapt to any changes that may occur. It is currently compatible with version 0.3.
Supported SOFA Data Types
The reader supports the following SOFA data types:
| Data Type |
Description |
FIR |
Finite Impulse Response filters |
FIR-E |
FIR with additional metadata (extended format) |
SOS |
Second Order Sections (IIR filters) |
For C++ developer
General Methods
| Method |
Description |
GetLastError() |
Returns the last error message and resets it |
GetSampleRateFromSofa(const std::string&) |
Returns the sampling rate of the SOFA file |
GetDataTypeFromSofa(const std::string&) |
Returns the detected SOFA data type |
HRTF Loaders
| Method |
Description |
ReadHRTFFromSofa(...) |
Loads an interpolated HRTF dataset into CSphericalInterpolatedFIRTable |
ReadHRTFRawFromSofa(...) |
Loads raw HRTF data into CSphericalFIRTable |
BRIR Loader
| Method |
Description |
ReadBRIRFromSofa(...) |
Loads BRIR data and applies fade-in/out to separate direct and reverberant components |
FIR Filter Loader
| Method |
Description |
ReadFIRFilterFromSofa(...) |
Loads a generic FIR dataset into a spherical FIR table |
Directivity Loaders
| Method |
Description |
ReadDirectivityFromSofa(...) |
Loads interpolated source directivity |
ReadDirectivityRawFromSofa(...) |
Loads raw directivity without interpolation |
SOS Filter Loader
| Method |
Description |
ReadSOSFiltersFromSofa(...) |
Loads SOS filters into CSphericalSOSTable |