annotate projects/heavy/envelopeTrigger/ControlSystem.c @ 162:c3e8226a5651 heavy-updated

- added additional flags to C rules (-DNDEBUG, -mfpu=neon) - sample-accurate envelope triggering pd/heavy example
author chnrx <chris.heinrichs@gmail.com>
date Thu, 12 Nov 2015 14:59:46 +0000
parents
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 "ControlSystem.h"
chris@162 18 #include "HvTable.h"
chris@162 19
chris@162 20 void cSystem_onMessage(HvBase *_c, void *o, int letIn, const HvMessage *const m,
chris@162 21 void (*sendMessage)(HvBase *, int, const HvMessage *const)) {
chris@162 22
chris@162 23 HvMessage *n = HV_MESSAGE_ON_STACK(1);
chris@162 24 if (msg_compareSymbol(m, 0, "samplerate")) {
chris@162 25 msg_initWithFloat(n, msg_getTimestamp(m), (float) ctx_getSampleRate(_c));
chris@162 26 } else if (msg_compareSymbol(m, 0, "numInputChannels")) {
chris@162 27 msg_initWithFloat(n, msg_getTimestamp(m), (float) ctx_getNumInputChannels(_c));
chris@162 28 } else if (msg_compareSymbol(m, 0, "numOutputChannels")) {
chris@162 29 msg_initWithFloat(n, msg_getTimestamp(m), (float) ctx_getNumOutputChannels(_c));
chris@162 30 } else if (msg_compareSymbol(m, 0, "currentTime")) {
chris@162 31 msg_initWithFloat(n, msg_getTimestamp(m), (float) msg_getTimestamp(m));
chris@162 32 } else if (msg_compareSymbol(m, 0, "table")) {
chris@162 33 // NOTE(mhroth): no need to check message format for symbols as table lookup will fail otherwise
chris@162 34 HvTable *o = ctx_getTableForHash(_c, msg_getHash(m,1));
chris@162 35 if (o != NULL) {
chris@162 36 if (msg_compareSymbol(m, 2, "length")) {
chris@162 37 msg_initWithFloat(n, msg_getTimestamp(m), (float) hTable_getLength(o));
chris@162 38 } else if (msg_compareSymbol(m, 2, "size")) {
chris@162 39 msg_initWithFloat(n, msg_getTimestamp(m), (float) hTable_getSize(o));
chris@162 40 } else if (msg_compareSymbol(m, 2, "head")) {
chris@162 41 msg_initWithFloat(n, msg_getTimestamp(m), (float) hTable_getHead(o));
chris@162 42 } else return;
chris@162 43 } else return;
chris@162 44 } else return;
chris@162 45 sendMessage(_c, 0, n);
chris@162 46 }