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