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) */
| 68 | s: normalized angular frequency equal to $2 \pi f / f_{sr}$ ($\pi$ is the Nyquist frequency) |
| 69 | */ |
| 70 | std::complex<T> getTransferFunction(T s) { |
| 71 | // Compute sum(a_k z^-k) / sum(b_k z^-k) where z = e^(i s) |
| 72 | std::complex<T> bSum(b[0], 0); |
| 73 | std::complex<T> aSum(1, 0); |
| 74 | for (int i = 1; i < ORDER; i++) { |
| 75 | T p = -i * s; |
| 76 | std::complex<T> z(simd::cos(p), simd::sin(p)); |
| 77 | bSum += b[i] * z; |
| 78 | aSum += a[i - 1] * z; |
| 79 | } |
| 80 | return bSum / aSum; |
| 81 | } |
| 82 | |
| 83 | T getFrequencyResponse(T f) { |
| 84 | return simd::abs(getTransferFunction(2 * M_PI * f)); |
nothing calls this directly
no outgoing calls
no test coverage detected