|
JPL Spatial
Sound spatialization and propagation library
|
#include <JPLSpatial/Panning/PannerBase.h>
Classes | |
| struct | ChannelGroup |
| struct | PanUpdateData |
| Parameters to update VBAP data for a source. More... | |
| struct | PanUpdateDataWithOrientation |
| struct | VBAPLayoutBase |
| struct | VirtualSource |
Public Types | |
| using | Vec3Type = typename Traits::Vec3Type |
| Aliases to avoid typing wordy templates. | |
| template<class T > | |
| using | Array = std::pmr::vector< T > |
| using | ChannelGainsRef = typename Traits::ChannelGains & |
| using | PanSourceOrientation = OrientationData< Vec3Type > |
| using | PanType = PannerType |
| using | LUTType = typename PanType::LUTType |
| using | LUTInterface = typename PanType::LUTInterface |
| using | SourceLayoutType = typename PanType::SourceLayout |
Static Public Member Functions | |
| static JPL_INLINE void | NormalizeWeights (std::span< VirtualSource > virtualSources) |
| Normalize weights of the virtual sources to ensure consistent energy. | |
Vector Based Amplitude Panner that can handle panning from any source channel map to any target/output channel map.
Internally uses MDAP (Multiple Directions Amplitude Panning) with virtual sources (aka virtual positions).
SourceLayout and ProcessVBAPData function can be used for a more conventional channel map -> channel map panning, based on parameters like spread and focus, which can be driven by, for example, distance from the soruce to the listener (on the client side).
While VirtualSource(s) can be used directly with ProcessVirtualSources function for a more customizable spatialization, e.g. for volumetric sound sources, or any other cases where position and spatial extend of each channel needed to be manually cotrolled.
Instead of using VBAPannerBase directly, it is adviced to use 'VBAPanner2D' and 'VBAPanner3D' aliases from the similarly named files.
| using JPL::VBAPannerBase< PannerType, Traits >::Array = std::pmr::vector<T> |
| using JPL::VBAPannerBase< PannerType, Traits >::ChannelGainsRef = typename Traits::ChannelGains& |
| using JPL::VBAPannerBase< PannerType, Traits >::LUTInterface = typename PanType::LUTInterface |
| using JPL::VBAPannerBase< PannerType, Traits >::LUTType = typename PanType::LUTType |
| using JPL::VBAPannerBase< PannerType, Traits >::PanSourceOrientation = OrientationData<Vec3Type> |
| using JPL::VBAPannerBase< PannerType, Traits >::PanType = PannerType |
| using JPL::VBAPannerBase< PannerType, Traits >::SourceLayoutType = typename PanType::SourceLayout |
| using JPL::VBAPannerBase< PannerType, Traits >::Vec3Type = typename Traits::Vec3Type |
Aliases to avoid typing wordy templates.
|
inlinenoexcept |
Get the channel map the panner is initialized to.
|
inlinenoexcept |
Get the look-up table. Can be nullptr, if hasn't been initialized yet.
|
inlinenoexcept |
Get number of channels the LUT is initialized for. Effectively this is the channel count of the channel map the panner is initialized for, including LFE (though LFE gain is always 0.0).
|
inlinenoexcept |
Get shortest aperture between two speakers (dot product for 3D, angle for 2D panner). This is mainly useful for debuggint and verification.
| JPL_INLINE void JPL::VBAPannerBase< PannerType, Traits >::GetSpeakerGains | ( | const simd & | dirX, |
| const simd & | dirY, | ||
| const simd & | dirZ, | ||
| std::span< simd > | outGains | ||
| ) | const |
Get speaker gains from LUT based on 'direction' vector. Vecrorized version.
| outGains | : must be of size equals to number of target channels of this panner |
| JPL_INLINE void JPL::VBAPannerBase< PannerType, Traits >::GetSpeakerGains | ( | const Vec3Type & | direction, |
| std::span< float > | outGains | ||
| ) | const |
Get speaker gains from LUT based on 'direction' vector.
| outGains | : must be of size equals to number of target channels of this panner |
|
inline |
Initialize LUT for a specific channelMap.
| channelMap | : target channel map to create LUT for |
| JPL_INLINE bool JPL::VBAPannerBase< PannerType, Traits >::InitializeSourceLayout | ( | ChannelMap | channelMap, |
| SourceLayoutType & | outLayout | ||
| ) | const |
Create/initialize SourceLayout for given source channelMap
|
inlinenoexcept |
|
inlinenoexcept |
|
static |
Normalize weights of the virtual sources to ensure consistent energy.
| JPL_INLINE void JPL::VBAPannerBase< PannerType, Traits >::ProcessVBAPData | ( | const SourceLayoutType & | sourceLayout, |
| const PanUpdateData & | updateData, | ||
| std::span< float > | outChannelMixMap, | ||
| OnChannelGeneratedCallback && | onVSsGeneratedCb = {} |
||
| ) | const |
This function should be called whenever pan data changes to update set gains based on PanUpdateData for each source channel retrieved by getOutGains callback. SourceLayout must be initialized beforehand. E.g. this would be called for each source that has unique channel layout or panning state
| outChannelMixMap | : outptut channel mixing map, where for each source chanel there's a set of gain values for each target (e.g. for Stereo->Stereo [ sl_tl, sl_tr, sr_tl, sr_tr ]) |
| JPL_INLINE void JPL::VBAPannerBase< PannerType, Traits >::ProcessVBAPData | ( | const SourceLayoutType & | sourceLayout, |
| const PanUpdateDataWithOrientation & | updateData, | ||
| std::span< float > | outChannelMixMap, | ||
| OnChannelGeneratedCallback && | onVSsGeneratedCb = {} |
||
| ) | const |
| JPL_INLINE void JPL::VBAPannerBase< PannerType, Traits >::ProcessVirtualSources | ( | std::span< const VirtualSource > | virtualSources, |
| std::span< float > | outGains | ||
| ) | const |
Get and accumulate speaker gains for all virtual soruces into @outGains Weights of the virtual sources must be L1 normalized