HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::Spatializer Class Referencefinal

implements reading the SOFA files and HRTF interpolation for spatialization. More...

#include <Spatializer.h>

Public Member Functions

 Spatializer (const std::filesystem::path &sofaFilePath, uint32_t sampleRate)
 
 Spatializer (const Spatializer &)=delete
 
 Spatializer (Spatializer &&rhs) noexcept
 
Spatializeroperator= (const Spatializer &)=delete
 
Spatializeroperator= (Spatializer &&rhs) noexcept
 
uint32_t GetSampleRate () const
 
size_t GetFrameCount () const
 
void OpenSofaFile (const std::filesystem::path &sofaFilePath, uint32_t sampleRate)
 
void CloseSofaFile ()
 
void Process (AudioBuffer &buffer, float azimuth_deg, float elevation_deg)
 
void Process (AudioBuffer &buffer, float azimuth_deg, float elevation_deg, const Heph::DoubleBuffer &windowBuffer)
 

Detailed Description

implements reading the SOFA files and HRTF interpolation for spatialization.

Member Function Documentation

◆ GetSampleRate()

uint32_t HephAudio::Spatializer::GetSampleRate ( ) const

gets the sampling rate of the read SOFA file.

◆ GetFrameCount()

size_t HephAudio::Spatializer::GetFrameCount ( ) const

gets the size of the HRTF filters.

◆ OpenSofaFile()

void HephAudio::Spatializer::OpenSofaFile ( const std::filesystem::path & sofaFilePath,
uint32_t sampleRate )

reads the SOFA file for using the HRTF data.

Exceptions
FailException

◆ CloseSofaFile()

void HephAudio::Spatializer::CloseSofaFile ( )

closes the SOFA file and releases the resources.

◆ Process() [1/2]

void HephAudio::Spatializer::Process ( AudioBuffer & buffer,
float azimuth_deg,
float elevation_deg )

spatializes the provided audio data.
Uses HannWindow for windowing.

Parameters
bufferaudio data.
azimuth_degdesired azimuth angle in degrees.
elevation_degdesired elevation angle in degrees.
Exceptions
InvalidArgumentException

◆ Process() [2/2]

void HephAudio::Spatializer::Process ( AudioBuffer & buffer,
float azimuth_deg,
float elevation_deg,
const Heph::DoubleBuffer & windowBuffer )

spatializes the provided audio data.

Parameters
bufferaudio data.
azimuth_degdesired azimuth angle in degrees.
elevation_degdesired elevation angle in degrees.
windowBufferbuffer that's generated by using one of the Window classes.
Note
size of the windowBuffer must be equal to the HRTF IR size, which can be acquired by the GetFrameCount method.
Exceptions
InvalidArgumentException