annotate projects/heavy/envelopeTrigger/SignalVar.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 _HEAVY_SIGNAL_VAR_H_
chris@162 18 #define _HEAVY_SIGNAL_VAR_H_
chris@162 19
chris@162 20 #include "HvBase.h"
chris@162 21
chris@162 22 // __var~f
chris@162 23 // __varset~f
chris@162 24
chris@162 25 typedef struct SignalVarf {
chris@162 26 hv_bufferf_t v;
chris@162 27 } SignalVarf;
chris@162 28
chris@162 29 hv_size_t sVarf_init(SignalVarf *o, float k, float step, bool reverse);
chris@162 30
chris@162 31 static inline void __hv_var_f(SignalVarf *o, hv_bOutf_t bOut) {
chris@162 32 *bOut = o->v;
chris@162 33 }
chris@162 34
chris@162 35 static inline void sVarsetf_process(SignalVarf *o, hv_bInf_t bIn) {
chris@162 36 o->v = bIn;
chris@162 37 }
chris@162 38
chris@162 39 void sVarf_onMessage(HvBase *_c, SignalVarf *o, const HvMessage *m);
chris@162 40
chris@162 41
chris@162 42
chris@162 43 // __var~i
chris@162 44 // __varset~i
chris@162 45
chris@162 46 typedef struct SignalVari {
chris@162 47 hv_bufferi_t v;
chris@162 48 } SignalVari;
chris@162 49
chris@162 50 hv_size_t sVari_init(SignalVari *o, int k, int step, bool reverse);
chris@162 51
chris@162 52 static inline void __hv_var_i(SignalVari *o, hv_bOuti_t bOut) {
chris@162 53 *bOut = o->v;
chris@162 54 }
chris@162 55
chris@162 56 #if HV_SIMD_AVX
chris@162 57 #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m256i)(__v8si) {_a,_b,_c,_d,_e,_f,_g,_h})
chris@162 58 #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m256i)(__v8si) {_h,_g,_f,_e,_d,_c,_b,_a})
chris@162 59 #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m256) {_a,_b,_c,_d,_e,_f,_g,_h})
chris@162 60 #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m256) {_h,_g,_f,_e,_d,_c,_b,_a})
chris@162 61 #elif HV_SIMD_SSE
chris@162 62 #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128i)(__v4si) {_a,_b,_c,_d})
chris@162 63 #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128i)(__v4si) {_d,_c,_b,_a})
chris@162 64 #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128) {_a,_b,_c,_d})
chris@162 65 #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128) {_d,_c,_b,_a})
chris@162 66 #elif HV_SIMD_NEON
chris@162 67 #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((int32x4_t) {_a,_b,_c,_d})
chris@162 68 #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((int32x4_t) {_d,_c,_b,_a})
chris@162 69 #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((float32x4_t) {_a,_b,_c,_d})
chris@162 70 #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((float32x4_t) {_d,_c,_b,_a})
chris@162 71 #else // HV_SIMD_NONE
chris@162 72 #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a
chris@162 73 #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a
chris@162 74 #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a
chris@162 75 #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a
chris@162 76 #endif
chris@162 77 // r == 0: forwards, r == 1: backwards
chris@162 78 #define __hv_var_k_i(_z,_a,_b,_c,_d,_e,_f,_g,_h,_r) __hv_var_k_i_##_r(_z,_a,_b,_c,_d,_e,_f,_g,_h)
chris@162 79 #define __hv_var_k_f(_z,_a,_b,_c,_d,_e,_f,_g,_h,_r) __hv_var_k_f_##_r(_z,_a,_b,_c,_d,_e,_f,_g,_h)
chris@162 80
chris@162 81 static inline void sVarseti_process(SignalVari *o, hv_bIni_t bIn) {
chris@162 82 o->v = bIn;
chris@162 83 }
chris@162 84
chris@162 85 void sVari_onMessage(HvBase *_c, SignalVari *o, const HvMessage *m);
chris@162 86
chris@162 87 #endif // _HEAVY_SIGNAL_VAR_H_