JPL Spatial
Sound spatialization and propagation library
Loading...
Searching...
No Matches
JPL::VBAP::LUT2D Class Reference

Look-up table containing channel gains for each direction. More...

#include <JPLSpatial/Panning/VBAPLUT2D.h>

Classes

struct  LUTStats
 

Public Types

template<class T >
using Array = std::pmr::vector< T >
 

Public Member Functions

 LUT2D ()=default
 
JPL_INLINE bool IsInitialized () const noexcept
 
JPL_INLINE float GetLUTValue (uint32 positionInLUT) const
 
JPL_INLINE floatoperator[] (int i)
 
JPL_INLINE const floatoperator[] (int i) const
 
JPL_INLINE size_t GetLUTSize () const noexcept
 Size of the LUT = LUT Resolution * Number of Channels.
 
JPL_INLINE size_t GetLUTResolution () const noexcept
 Resolution of the LUT.
 
JPL_INLINE int AngleNormalizedToLUTPosition (float angleNormalised) const
 
JPL_INLINE int AngleToLUTPosition (float angleInRadians) const
 
JPL_INLINE float LUTPositionToAngle (int pos) const
 
JPL_INLINE void GetSpeakerGains (int lutPosition, std::span< float > outGains) const
 Get preprocessed speaker gains at specific LUT posotion.
 
JPL_INLINE void GetSpeakerGains (const Vec2 &direction, std::span< float > outGains) const
 Get preprocessed speaker gains from LUT based on direction vector.
 
JPL_INLINE void GetSpeakerGains (const simd &dirX, const simd &dirY, std::span< simd > outGains) const
 Get preprocessed speaker gains from LUT based on direction vector.
 
JPL_INLINE int CartesianToLUTPosition (float x, float y) const
 Get LUT position from direction vector.
 
JPL_INLINE simd_mask CartesianToLUTPosition (const simd &x, const simd &y) const
 Get LUT position from direction vector.
 

Static Public Member Functions

static void BuildDiamondToUniformIndexLUT (Array< uint32 > &outCorrectionLUT, uint32 N_uniform, uint32 M_corr=1024)
 
static void BuildDiamondToAngleNormLUT (Array< float > &outCorrectionLUT, uint32 M_corr=1024)
 

Friends

template<auto GetSpeakerAngleFunction>
class LUTBuilder2D
 

Detailed Description

Look-up table containing channel gains for each direction.

Member Typedef Documentation

◆ Array

template<class T >
using JPL::VBAP::LUT2D::Array = std::pmr::vector<T>

Constructor & Destructor Documentation

◆ LUT2D()

JPL::VBAP::LUT2D::LUT2D ( )
default

Member Function Documentation

◆ AngleNormalizedToLUTPosition()

JPL_INLINE int JPL::VBAP::LUT2D::AngleNormalizedToLUTPosition ( float  angleNormalised) const

Get LUT position from direction angle, where 0.0 is forward

Parameters
angleNormalizedangle in radians in [0, 2Pi]

◆ AngleToLUTPosition()

JPL_INLINE int JPL::VBAP::LUT2D::AngleToLUTPosition ( float  angleInRadians) const

Get LUT position from direction angle, where 0.0 is forward

Parameters
angleInRadiansin radians in [-Pi, Pi]

◆ BuildDiamondToAngleNormLUT()

void JPL::VBAP::LUT2D::BuildDiamondToAngleNormLUT ( Array< float > &  outCorrectionLUT,
uint32  M_corr = 1024 
)
inlinestatic

Build p -> normalized angle in [0,1) M_corr: power-of-two size

◆ BuildDiamondToUniformIndexLUT()

void JPL::VBAP::LUT2D::BuildDiamondToUniformIndexLUT ( Array< uint32 > &  outCorrectionLUT,
uint32  N_uniform,
uint32  M_corr = 1024 
)
inlinestatic

Build a table of size M_corr that maps diamond-parameter bins to 'uniform-angle' indices in [0, N_uniform).

◆ CartesianToLUTPosition() [1/2]

JPL_INLINE simd_mask JPL::VBAP::LUT2D::CartesianToLUTPosition ( const simd x,
const simd y 
) const

Get LUT position from direction vector.

For diamond encoding we need to normalize Vec2(x, y) direction

◆ CartesianToLUTPosition() [2/2]

JPL_INLINE int JPL::VBAP::LUT2D::CartesianToLUTPosition ( float  x,
float  y 
) const

Get LUT position from direction vector.

◆ GetLUTResolution()

JPL_INLINE size_t JPL::VBAP::LUT2D::GetLUTResolution ( ) const
inlinenoexcept

Resolution of the LUT.

◆ GetLUTSize()

JPL_INLINE size_t JPL::VBAP::LUT2D::GetLUTSize ( ) const
inlinenoexcept

Size of the LUT = LUT Resolution * Number of Channels.

◆ GetLUTValue()

JPL_INLINE float JPL::VBAP::LUT2D::GetLUTValue ( uint32  positionInLUT) const
inline

Get gain value at LUT position. Channel stride should be handled by the caller.

E.g. to get gain value for channel 3, knowing LUT position (e.g. retrieved by calling AngleToLUTPosition), positionInLUT parameter should be: AngleToLUTPosition * NumberOfChannels + 3.

Channel gain values for each angle are laid out continuously in the LUT. So to get all the target channel gains for a specific angle, simply get the beginning of the gain data, e.g.: GetLUTValue(AngleToLUTPosition * NumberOfChannels) ..and copy the contiguous gains from that position (LFE is inlude if present in the channel map, though the gain for LFE is always 0.0).

◆ GetSpeakerGains() [1/3]

JPL_INLINE void JPL::VBAP::LUT2D::GetSpeakerGains ( const simd dirX,
const simd dirY,
std::span< simd outGains 
) const

Get preprocessed speaker gains from LUT based on direction vector.

◆ GetSpeakerGains() [2/3]

JPL_INLINE void JPL::VBAP::LUT2D::GetSpeakerGains ( const Vec2 direction,
std::span< float outGains 
) const

Get preprocessed speaker gains from LUT based on direction vector.

◆ GetSpeakerGains() [3/3]

JPL_INLINE void JPL::VBAP::LUT2D::GetSpeakerGains ( int  lutPosition,
std::span< float outGains 
) const

Get preprocessed speaker gains at specific LUT posotion.

◆ IsInitialized()

JPL_INLINE bool JPL::VBAP::LUT2D::IsInitialized ( ) const
inlinenoexcept

◆ LUTPositionToAngle()

JPL_INLINE auto JPL::VBAP::LUT2D::LUTPositionToAngle ( int  pos) const

Convert LUT position to angle (within LUT resolution, irrespective of number of channels of the channel map)

◆ operator[]() [1/2]

JPL_INLINE float & JPL::VBAP::LUT2D::operator[] ( int  i)
inline

◆ operator[]() [2/2]

JPL_INLINE const float & JPL::VBAP::LUT2D::operator[] ( int  i) const
inline

Friends And Related Symbol Documentation

◆ LUTBuilder2D

template<auto GetSpeakerAngleFunction>
friend class LUTBuilder2D
friend

The documentation for this class was generated from the following file: