Computes the complex transfer function $H(s)$ at a particular frequency s: normalized angular frequency equal to $2 \pi f / f_{sr}$ ($\pi$ is the Nyquist frequency) */
| 262 | s: normalized angular frequency equal to $2 \pi f / f_{sr}$ ($\pi$ is the Nyquist frequency) |
| 263 | */ |
| 264 | std::complex<T> getTransferFunction(T s) { |
| 265 | // Compute sum(a_k z^-k) / sum(b_k z^-k) where z = e^(i s) |
| 266 | std::complex<T> bSum(b[0], 0); |
| 267 | std::complex<T> aSum(1, 0); |
| 268 | for (int i = 1; i < std::max(B_ORDER, A_ORDER); i++) { |
| 269 | T p = -i * s; |
| 270 | std::complex<T> z(simd::cos(p), simd::sin(p)); |
| 271 | if (i < B_ORDER) |
| 272 | bSum += b[i] * z; |
| 273 | if (i < A_ORDER) |
| 274 | aSum += a[i - 1] * z; |
| 275 | } |
| 276 | return bSum / aSum; |
| 277 | } |
| 278 | |
| 279 | T getFrequencyResponse(T f) { |
| 280 | // T hReal, hImag; |