HOA Library  beta 3.0
High Order Ambisonics Library
Public Member Functions | List of all members
Encoder< D, T > Class Template Reference

The class encodes a signal into the harmonics domain depending on coodinates. More...

#include <Hoa_Encoder.hpp>

Inheritance diagram for Encoder< D, T >:
ProcessorHarmonics< D, T > Processor< D, T >

Public Member Functions

 Encoder (const size_t order)
 The constructor. More...
 
 ~Encoder () hoa_noexcept
 The destructor.
 
getRadius () const hoa_noexcept
 Returns the radius.
 
getAzimuth () const hoa_noexcept
 Returns the azimuth.
 
getElevation () const hoa_noexcept
 Returns the elevation.
 
void setCoordinates (const T radius, const T azimuth, const T elevation) hoa_noexcept
 Sets the coordinates. More...
 
void setRadius (const T radius) hoa_noexcept
 Sets the radius. More...
 
void setAzimuth (const T azimuth) hoa_noexcept
 Sets the azimuth. More...
 
void setElevation (const T elevation) hoa_noexcept
 Sets the elevation. More...
 
void process (const T *input, T *outputs) hoa_noexcept hoa_override
 The method performs the encoding of the harmonics signal. More...
 
- Public Member Functions inherited from ProcessorHarmonics< D, T >
 ProcessorHarmonics (const size_t order) hoa_noexcept
 The harmonics constructor. More...
 
virtual ~ProcessorHarmonics () hoa_noexcept
 The harmonics destructor.
 
size_t getDecompositionOrder () const hoa_noexcept
 Returns the order of decomposition.
 
size_t getNumberOfHarmonics () const hoa_noexcept
 Returns the number of harmonics.
 
size_t getHarmonicDegree (const size_t index) const hoa_noexcept
 Returns the degree of an harmonic. More...
 
long getHarmonicOrder (const size_t index) const hoa_noexcept
 Returns the azimuthal order of an harmonic. More...
 
size_t getHarmonicIndex (const size_t degree, const long order) const hoa_noexcept
 Returns the index of an harmonic given the degree and the azimuthal order. More...
 
std::string getHarmonicName (const size_t index) const hoa_noexcept
 Returns the name of an harmonic. More...
 
getHarmonicNormalization (const size_t index) const hoa_noexcept
 Returns the normalization of an harmonic. More...
 
getHarmonicSemiNormalization (const size_t index) const hoa_noexcept
 Returns the semi-normalization of an harmonic. More...
 
- Public Member Functions inherited from Processor< D, T >
virtual ~Processor () hoa_noexcept
 The destructor.
 

Detailed Description

template<Dimension D, typename T>
class hoa::Encoder< D, T >

The class encodes a signal into the harmonics domain depending on coodinates.

The class generates the signals associated to the harmonics \(Y_{l,m}\) according to a radius \(\rho\), an azimuth \(\theta\) and an elevation \(\varphi\).
The coefficients of the harmonics are defined by:

\[Y_{l,m}(\theta, \varphi) = G_{l,m}(\rho) P_{l, \left|m\right|}(\sin{(\varphi)}) e^{+im\theta} k_{l, m} \]

with
\(G_{l,m}(\rho)\) the radius part of the equation,
\(e^{+im\theta}\) the azimuth part with \(i\) the imaginary,
\(P_{l, \left|m\right|}(\cos{(\varphi)})\) the elevation part of the equation with \(P_{l, \left|m\right|}(x)\) the associated Legendre polynomials,
\(k_{l, m}\) the normalization and
\(N\) the order of decomposition, \(l\) the degree, \(m\) the azimuthal order, \(\rho\) the radius, \(\theta\) the azimuth and \(\varphi\) the elevation in radian.

The radius \(\rho\) is included between \(0\) and \(+\infty\). \(0\) is the center of the soundfield, \(1\) is the radius of the ambisonics circle or sphere, beyond this limit the gains \(G\) of the harmonics decrease globally and before the gains \(G\) decrease independently:
if \(\rho\ge1\)

\[G_{l,m}(\rho) = \frac{1}{\rho}\]

else

\[G_{l,m}(\rho) = \rho^l((1-\rho)(N-l)+1)\]

The azimuth \(\theta\) in radian is included between \(0\) and \(2\pi\). The direction of rotation is counterclockwise. The \(0\) radian is \(\frac{\pi}{2}\) phase shifted relative to a mathematical representation of a circle, then the \(0\) radian is at the "front" of the soundfield. The azimuth part in the imaginary form of the equation \(e^{+im\theta}\) can be expressed with the real form :
if \(m\geq0\)

\[e^{+im\theta} = \cos{(\left|m\right|\theta)}\]

else

\[e^{+im\theta} = \sin{(\left|m\right|\theta)}\]

The elevation \(\varphi\) is included between \(-\pi\) and \(\pi\). The direction of rotation is from bottom to the top. The \(0\) radian is centered at the "front" of the soundfield, then \(\frac{\pi}{2}\) is at the top, \(-\frac{\pi}{2}\) is at the bottom and \(\pi\) is behind. Note that if the angle of elevation is between \(\frac{\pi}{2}\) and \(\frac{3\pi}{2}\), the azimuth is reversed. The elevation part \(P_{l, \left|m\right|}(x)\) of the formula can be expressed with the recursives formulas:

\[P_{l+1,l+1}(x) = -(2l+1)\sqrt{(1-x^2)}P_{(l,l)}(x) \]

\[P_{l+1,l}(x) = x(2l+1)P_{(l,l)}(x) \]

\[P_{l+1,m}(x) = \frac{x(2l+1)P_{(l,m)}(x) - (l+m)P_{(l-1,m)}(x)}{l-m+1} \]

and with

\[P_{0, 0}(x) = 1\]

The normalization part \(k_{l, m}\) is equivalent to :
if \(m = 0\) then

\[k_{l, m} = 1\]

else

\[k_{l, m} = \sqrt{\frac{(l - \left|m\right|)!}{(l + \left|m\right|)!}}\sqrt{2} \]

Definition at line 66 of file Hoa_Encoder.hpp.

Constructor & Destructor Documentation

Encoder ( const size_t  order)
inline

The constructor.

Parameters
orderThe order of decomposition.

Definition at line 72 of file Hoa_Encoder.hpp.

Member Function Documentation

void setCoordinates ( const T  radius,
const T  azimuth,
const T  elevation 
)
inline

Sets the coordinates.

Parameters
radiusThe new radius.
azimuthThe new azimuth.
elevationThe new elevation.

Definition at line 103 of file Hoa_Encoder.hpp.

void setRadius ( const T  radius)
inline

Sets the radius.

Parameters
radiusThe new radius.

Definition at line 111 of file Hoa_Encoder.hpp.

void setAzimuth ( const T  azimuth)
inline

Sets the azimuth.

Parameters
azimuthThe new azimuth.

Definition at line 133 of file Hoa_Encoder.hpp.

void setElevation ( const T  elevation)
inline

Sets the elevation.

Parameters
elevationThe new elevation.

Definition at line 179 of file Hoa_Encoder.hpp.

void process ( const T *  input,
T *  outputs 
)
inlinevirtual

The method performs the encoding of the harmonics signal.

The input pointer must be the sample to encode and the outputs array contains the spherical harmonics samples thus the minimum size of the array must be the number of harmonics.

Parameters
inputThe input pointer.
outputsThe outputs array.

Reimplemented from Processor< D, T >.

Definition at line 252 of file Hoa_Encoder.hpp.