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: #include "SignalVar.h" chris@162: chris@162: // __var~f chris@162: chris@162: static void sVarf_update(SignalVarf *o, float k, float step, bool reverse) { chris@162: #if HV_SIMD_AVX chris@162: if (reverse) o->v = _mm256_setr_ps(k+7.0f*step, k+6.0f*step, k+5.0f*step, k+4.0f*step, k+3.0f*step, k+2.0f*step, k+step, k); chris@162: else o->v = _mm256_set_ps(k+7.0f*step, k+6.0f*step, k+5.0f*step, k+4.0f*step, k+3.0f*step, k+2.0f*step, k+step, k); chris@162: #elif HV_SIMD_SSE chris@162: if (reverse) o->v = _mm_setr_ps(k+3.0f*step, k+2.0f*step, k+step, k); chris@162: else o->v = _mm_set_ps(k+3.0f*step, k+2.0f*step, k+step, k); chris@162: #elif HV_SIMD_NEON chris@162: if (reverse) o->v = (float32x4_t) {3.0f*step+k, 2.0f*step+k, step+k, k}; chris@162: else o->v = (float32x4_t) {k, step+k, 2.0f*step+k, 3.0f*step+k}; chris@162: #else // HV_SIMD_NONE chris@162: o->v = k; chris@162: #endif chris@162: } chris@162: chris@162: hv_size_t sVarf_init(SignalVarf *o, float k, float step, bool reverse) { chris@162: sVarf_update(o, k, step, reverse); chris@162: return 0; chris@162: } chris@162: chris@162: void sVarf_onMessage(HvBase *_c, SignalVarf *o, const HvMessage *m) { chris@162: if (msg_isFloat(m,0)) { chris@162: sVarf_update(o, msg_getFloat(m,0), msg_isFloat(m,1) ? msg_getFloat(m,1) : 0.0f, msg_getNumElements(m) == 3); chris@162: } chris@162: } chris@162: chris@162: chris@162: chris@162: // __var~i chris@162: chris@162: static void sVari_update(SignalVari *o, int k, int step, bool reverse) { chris@162: #if HV_SIMD_AVX chris@162: if (reverse) o->v = _mm256_setr_epi32(k+7*step, k+6*step, k+5*step, k+4*step, k+3*step, k+2*step, k+step, k); chris@162: else o->v = _mm256_set_epi32(k+7*step, k+6*step, k+5*step, k+4*step, k+3*step, k+2*step, k+step, k); chris@162: #elif HV_SIMD_SSE chris@162: if (reverse) o->v = _mm_setr_epi32(k+3*step, k+2*step, k+step, k); chris@162: else o->v = _mm_set_epi32(k+3*step, k+2*step, k+step, k); chris@162: #elif HV_SIMD_NEON chris@162: if (reverse) o->v = (int32x4_t) {3*step+k, 2*step+k, step+k, k}; chris@162: else o->v = (int32x4_t) {k, step+k, 2*step+k, 3*step+k}; chris@162: #else // HV_SIMD_NEON chris@162: o->v = k; chris@162: #endif chris@162: } chris@162: chris@162: hv_size_t sVari_init(SignalVari *o, int k, int step, bool reverse) { chris@162: sVari_update(o, k, step, reverse); chris@162: return 0; chris@162: } chris@162: chris@162: void sVari_onMessage(HvBase *_c, SignalVari *o, const HvMessage *m) { chris@162: if (msg_isFloat(m,0)) { chris@162: sVari_update(o, (int) msg_getFloat(m,0), msg_isFloat(m,1) ? (int) msg_getFloat(m,1) : 0, msg_getNumElements(m) == 3); chris@162: } chris@162: }