ylm.lib
A library to compute real N3D1 Spherical Harmonics at arbitrary degree $l$ and order $m$, according to the following formula:
\[\begin{equation} Y_{l,m}(\theta, \phi) = \left\lbrace \begin{aligned} N_{l,m} P_l^m\left(\sin(\phi)\right) \cos(m \theta) & & \text{for} & & m \geq 0 \\ N_{l,m} P_l^m\left(\sin(\phi)\right) \sin(m \theta) & & \text{for} & & m < 0 \end{aligned} \right., \label{eq:sph} \end{equation}\]where $P_l^m$ are the associated Legendre polynomial of the first kind of degree $l$ and order $m$, with ${(l,m) \in (\mathbb{N}, \mathbb{Z}) ~|~ |m| \leq l}$. The Condon-Shortley Phase is not included, and the ACN convention2 is used. $N_{l,m}$ is the “N3D” normalization factor ensuring the orthonormality of the SHs on the unit sphere3. It is given by: \begin{equation} N_{l,m} = \sqrt{(2- \delta_m) (2 l + 1)\frac{(l-|m|)!}{(l+|m|)!}}, \label{eq:norm} \end{equation} where $\delta_m$ is the Kronecker delta function. Details of implementation are given in4 (Note that spherical coordinate system and notations differ in4)
Functions
factorial(m)
Computes the factorial $m!$ of integer $m$.
factorial2(m)
Computes the double factorial $m!!$ of integer $m$.
legendre(l,x)
Computes the Legendre polynomial $P_{l}(x)$ of degree $l$.
alegendre(l,x)
Computes the associated Legendre polynomial $P_{l,m}(x)$ of degree $l$ and order $m$.
chebychev2(m,x)
Computes the Chebyshev polynomial $U_m(x)$ of $2^{\text{nd}}$ kind.
n3d(l,m)
Computes the “N3D” norm $N_{l,|m|}$ of Eq. \eqref{eq:norm}.
ylm(l,m,t,p)
Computes the N3D real Spherical Harmonic $Y_{l,m}(\theta,\phi)$ of Eq. \eqref{eq:sph}. –
sylm(l,m,t,p)
Computes the N3D real Spherical Harmonic $Y_{l,m}(\theta,\phi)$ of Eq. \eqref{eq:sph}, with smoothing functions.
acn(l,m)
Computes the Ambisonic Channel Number (ACN)2 from indexes $(l,m)$:
\[\begin{equation} \left\lbrace \begin{aligned} &\text{ACN}(l,m) = i = l^2 + l + m \\ &m = \lfloor \sqrt{i} \rfloor \\ &l = i - m^2 - m \end{aligned} \right. \label{eq:acn} \end{equation}\]In Eq. \eqref{eq:acn}, $\lfloor \cdot \rfloor$ is the floor function.
yacn(i,t,p)
Computes the $i^\text{th}$ N3D real Spherical Harmonic $Y_i(\theta,\phi)$ with ACN $i$.
syacn(i,t,p)
Computes the $i^\text{th}$ N3D real Spherical Harmonic $Y_i(\theta,\phi)$ with ACN $i$ and smoothing function.
yvec(imax,t,p)
Vector of Spherical Harmonics $\mathbf{y}(\theta,\phi)$. A signal bus of dimensions $i_\text{max}$ is multiplied with the corresponding Spherical Harmonics, i.e., the $i^\text{th}$ signal is multiplied with $Y_i(\theta,\phi)$.
syvec(imax,t,p)
Vector of Spherical Harmonics $\mathbf{y}(\theta,\phi)$ with smoothing function. A signal bus of dimensions $i_\text{max}$ is multiplied with the corresponding Spherical Harmonics, i.e., the $i^\text{th}$ signal is multiplied with $Y_i(\theta,\phi)$.
costheta(t1,p1,t2,p2)
Cosine of angle $\Theta$ between directions $(\theta_1,\phi_1)$ and $(\theta_2,\phi_2)$ such that:
\[\cos(\Theta) = \cos(\phi_1)\cos(\phi_2)\cos(\theta_1 - \theta_2) + \sin(\phi_1) \sin(\phi_2)\]buswg(c)
Apply the gains defined in the list c
to the input bus. Useful for matrix multiplication.
sup(c)
Returns the maximum of input bus.
wre(lmax, l1, l)
For a on-axis normalized max-$r_E$ beampattern at degree $L$, the weights at degree $l$, denoted $w_L(l)$ are given by5:
\[\begin{equation} w_{\text{max-}r_E,l}(L) = \left\lbrace \begin{aligned} &\frac{P_l\left(\cos\left(\frac{137.9^\circ}{L + 1.51}\right)\right)}{\sum_\limits{i=0}^{L} (2 i + 1) P_i\left(\cos\left(\frac{137.9^\circ}{L + 1.51}\right)\right)} & \text{for } & l \leq L \\ &0 & \text{for } & l > L \end{aligned} \right. \label{eq:acn2} \end{equation}\]lmax
: maximum degree needed at compilation time: Ifl1 > lmax
, thenwre(lmax, l1, l) = 0
.l1
: beampattern degree,l
: required degree.
vecwre(lmax,l)
Vector of on-axis normalized max-$r_E$ beampattern weights.
lmax
: maximum degree needed at compilation time: Ifl1 > lmax
, thenwre(lmax, l1, l) = 0
.l1
: beampattern degree.
maxre(lmax,l1)
Vector of on-axis normalized max-$r_E$ beampattern weights.
The beampattern degree is l1
and its steering angle $(\theta_0, \phi_0)$
lmax
: maximum degree needed at compilation time: Ifl1 > lmax
, thenwre(lmax, l1, l) = 0
.l1
: beampattern degree.
-
T. Carpentier, « Normalization schemes in Ambisonic: does it matter? », in Audio Engineering Society Convention 142, Berlin, 2017. ↩
-
Nachbar, C., Zotter, F., Deleflie, E., & Sontacchi, A, Ambix - A suggested ambisonics format, in Ambisonics Symposium, Lexington, 2011. ↩ ↩2
-
E. G. Williams, Fourier Acoustics: Sound Radiation And Nearfield Acoustical Holography. London: Academic Press, 1999. ↩
-
P. Lecomte, « Ambitools: Tools for Sound Field Synthesis with Higher Order Ambisonics - V1.0 », in International Faust Conference, Mainz, 2018, p. 1‑9. ↩ ↩2
-
F. Zotter, M. Zaunschirm, M. Frank, et M. Kronlachner, « A beamformer to play with wall reflections: The icosahedral loudspeaker », Computer Music Journal, vol. 41, nᵒ 3, p. 50‑68, 2017. ↩