annotate projects/heavy/envelopeTrigger/SignalRPole.h @ 162:c3e8226a5651 heavy-updated

- added additional flags to C rules (-DNDEBUG, -mfpu=neon) - sample-accurate envelope triggering pd/heavy example
author chnrx <chris.heinrichs@gmail.com>
date Thu, 12 Nov 2015 14:59:46 +0000
parents
children
rev   line source
chris@162 1 /**
chris@162 2 * Copyright (c) 2014, 2015, Enzien Audio Ltd.
chris@162 3 *
chris@162 4 * Permission to use, copy, modify, and/or distribute this software for any
chris@162 5 * purpose with or without fee is hereby granted, provided that the above
chris@162 6 * copyright notice and this permission notice appear in all copies.
chris@162 7 *
chris@162 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
chris@162 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
chris@162 10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
chris@162 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
chris@162 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
chris@162 13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
chris@162 14 * PERFORMANCE OF THIS SOFTWARE.
chris@162 15 */
chris@162 16
chris@162 17 #ifndef _SIGNAL_RPOLE_H_
chris@162 18 #define _SIGNAL_RPOLE_H_
chris@162 19
chris@162 20 #include "HvBase.h"
chris@162 21 #include "SignalDel1.h"
chris@162 22 #include "HeavyMath.h"
chris@162 23
chris@162 24 // implements y[n] = x[n] - a*y[n-1]
chris@162 25 // H(z) = 1/(1+a*z^-1)
chris@162 26 typedef struct SignalRPole {
chris@162 27 #if HV_SIMD_AVX
chris@162 28 SignalDel1 sDel1_fxiLN;
chris@162 29 SignalDel1 sDel1_kjkpV;
chris@162 30 SignalDel1 sDel1_dkIWc;
chris@162 31 SignalDel1 sDel1_bVeoW;
chris@162 32 SignalDel1 sDel1_PulZn;
chris@162 33 SignalDel1 sDel1_yTFig;
chris@162 34 SignalDel1 sDel1_Is9Qf;
chris@162 35 SignalDel1 sDel1_LIyNt;
chris@162 36 SignalDel1 sDel1_VqpU3;
chris@162 37 SignalDel1 sDel1_ZVYeg;
chris@162 38 SignalDel1 sDel1_IVAZh;
chris@162 39 SignalDel1 sDel1_F8WrY;
chris@162 40 SignalDel1 sDel1_rkFMy;
chris@162 41 SignalDel1 sDel1_BeqSK;
chris@162 42 hv_bufferf_t ym;
chris@162 43 #elif HV_SIMD_SSE || HV_SIMD_NEON
chris@162 44 SignalDel1 sDel1_i8Twk;
chris@162 45 SignalDel1 sDel1_KYibU;
chris@162 46 SignalDel1 sDel1_spa5V;
chris@162 47 SignalDel1 sDel1_3HXdb;
chris@162 48 SignalDel1 sDel1_Aj1oK;
chris@162 49 SignalDel1 sDel1_jNX1g;
chris@162 50 hv_bufferf_t ym;
chris@162 51 #else
chris@162 52 hv_bufferf_t ym;
chris@162 53 #endif
chris@162 54 } SignalRPole;
chris@162 55
chris@162 56 hv_size_t sRPole_init(SignalRPole *o);
chris@162 57
chris@162 58 void sRPole_onMessage(HvBase *_c, SignalRPole *o, int letIn, const HvMessage *m);
chris@162 59
chris@162 60 static inline void __hv_rpole_f(SignalRPole *o, hv_bInf_t bIn0, hv_bInf_t bIn1, hv_bOutf_t bOut) {
chris@162 61 #if HV_SIMD_AVX
chris@162 62 hv_bufferf_t a, b, c, d, e, f, g, i, j, k, l, m, n;
chris@162 63 __hv_del1_f(&o->sDel1_fxiLN, bIn1, &a);
chris@162 64 __hv_mul_f(bIn1, a, &b);
chris@162 65 __hv_del1_f(&o->sDel1_kjkpV, a, &a);
chris@162 66 __hv_mul_f(b, a, &c);
chris@162 67 __hv_del1_f(&o->sDel1_dkIWc, a, &a);
chris@162 68 __hv_mul_f(c, a, &d);
chris@162 69 __hv_del1_f(&o->sDel1_bVeoW, a, &a);
chris@162 70 __hv_mul_f(d, a, &e);
chris@162 71 __hv_del1_f(&o->sDel1_PulZn, a, &a);
chris@162 72 __hv_mul_f(e, a, &f);
chris@162 73 __hv_del1_f(&o->sDel1_yTFig, a, &a);
chris@162 74 __hv_mul_f(f, a, &g);
chris@162 75 __hv_del1_f(&o->sDel1_Is9Qf, a, &a);
chris@162 76 __hv_mul_f(g, a, &a);
chris@162 77 __hv_del1_f(&o->sDel1_LIyNt, bIn0, &i);
chris@162 78 __hv_del1_f(&o->sDel1_VqpU3, i, &j);
chris@162 79 __hv_del1_f(&o->sDel1_ZVYeg, j, &k);
chris@162 80 __hv_del1_f(&o->sDel1_IVAZh, k, &l);
chris@162 81 __hv_del1_f(&o->sDel1_F8WrY, l, &m);
chris@162 82 __hv_del1_f(&o->sDel1_rkFMy, m, &n);
chris@162 83 __hv_mul_f(i, bIn1, &i);
chris@162 84 __hv_sub_f(bIn0, i, &i);
chris@162 85 __hv_fma_f(j, b, i, &i);
chris@162 86 __hv_mul_f(k, c, &c);
chris@162 87 __hv_sub_f(i, c, &c);
chris@162 88 __hv_fma_f(l, d, c, &c);
chris@162 89 __hv_mul_f(m, e, &e);
chris@162 90 __hv_sub_f(c, e, &e);
chris@162 91 __hv_fma_f(n, f, e, &e);
chris@162 92 __hv_del1_f(&o->sDel1_BeqSK, n, &n);
chris@162 93 __hv_mul_f(n, g, &g);
chris@162 94 __hv_sub_f(e, g, &g);
chris@162 95 __hv_fma_f(a, o->ym, g, &g);
chris@162 96 o->ym = g;
chris@162 97 *bOut = g;
chris@162 98 #elif HV_SIMD_SSE || HV_SIMD_NEON
chris@162 99 hv_bufferf_t a, b, c, e, f;
chris@162 100 __hv_del1_f(&o->sDel1_i8Twk, bIn1, &a);
chris@162 101 __hv_mul_f(bIn1, a, &b);
chris@162 102 __hv_del1_f(&o->sDel1_KYibU, a, &a);
chris@162 103 __hv_mul_f(b, a, &c);
chris@162 104 __hv_del1_f(&o->sDel1_spa5V, a, &a);
chris@162 105 __hv_mul_f(c, a, &a);
chris@162 106 __hv_del1_f(&o->sDel1_3HXdb, bIn0, &e);
chris@162 107 __hv_del1_f(&o->sDel1_Aj1oK, e, &f);
chris@162 108 __hv_mul_f(e, bIn1, &e);
chris@162 109 __hv_sub_f(bIn0, e, &e);
chris@162 110 __hv_fma_f(f, b, e, &e);
chris@162 111 __hv_del1_f(&o->sDel1_jNX1g, f, &f);
chris@162 112 __hv_mul_f(f, c, &c);
chris@162 113 __hv_sub_f(e, c, &c);
chris@162 114 __hv_fma_f(a, o->ym, c, &c);
chris@162 115 o->ym = c;
chris@162 116 *bOut = c;
chris@162 117 #else
chris@162 118 *bOut = bIn0 - bIn1 * o->ym;
chris@162 119 o->ym = *bOut;
chris@162 120 #endif
chris@162 121 }
chris@162 122
chris@162 123 #endif // _SIGNAL_RPOLE_H_