chris@160: /** chris@160: * Copyright (c) 2014, 2015, Enzien Audio Ltd. chris@160: * chris@160: * Permission to use, copy, modify, and/or distribute this software for any chris@160: * purpose with or without fee is hereby granted, provided that the above chris@160: * copyright notice and this permission notice appear in all copies. chris@160: * chris@160: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH chris@160: * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY chris@160: * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, chris@160: * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM chris@160: * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR chris@160: * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR chris@160: * PERFORMANCE OF THIS SOFTWARE. chris@160: */ chris@160: chris@160: #ifndef _SIGNAL_RPOLE_H_ chris@160: #define _SIGNAL_RPOLE_H_ chris@160: chris@160: #include "HvBase.h" chris@160: #include "SignalDel1.h" chris@160: #include "HeavyMath.h" chris@160: chris@160: // implements y[n] = x[n] - a*y[n-1] chris@160: // H(z) = 1/(1+a*z^-1) chris@160: typedef struct SignalRPole { chris@160: #if HV_SIMD_AVX chris@160: SignalDel1 sDel1_fxiLN; chris@160: SignalDel1 sDel1_kjkpV; chris@160: SignalDel1 sDel1_dkIWc; chris@160: SignalDel1 sDel1_bVeoW; chris@160: SignalDel1 sDel1_PulZn; chris@160: SignalDel1 sDel1_yTFig; chris@160: SignalDel1 sDel1_Is9Qf; chris@160: SignalDel1 sDel1_LIyNt; chris@160: SignalDel1 sDel1_VqpU3; chris@160: SignalDel1 sDel1_ZVYeg; chris@160: SignalDel1 sDel1_IVAZh; chris@160: SignalDel1 sDel1_F8WrY; chris@160: SignalDel1 sDel1_rkFMy; chris@160: SignalDel1 sDel1_BeqSK; chris@160: hv_bufferf_t ym; chris@160: #elif HV_SIMD_SSE || HV_SIMD_NEON chris@160: SignalDel1 sDel1_i8Twk; chris@160: SignalDel1 sDel1_KYibU; chris@160: SignalDel1 sDel1_spa5V; chris@160: SignalDel1 sDel1_3HXdb; chris@160: SignalDel1 sDel1_Aj1oK; chris@160: SignalDel1 sDel1_jNX1g; chris@160: hv_bufferf_t ym; chris@160: #else chris@160: hv_bufferf_t ym; chris@160: #endif chris@160: } SignalRPole; chris@160: chris@160: hv_size_t sRPole_init(SignalRPole *o); chris@160: chris@160: void sRPole_onMessage(HvBase *_c, SignalRPole *o, int letIn, const HvMessage *m); chris@160: chris@160: static inline void __hv_rpole_f(SignalRPole *o, hv_bInf_t bIn0, hv_bInf_t bIn1, hv_bOutf_t bOut) { chris@160: #if HV_SIMD_AVX chris@160: hv_bufferf_t a, b, c, d, e, f, g, i, j, k, l, m, n; chris@160: __hv_del1_f(&o->sDel1_fxiLN, bIn1, &a); chris@160: __hv_mul_f(bIn1, a, &b); chris@160: __hv_del1_f(&o->sDel1_kjkpV, a, &a); chris@160: __hv_mul_f(b, a, &c); chris@160: __hv_del1_f(&o->sDel1_dkIWc, a, &a); chris@160: __hv_mul_f(c, a, &d); chris@160: __hv_del1_f(&o->sDel1_bVeoW, a, &a); chris@160: __hv_mul_f(d, a, &e); chris@160: __hv_del1_f(&o->sDel1_PulZn, a, &a); chris@160: __hv_mul_f(e, a, &f); chris@160: __hv_del1_f(&o->sDel1_yTFig, a, &a); chris@160: __hv_mul_f(f, a, &g); chris@160: __hv_del1_f(&o->sDel1_Is9Qf, a, &a); chris@160: __hv_mul_f(g, a, &a); chris@160: __hv_del1_f(&o->sDel1_LIyNt, bIn0, &i); chris@160: __hv_del1_f(&o->sDel1_VqpU3, i, &j); chris@160: __hv_del1_f(&o->sDel1_ZVYeg, j, &k); chris@160: __hv_del1_f(&o->sDel1_IVAZh, k, &l); chris@160: __hv_del1_f(&o->sDel1_F8WrY, l, &m); chris@160: __hv_del1_f(&o->sDel1_rkFMy, m, &n); chris@160: __hv_mul_f(i, bIn1, &i); chris@160: __hv_sub_f(bIn0, i, &i); chris@160: __hv_fma_f(j, b, i, &i); chris@160: __hv_mul_f(k, c, &c); chris@160: __hv_sub_f(i, c, &c); chris@160: __hv_fma_f(l, d, c, &c); chris@160: __hv_mul_f(m, e, &e); chris@160: __hv_sub_f(c, e, &e); chris@160: __hv_fma_f(n, f, e, &e); chris@160: __hv_del1_f(&o->sDel1_BeqSK, n, &n); chris@160: __hv_mul_f(n, g, &g); chris@160: __hv_sub_f(e, g, &g); chris@160: __hv_fma_f(a, o->ym, g, &g); chris@160: o->ym = g; chris@160: *bOut = g; chris@160: #elif HV_SIMD_SSE || HV_SIMD_NEON chris@160: hv_bufferf_t a, b, c, e, f; chris@160: __hv_del1_f(&o->sDel1_i8Twk, bIn1, &a); chris@160: __hv_mul_f(bIn1, a, &b); chris@160: __hv_del1_f(&o->sDel1_KYibU, a, &a); chris@160: __hv_mul_f(b, a, &c); chris@160: __hv_del1_f(&o->sDel1_spa5V, a, &a); chris@160: __hv_mul_f(c, a, &a); chris@160: __hv_del1_f(&o->sDel1_3HXdb, bIn0, &e); chris@160: __hv_del1_f(&o->sDel1_Aj1oK, e, &f); chris@160: __hv_mul_f(e, bIn1, &e); chris@160: __hv_sub_f(bIn0, e, &e); chris@160: __hv_fma_f(f, b, e, &e); chris@160: __hv_del1_f(&o->sDel1_jNX1g, f, &f); chris@160: __hv_mul_f(f, c, &c); chris@160: __hv_sub_f(e, c, &c); chris@160: __hv_fma_f(a, o->ym, c, &c); chris@160: o->ym = c; chris@160: *bOut = c; chris@160: #else chris@160: *bOut = bIn0 - bIn1 * o->ym; chris@160: o->ym = *bOut; chris@160: #endif chris@160: } chris@160: chris@160: #endif // _SIGNAL_RPOLE_H_