annotate projects/heavy/envelopeTrigger/ControlUnop.c @ 163:20b52283c7b4 heavy-updated

- added circular buffer pd/heavy example (works but process needs to be killed manually if launched via ssh?)
author chnrx <chris.heinrichs@gmail.com>
date Thu, 12 Nov 2015 15:55:30 +0000
parents c3e8226a5651
children
rev   line source
chris@162 1 /**
chris@162 2 * Copyright (c) 2014, 2015, Enzien Audio Ltd.
chris@162 3 *
chris@162 4 * Permission to use, copy, modify, and/or distribute this software for any
chris@162 5 * purpose with or without fee is hereby granted, provided that the above
chris@162 6 * copyright notice and this permission notice appear in all copies.
chris@162 7 *
chris@162 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
chris@162 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
chris@162 10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
chris@162 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
chris@162 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
chris@162 13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
chris@162 14 * PERFORMANCE OF THIS SOFTWARE.
chris@162 15 */
chris@162 16
chris@162 17 #include "ControlUnop.h"
chris@162 18 #include "HvBase.h"
chris@162 19
chris@162 20 void cUnop_onMessage(HvBase *_c, UnopType op, const HvMessage *const m,
chris@162 21 void (*sendMessage)(HvBase *, int, const HvMessage *const )) {
chris@162 22 if (msg_isFloat(m, 0)) {
chris@162 23 float f = msg_getFloat(m, 0);
chris@162 24 switch (op) {
chris@162 25 case HV_UNOP_SIN: f = hv_sin_f(f); break;
chris@162 26 case HV_UNOP_SINH: f = hv_sinh_f(f); break;
chris@162 27 case HV_UNOP_COS: f = hv_cos_f(f); break;
chris@162 28 case HV_UNOP_COSH: f = hv_cosh_f(f); break;
chris@162 29 case HV_UNOP_TAN: f = hv_tan_f(f); break;
chris@162 30 case HV_UNOP_TANH: f = hv_tanh_f(f); break;
chris@162 31 case HV_UNOP_ASIN: f = hv_asin_f(f); break;
chris@162 32 case HV_UNOP_ASINH: f = hv_asinh_f(f); break;
chris@162 33 case HV_UNOP_ACOS: f = hv_acos_f(f); break;
chris@162 34 case HV_UNOP_ACOSH: f = hv_acosh_f(f); break;
chris@162 35 case HV_UNOP_ATAN: f = hv_atan_f(f); break;
chris@162 36 case HV_UNOP_ATANH: f = hv_atanh_f(f); break;
chris@162 37 case HV_UNOP_EXP: f = hv_exp_f(f); break;
chris@162 38 case HV_UNOP_ABS: f = hv_abs_f(f); break;
chris@162 39 case HV_UNOP_SQRT: f = (f > 0.0f) ? hv_sqrt_f(f) : 0.0f; break;
chris@162 40 case HV_UNOP_LOG: f = (f > 0.0f) ? hv_log_f(f) : 0.0f; break;
chris@162 41 case HV_UNOP_LOG2: f = (f > 0.0f) ? hv_log2_f(f) : 0.0f; break;
chris@162 42 case HV_UNOP_LOG10: f = (f > 0.0f) ? hv_log10_f(f) : 0.0f; break;
chris@162 43 case HV_UNOP_CEIL: f = hv_ceil_f(f); break;
chris@162 44 case HV_UNOP_FLOOR: f = hv_floor_f(f); break;
chris@162 45 case HV_UNOP_ROUND: f = hv_round_f(f); break;
chris@162 46 default: return;
chris@162 47 }
chris@162 48 HvMessage *n = HV_MESSAGE_ON_STACK(1);
chris@162 49 msg_initWithFloat(n, m->timestamp, f);
chris@162 50 sendMessage(_c, 0, n);
chris@162 51 }
chris@162 52 }