Mercurial > hg > beaglert
comparison projects/heavy/samphold/Heavy.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 |
comparison
equal
deleted
inserted
replaced
159:1e7db6610600 | 160:5bcf04234f80 |
---|---|
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 "HvBase.h" | |
18 #include "HvTable.h" | |
19 | |
20 #if !HV_WIN | |
21 #pragma mark - Heavy Table | |
22 #endif | |
23 | |
24 int hv_table_resize(HvTable *o, hv_uint32_t newLength) { | |
25 return hTable_resize(o, newLength); | |
26 } | |
27 | |
28 float *hv_table_getBuffer(HvTable *o) { | |
29 return hTable_getBuffer(o); | |
30 } | |
31 | |
32 hv_size_t hv_table_getLength(HvTable *o) { | |
33 return hTable_getLength(o); | |
34 } | |
35 | |
36 | |
37 | |
38 #if !HV_WIN | |
39 #pragma mark - Heavy Message | |
40 #endif | |
41 | |
42 hv_size_t hv_msg_getByteSize (hv_uint32_t numElements) { | |
43 return msg_getByteSize(numElements); | |
44 } | |
45 | |
46 void hv_msg_init(HvMessage *m, int numElements, hv_uint32_t timestamp) { | |
47 msg_init(m, numElements, timestamp); | |
48 } | |
49 | |
50 hv_size_t hv_msg_getNumElements(const HvMessage *const m) { | |
51 return msg_getNumElements(m); | |
52 } | |
53 | |
54 double hv_msg_getTimestamp(const HvMessage *const m) { | |
55 return msg_getTimestamp(m); | |
56 } | |
57 | |
58 void hv_msg_setTimestamp(HvMessage *m, hv_uint32_t timestamp) { | |
59 msg_setTimestamp(m, timestamp); | |
60 } | |
61 | |
62 bool hv_msg_isBang(const HvMessage *const m, int i) { | |
63 return msg_isBang(m,i); | |
64 } | |
65 | |
66 void hv_msg_setBang(HvMessage *m, int i) { | |
67 msg_setBang(m,i); | |
68 } | |
69 | |
70 bool hv_msg_isFloat(const HvMessage *const m, int i) { | |
71 return msg_isFloat(m, i); | |
72 } | |
73 | |
74 float hv_msg_getFloat(const HvMessage *const m, int i) { | |
75 return msg_getFloat(m,i); | |
76 } | |
77 | |
78 void hv_msg_setFloat(HvMessage *m, int i, float f) { | |
79 msg_setFloat(m,i,f); | |
80 } | |
81 | |
82 bool hv_msg_isSymbol(const HvMessage *const m, int i) { | |
83 return msg_isSymbol(m,i); | |
84 } | |
85 | |
86 char *hv_msg_getSymbol(const HvMessage *const m, int i) { | |
87 return msg_getSymbol(m,i); | |
88 } | |
89 | |
90 void hv_msg_setSymbol(HvMessage *m, int i, char *s) { | |
91 msg_setSymbol(m,i,s); | |
92 } | |
93 | |
94 bool hv_msg_isHash(const HvMessage *const m, int i) { | |
95 return msg_isHash(m, i); | |
96 } | |
97 | |
98 unsigned int hv_msg_getHash(const HvMessage *const m, int i) { | |
99 return msg_getHash(m, i); | |
100 } | |
101 | |
102 bool hv_msg_hasFormat(const HvMessage *const m, const char *fmt) { | |
103 return msg_hasFormat(m, fmt); | |
104 } | |
105 | |
106 char *hv_msg_toString(const HvMessage *const m) { | |
107 return msg_toString(m); | |
108 } | |
109 | |
110 HvMessage *hv_msg_copy(HvMessage *m) { | |
111 return msg_copy(m); | |
112 } | |
113 | |
114 void hv_msg_free(HvMessage *m) { | |
115 msg_free(m); | |
116 } | |
117 | |
118 | |
119 | |
120 #if !HV_WIN | |
121 #pragma mark - Heavy Common | |
122 #endif | |
123 | |
124 double hv_getSampleRate(HvBase *c) { | |
125 return ctx_getSampleRate(c); | |
126 } | |
127 | |
128 int hv_getNumInputChannels(HvBase *c) { | |
129 return ctx_getNumInputChannels(c); | |
130 } | |
131 | |
132 int hv_getNumOutputChannels(HvBase *c) { | |
133 return ctx_getNumOutputChannels(c); | |
134 } | |
135 | |
136 const char *hv_getName(HvBase *c) { | |
137 return ctx_getName(c); | |
138 } | |
139 | |
140 void hv_setPrintHook(HvBase *c, void (*f)(double, const char *, const char *, void *)) { | |
141 ctx_setPrintHook(c, f); | |
142 } | |
143 | |
144 void hv_setSendHook(HvBase *c, void (*f)(double, const char *, const HvMessage *const, void *)) { | |
145 ctx_setSendHook(c, f); | |
146 } | |
147 | |
148 void hv_vscheduleMessageForReceiver(HvBase *c, const char *receiverName, const double delayMs, const char *format, ...) { | |
149 va_list ap; | |
150 va_start(ap, format); | |
151 | |
152 const int numElem = (int) hv_strlen(format); | |
153 HvMessage *m = HV_MESSAGE_ON_STACK(numElem); | |
154 msg_init(m, numElem, c->blockStartTimestamp + (hv_uint32_t) (hv_max_d(0.0, delayMs)*ctx_getSampleRate(c)/1000.0)); | |
155 for (int i = 0; i < numElem; i++) { | |
156 switch (format[i]) { | |
157 case 'b': msg_setBang(m,i); break; | |
158 case 'f': msg_setFloat(m, i, (float) va_arg(ap, double)); break; | |
159 case 's': msg_setSymbol(m, i, (char *) va_arg(ap, char *)); break; | |
160 default: break; | |
161 } | |
162 } | |
163 ctx_scheduleMessageForReceiver(c, receiverName, m); | |
164 | |
165 va_end(ap); | |
166 } | |
167 | |
168 void hv_scheduleMessageForReceiver(HvBase *c, const char *receiverName, double delayMs, HvMessage *m) { | |
169 hv_assert(delayMs >= 0.0); | |
170 msg_setTimestamp(m, c->blockStartTimestamp + (hv_uint32_t) (delayMs*ctx_getSampleRate(c)/1000.0)); | |
171 ctx_scheduleMessageForReceiver(c, receiverName, m); | |
172 } | |
173 | |
174 HvTable *hv_getTableForName(HvBase *c, const char *tableName) { | |
175 return ctx_getTableForName(c, tableName); | |
176 } | |
177 | |
178 void hv_cancelMessage(HvBase *c, HvMessage *m) { | |
179 ctx_cancelMessage(c, m, NULL); | |
180 } | |
181 | |
182 double hv_getCurrentTime(HvBase *c) { | |
183 return ((double) c->blockStartTimestamp)/c->sampleRate; | |
184 } | |
185 | |
186 void *hv_getUserData(HvBase *c) { | |
187 return ctx_getUserData(c); | |
188 } | |
189 | |
190 void hv_setUserData(HvBase *c, void *userData) { | |
191 ctx_setUserData(c, userData); | |
192 } | |
193 | |
194 void hv_setBasePath(HvBase *c, const char *basePath) { | |
195 ctx_setBasePath(c, basePath); | |
196 } |