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

Method getTransferFunction

include/dsp/filter.hpp:264–277  ·  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

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;

Callers

nothing calls this directly

Calls 3

maxFunction · 0.85
cosFunction · 0.85
sinFunction · 0.85

Tested by

no test coverage detected