chris@162: /** chris@162: * Copyright (c) 2014, 2015, Enzien Audio Ltd. chris@162: * chris@162: * Permission to use, copy, modify, and/or distribute this software for any chris@162: * purpose with or without fee is hereby granted, provided that the above chris@162: * copyright notice and this permission notice appear in all copies. chris@162: * chris@162: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH chris@162: * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY chris@162: * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, chris@162: * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM chris@162: * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR chris@162: * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR chris@162: * PERFORMANCE OF THIS SOFTWARE. chris@162: */ chris@162: chris@162: #ifndef _HEAVY_SIGNAL_VAR_H_ chris@162: #define _HEAVY_SIGNAL_VAR_H_ chris@162: chris@162: #include "HvBase.h" chris@162: chris@162: // __var~f chris@162: // __varset~f chris@162: chris@162: typedef struct SignalVarf { chris@162: hv_bufferf_t v; chris@162: } SignalVarf; chris@162: chris@162: hv_size_t sVarf_init(SignalVarf *o, float k, float step, bool reverse); chris@162: chris@162: static inline void __hv_var_f(SignalVarf *o, hv_bOutf_t bOut) { chris@162: *bOut = o->v; chris@162: } chris@162: chris@162: static inline void sVarsetf_process(SignalVarf *o, hv_bInf_t bIn) { chris@162: o->v = bIn; chris@162: } chris@162: chris@162: void sVarf_onMessage(HvBase *_c, SignalVarf *o, const HvMessage *m); chris@162: chris@162: chris@162: chris@162: // __var~i chris@162: // __varset~i chris@162: chris@162: typedef struct SignalVari { chris@162: hv_bufferi_t v; chris@162: } SignalVari; chris@162: chris@162: hv_size_t sVari_init(SignalVari *o, int k, int step, bool reverse); chris@162: chris@162: static inline void __hv_var_i(SignalVari *o, hv_bOuti_t bOut) { chris@162: *bOut = o->v; chris@162: } chris@162: chris@162: #if HV_SIMD_AVX chris@162: #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: #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: #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: #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: #elif HV_SIMD_SSE chris@162: #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128i)(__v4si) {_a,_b,_c,_d}) chris@162: #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128i)(__v4si) {_d,_c,_b,_a}) chris@162: #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128) {_a,_b,_c,_d}) chris@162: #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((__m128) {_d,_c,_b,_a}) chris@162: #elif HV_SIMD_NEON chris@162: #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((int32x4_t) {_a,_b,_c,_d}) chris@162: #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((int32x4_t) {_d,_c,_b,_a}) chris@162: #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((float32x4_t) {_a,_b,_c,_d}) chris@162: #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=((float32x4_t) {_d,_c,_b,_a}) chris@162: #else // HV_SIMD_NONE chris@162: #define __hv_var_k_i_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a chris@162: #define __hv_var_k_i_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a chris@162: #define __hv_var_k_f_0(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a chris@162: #define __hv_var_k_f_1(_z,_a,_b,_c,_d,_e,_f,_g,_h) *_z=_a chris@162: #endif chris@162: // r == 0: forwards, r == 1: backwards chris@162: #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: #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: chris@162: static inline void sVarseti_process(SignalVari *o, hv_bIni_t bIn) { chris@162: o->v = bIn; chris@162: } chris@162: chris@162: void sVari_onMessage(HvBase *_c, SignalVari *o, const HvMessage *m); chris@162: chris@162: #endif // _HEAVY_SIGNAL_VAR_H_