comparison projects/heavy/circularBuffer/SignalTabwrite.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
children
comparison
equal deleted inserted replaced
162:c3e8226a5651 163:20b52283c7b4
1 /**
2 * Copyright (c) 2014, 2015, Enzien Audio Ltd.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #include "SignalTabwrite.h"
18
19 hv_size_t sTabwrite_init(SignalTabwrite *o, HvTable *table) {
20 o->table = table;
21 o->head = 0;
22 return 0;
23 }
24
25 void sTabwrite_onMessage(HvBase *_c, SignalTabwrite *o, int letIn, const HvMessage *const m,
26 void (*sendMessage)(HvBase *, int, const HvMessage *const)) {
27 switch (letIn) {
28 // inlet 0 is the signal inlet
29 case 1: {
30 switch (msg_getType(m,0)) {
31 case BANG: o->head = 0; break;
32 case FLOAT: {
33 o->head = (msg_getFloat(m,0) >= 0.0f) ? (hv_uint32_t) msg_getFloat(m,0) : HV_TABWRITE_STOPPED;
34 break;
35 }
36 case SYMBOL: {
37 if (msg_compareSymbol(m, 0, "stop")) {
38 o->head = HV_TABWRITE_STOPPED;
39 }
40 break;
41 }
42 default: break;
43 }
44 break;
45 }
46 case 2: {
47 if (msg_isHashLike(m,0)) {
48 o->table = ctx_getTableForHash(_c, msg_getHash(m,0));
49 }
50 break;
51 }
52 default: break;
53 }
54 }