MCPcopy Create free account
hub / github.com/VCVRack/Befaco / getTransferFunction

Method getTransferFunction

src/ChowDSP.hpp:70–81  ·  view source on GitHub ↗

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) */

Source from the content-addressed store, hash-verified

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));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected