annotate projects/heavy/hello-world/SignalRPole.h @ 160:5bcf04234f80 heavy-updated

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