Mercurial > hg > beaglert
comparison 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 |
comparison
equal
deleted
inserted
replaced
161:07735c9d95c8 | 162:c3e8226a5651 |
---|---|
1 /** | |
2 * Copyright (c) 2014, 2015, Enzien Audio Ltd. | |
3 * | |
4 * Permission to use, copy, modify, and/or distribute this software for any | |
5 * purpose with or without fee is hereby granted, provided that the above | |
6 * copyright notice and this permission notice appear in all copies. | |
7 * | |
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
14 * PERFORMANCE OF THIS SOFTWARE. | |
15 */ | |
16 | |
17 #ifndef _HEAVY_SIGNAL_VAR_H_ | |
18 #define _HEAVY_SIGNAL_VAR_H_ | |
19 | |
20 #include "HvBase.h" | |
21 | |
22 // __var~f | |
23 // __varset~f | |
24 | |
25 typedef struct SignalVarf { | |
26 hv_bufferf_t v; | |
27 } SignalVarf; | |
28 | |
29 hv_size_t sVarf_init(SignalVarf *o, float k, float step, bool reverse); | |
30 | |
31 static inline void __hv_var_f(SignalVarf *o, hv_bOutf_t bOut) { | |
32 *bOut = o->v; | |
33 } | |
34 | |
35 static inline void sVarsetf_process(SignalVarf *o, hv_bInf_t bIn) { | |
36 o->v = bIn; | |
37 } | |
38 | |
39 void sVarf_onMessage(HvBase *_c, SignalVarf *o, const HvMessage *m); | |
40 | |
41 | |
42 | |
43 // __var~i | |
44 // __varset~i | |
45 | |
46 typedef struct SignalVari { | |
47 hv_bufferi_t v; | |
48 } SignalVari; | |
49 | |
50 hv_size_t sVari_init(SignalVari *o, int k, int step, bool reverse); | |
51 | |
52 static inline void __hv_var_i(SignalVari *o, hv_bOuti_t bOut) { | |
53 *bOut = o->v; | |
54 } | |
55 | |
56 #if HV_SIMD_AVX | |
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}) | |
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}) | |
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}) | |
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}) | |
61 #elif HV_SIMD_SSE | |
62 #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128i)(__v4si) {_a,_b,_c,_d}) | |
63 #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128i)(__v4si) {_d,_c,_b,_a}) | |
64 #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128) {_a,_b,_c,_d}) | |
65 #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128) {_d,_c,_b,_a}) | |
66 #elif HV_SIMD_NEON | |
67 #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((int32x4_t) {_a,_b,_c,_d}) | |
68 #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((int32x4_t) {_d,_c,_b,_a}) | |
69 #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((float32x4_t) {_a,_b,_c,_d}) | |
70 #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((float32x4_t) {_d,_c,_b,_a}) | |
71 #else // HV_SIMD_NONE | |
72 #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a | |
73 #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a | |
74 #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a | |
75 #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a | |
76 #endif | |
77 // r == 0: forwards, r == 1: backwards | |
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) | |
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) | |
80 | |
81 static inline void sVarseti_process(SignalVari *o, hv_bIni_t bIn) { | |
82 o->v = bIn; | |
83 } | |
84 | |
85 void sVari_onMessage(HvBase *_c, SignalVari *o, const HvMessage *m); | |
86 | |
87 #endif // _HEAVY_SIGNAL_VAR_H_ |