Merge pull request #13 from google/build_fix Embeds the filter data and improves compatibility
The obr binaural rendering library is designed to render immersive audio content.
The library is written using C++ and it utilizes Bazel build system. A CMake configuration is also provided.
The library renders the following types of Audio Elements:
| Filter Type | Filter Length (samples) | Sampling Rate |
|---|---|---|
| Direct | 256 | 48 kHz |
| Ambient | 8192 | 48 kHz |
| Reverberant | 8192 | 48 kHz |
The ObrImpl class is the main interface for the binaural renderer. It provides methods to configure audio elements, process audio buffers, and retrieve information about the renderer. See obr_cli_lib.cc for an example of how to use the library. Listed below are the main methods required to configure the renderer and process audio data.
In order to instantiate the renderer, the ObrImpl constructor needs to be called. It takes the following arguments:
buffer_size_per_channel: The size of the audio processing buffer for each audio channel.sampling_rate: The sampling rate of the audio data.ObrImpl(int buffer_size_per_channel, int sampling_rate);
In order to render immersive audio using obr, the renderer needs to be configured using the AddAudioElement method. The method accepts AudioElementType enums defined within the audio_element_type.h file and BinauralFilterProfile enums defined within the audio_element_config.h file. If the second argument is not provided, the filter type defaults to kAmbient.
absl::Status AddAudioElement(AudioElementType type, BinauralFilterProfile filter_type);
Once the renderer is configured, the rendering of audio data can be done using the Process method. The method uses AudioBuffer class for storing input and output audio data.
void Process(const AudioBuffer& input_buffer, AudioBuffer* output_buffer);
The command line interface provides a straightforward way to render audio files of certain types. The CLI is built as a standalone executable and can be run as follows:
obr_cli --input_type=<1OA|2OA|3OA|4OA|7.1.4|OBA> --oba_metadata_file=<full path to textproto file> (required for OBA) --input_file=<full path to wav file> --output_file=<full path to wav file> --buffer_size=<number of samples> (optional, default is 256) --filter_type=<Direct|Ambient|Reverberant> (optional, default is Ambient)
The library is tested using Google Test framework. The tests are located in test subdirectories.