PAL Algorithms: Transforms and Group Delay
Direct DFT/DCT-related routines and the group-delay estimator.
|
|
|---|---|
KiratAlgCorePalAlgoGroupDelaySimpleSignature
void KiratAlgCorePalAlgoGroupDelaySimple( T_COMPLEX* pcInput, T_FLOAT* pfOutput, T_INT iNumFreqbins);Description
Derives group delay from a complex spectrum by calculating the phase, unwrapping it, scaling it to samples, and then taking frequency-domain phase differences. Mathematical operation
Let \(N=2(M-1)\) and \(P(a)=a\bmod 2\pi\) shifted into \([0,2\pi)\). From \(\theta_k=\operatorname{atan2}(\Im X_k,\Re X_k)\) the code forms \(\phi_0=0\) and \(\phi_k=\phi_{k-1}+P(P(\theta_k)-\phi_{k-1})\). After \(s_k=N\phi_k/(2\pi)\), the output is \(\tau_k=P_N(s_k-s_{k+1})\) for \(k=0,\ldots,M-2\), wrapped into \([0,N)\). |
|
KiratAlgCorePalAlgoMagDctSignature
void KiratAlgCorePalAlgoMagDct( T_FLOAT* pfInput, T_FLOAT* pfSpecOut, T_INT iNumFreqbins, T_INT iDataLength);Description
Calculates a direct DCT-II with scaling towards an orthonormal DCT. Mathematical operation
\(C_\mu=\sqrt{2/M}\,\alpha_\mu\sum_{n=0}^{L-1}x_n\cos\!\left[\pi(n+1/2)\mu/M\right]\), where \(\alpha_0=1/\sqrt2\) and \(\alpha_\mu=1\) for \(\mu>0\). |
|
KiratAlgCorePalAlgoMagDftSignature
void KiratAlgCorePalAlgoMagDft( T_FLOAT *pfInput, T_FLOAT *pfOutput, T_BOOL bSquare, T_INT iNumFreqbins, T_INT iDataLength );Description
Directly evaluates a DFT-like transform of a real-valued signal at frequencies from 0 to just below π. The function returns magnitude or squared magnitude rather than the complex spectrum. Mathematical operation
\(\omega_\mu=\pi\mu/M\), \(R_\mu=\sum_{n=0}^{L-1}x_n\cos(\omega_\mu n)\), \(I_\mu=-\sum_{n=0}^{L-1}x_n\sin(\omega_\mu n)\). Output: \(y_\mu=R_\mu^2+I_\mu^2\) if `bSquare`, otherwise \(y_\mu=\sqrt{R_\mu^2+I_\mu^2+\varepsilon_{\mathrm{SYS}}}\). |
|
KiratAlgCorePalAlgoMagIdctSignature
void KiratAlgCorePalAlgoMagIdct( T_FLOAT* pfSpecIn, T_FLOAT* pfOutput, T_INT iNumFreqbins, T_INT iDataLength);Description
Calculates the direct inverse DCT-II according to the summation and scaling implemented in the source code. Mathematical operation
The implementation first computes \(s_n=\sum_{\mu=0}^{M-1}C_\mu\cos[\pi(n+1/2)\mu/M]\). It then returns \(x_n=\sqrt{2/M}\,s_n\) for \(n>0\), while the first output sample receives an additional factor \(1/\sqrt2\): \(x_0=\sqrt{1/M}\,s_0\). |
|
KiratAlgCorePalAlgoMagIdftSignature
void KiratAlgCorePalAlgoMagIdft( T_FLOAT *pfSpecIn, T_FLOAT *pfOutput, T_BOOL bSquare, T_INT iNumFreqbins, T_INT iDataLength );Description
Synthesizes a time-domain sequence from real spectral magnitudes on the 0…π frequency grid. This is not a general complex IDFT because no phase information is supplied. Mathematical operation
\(\omega_n=\pi n/M\), \(R_n=\sum_{\mu=0}^{M-1}A_\mu\cos(\omega_n\mu)\), \(I_n=\sum_{\mu=0}^{M-1}A_\mu\sin(\omega_n\mu)\), followed by \(R_n,I_n\leftarrow(R_n,I_n)/(2\pi M)\). Output: \(y_n=R_n^2+I_n^2\) if `bSquare`, otherwise \(y_n=\sqrt{R_n^2+I_n^2+\varepsilon_{\mathrm{SYS}}}\). |