annotate projects/heavy/hello-world/SignalVar.c @ 160:5bcf04234f80 heavy-updated

- added -std=c99 to Makefile for user-supplied C files (required for heavy files) - changed heavy core render.cpp file to use latest API and removed all redundant functions (e.g. foleyDesigner/touchkey stuff) - use build_pd.sh to compile and run pd files (-h for usage instructions)
author chnrx <chris.heinrichs@gmail.com>
date Thu, 05 Nov 2015 18:58:26 +0000
parents
children
rev   line source
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 #include "SignalVar.h"
chris@160 18
chris@160 19 // __var~f
chris@160 20
chris@160 21 static void sVarf_update(SignalVarf *o, float k, float step, bool reverse) {
chris@160 22 #if HV_SIMD_AVX
chris@160 23 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@160 24 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@160 25 #elif HV_SIMD_SSE
chris@160 26 if (reverse) o->v = _mm_setr_ps(k+3.0f*step, k+2.0f*step, k+step, k);
chris@160 27 else o->v = _mm_set_ps(k+3.0f*step, k+2.0f*step, k+step, k);
chris@160 28 #elif HV_SIMD_NEON
chris@160 29 if (reverse) o->v = (float32x4_t) {3.0f*step+k, 2.0f*step+k, step+k, k};
chris@160 30 else o->v = (float32x4_t) {k, step+k, 2.0f*step+k, 3.0f*step+k};
chris@160 31 #else // HV_SIMD_NONE
chris@160 32 o->v = k;
chris@160 33 #endif
chris@160 34 }
chris@160 35
chris@160 36 hv_size_t sVarf_init(SignalVarf *o, float k, float step, bool reverse) {
chris@160 37 sVarf_update(o, k, step, reverse);
chris@160 38 return 0;
chris@160 39 }
chris@160 40
chris@160 41 void sVarf_onMessage(HvBase *_c, SignalVarf *o, const HvMessage *m) {
chris@160 42 if (msg_isFloat(m,0)) {
chris@160 43 sVarf_update(o, msg_getFloat(m,0), msg_isFloat(m,1) ? msg_getFloat(m,1) : 0.0f, msg_getNumElements(m) == 3);
chris@160 44 }
chris@160 45 }
chris@160 46
chris@160 47
chris@160 48
chris@160 49 // __var~i
chris@160 50
chris@160 51 static void sVari_update(SignalVari *o, int k, int step, bool reverse) {
chris@160 52 #if HV_SIMD_AVX
chris@160 53 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@160 54 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@160 55 #elif HV_SIMD_SSE
chris@160 56 if (reverse) o->v = _mm_setr_epi32(k+3*step, k+2*step, k+step, k);
chris@160 57 else o->v = _mm_set_epi32(k+3*step, k+2*step, k+step, k);
chris@160 58 #elif HV_SIMD_NEON
chris@160 59 if (reverse) o->v = (int32x4_t) {3*step+k, 2*step+k, step+k, k};
chris@160 60 else o->v = (int32x4_t) {k, step+k, 2*step+k, 3*step+k};
chris@160 61 #else // HV_SIMD_NEON
chris@160 62 o->v = k;
chris@160 63 #endif
chris@160 64 }
chris@160 65
chris@160 66 hv_size_t sVari_init(SignalVari *o, int k, int step, bool reverse) {
chris@160 67 sVari_update(o, k, step, reverse);
chris@160 68 return 0;
chris@160 69 }
chris@160 70
chris@160 71 void sVari_onMessage(HvBase *_c, SignalVari *o, const HvMessage *m) {
chris@160 72 if (msg_isFloat(m,0)) {
chris@160 73 sVari_update(o, (int) msg_getFloat(m,0), msg_isFloat(m,1) ? (int) msg_getFloat(m,1) : 0, msg_getNumElements(m) == 3);
chris@160 74 }
chris@160 75 }