comparison projects/heavy/samphold/HvContext_bbb.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 5bcf04234f80
children
comparison
equal deleted inserted replaced
161:07735c9d95c8 162:c3e8226a5651
37 37
38 38
39 /* 39 /*
40 * Function Declarations 40 * Function Declarations
41 */ 41 */
42 static void cBinop_62MLs_sendMessage(HvBase *, int, const HvMessage *const); 42 static void cMsg_5KHpJ_sendMessage(HvBase *, int, const HvMessage *const);
43 static void cUnop_Rm4T9_sendMessage(HvBase *, int, const HvMessage *const); 43 static void cSystem_tEzb9_sendMessage(HvBase *, int, const HvMessage *const);
44 static void cRandom_Uxs9y_sendMessage(HvBase *, int, const HvMessage *const); 44 static void cBinop_DXD3m_sendMessage(HvBase *, int, const HvMessage *const);
45 static void cLoadbang_XJMP6_sendMessage(HvBase *, int, const HvMessage *const); 45 static void cBinop_tyjup_sendMessage(HvBase *, int, const HvMessage *const);
46 static void cMsg_eMw6t_sendMessage(HvBase *, int, const HvMessage *const); 46 static void cMsg_QrCwu_sendMessage(HvBase *, int, const HvMessage *const);
47 static void cBinop_vHnCM_sendMessage(HvBase *, int, const HvMessage *const); 47 static void cBinop_iWcBL_sendMessage(HvBase *, int, const HvMessage *const);
48 static void cBinop_PmuD1_sendMessage(HvBase *, int, const HvMessage *const); 48 static void cBinop_6USpC_sendMessage(HvBase *, int, const HvMessage *const);
49 static void cBinop_lT4qw_sendMessage(HvBase *, int, const HvMessage *const); 49 static void cBinop_QuDfQ_sendMessage(HvBase *, int, const HvMessage *const);
50 static void cBinop_vpZDi_sendMessage(HvBase *, int, const HvMessage *const); 50 static void cLoadbang_0Dgs1_sendMessage(HvBase *, int, const HvMessage *const);
51 static void cMsg_zpcIL_sendMessage(HvBase *, int, const HvMessage *const); 51 static void cVar_lxt7X_sendMessage(HvBase *, int, const HvMessage *const);
52 static void cMsg_pfnj7_sendMessage(HvBase *, int, const HvMessage *const); 52 static void cMsg_qW1tH_sendMessage(HvBase *, int, const HvMessage *const);
53 static void cSystem_lJZJR_sendMessage(HvBase *, int, const HvMessage *const); 53 static void cLoadbang_bGFum_sendMessage(HvBase *, int, const HvMessage *const);
54 static void cVar_cPxQc_sendMessage(HvBase *, int, const HvMessage *const); 54 static void cBinop_79eIJ_sendMessage(HvBase *, int, const HvMessage *const);
55 static void cBinop_1u9M5_sendMessage(HvBase *, int, const HvMessage *const); 55 static void cRandom_zn9Go_sendMessage(HvBase *, int, const HvMessage *const);
56 static void cLoadbang_AXnu9_sendMessage(HvBase *, int, const HvMessage *const); 56 static void cUnop_2Y2rq_sendMessage(HvBase *, int, const HvMessage *const);
57 57
58 58
59 59
60 /* 60 /*
61 * Static Helper Functions 61 * Static Helper Functions
97 Base(_c)->sendHook = NULL; 97 Base(_c)->sendHook = NULL;
98 Base(_c)->userData = NULL; 98 Base(_c)->userData = NULL;
99 Base(_c)->name = "bbb"; 99 Base(_c)->name = "bbb";
100 100
101 Base(_c)->numBytes = sizeof(Hv_bbb); 101 Base(_c)->numBytes = sizeof(Hv_bbb);
102 Base(_c)->numBytes += sVari_init(&_c->sVari_ecpIx, 0, 0, false); 102 Base(_c)->numBytes += sVari_init(&_c->sVari_9lqOg, 0, 0, false);
103 Base(_c)->numBytes += sVarf_init(&_c->sVarf_VF9rD, 0.0f, 0.0f, false); 103 Base(_c)->numBytes += sVarf_init(&_c->sVarf_a6sNx, 0.0f, 0.0f, false);
104 Base(_c)->numBytes += sVarf_init(&_c->sVarf_0bFmM, 0.0f, 0.0f, false); 104 Base(_c)->numBytes += sVarf_init(&_c->sVarf_l59CR, 0.0f, 0.0f, false);
105 Base(_c)->numBytes += sRPole_init(&_c->sRPole_WxgWS); 105 Base(_c)->numBytes += sRPole_init(&_c->sRPole_ACVjc);
106 Base(_c)->numBytes += sPhasor_k_init(&_c->sPhasor_YcHM3, 880.0f, sampleRate); 106 Base(_c)->numBytes += sPhasor_k_init(&_c->sPhasor_GKtI5, 880.0f, sampleRate);
107 Base(_c)->numBytes += sDel1_init(&_c->sDel1_FfVih); 107 Base(_c)->numBytes += sDel1_init(&_c->sDel1_OZ8Kl);
108 Base(_c)->numBytes += sSamphold_init(&_c->sSamphold_hq9sm); 108 Base(_c)->numBytes += sSamphold_init(&_c->sSamphold_XcpkT);
109 Base(_c)->numBytes += sPhasor_init(&_c->sPhasor_n1TcS, sampleRate); 109 Base(_c)->numBytes += sPhasor_init(&_c->sPhasor_6rvdw, sampleRate);
110 Base(_c)->numBytes += cBinop_init(&_c->cBinop_62MLs, 8388610.0f); // __mul 110 Base(_c)->numBytes += cBinop_init(&_c->cBinop_tyjup, 0.0f); // __mul
111 Base(_c)->numBytes += cRandom_init(&_c->cRandom_Uxs9y, -1512500956); 111 Base(_c)->numBytes += cBinop_init(&_c->cBinop_iWcBL, 0.0f); // __max
112 Base(_c)->numBytes += cBinop_init(&_c->cBinop_vHnCM, 1.0f); // __min 112 Base(_c)->numBytes += cBinop_init(&_c->cBinop_6USpC, 1.0f); // __min
113 Base(_c)->numBytes += cBinop_init(&_c->cBinop_PmuD1, 0.0f); // __max 113 Base(_c)->numBytes += cVar_init_f(&_c->cVar_lxt7X, 1.0f);
114 Base(_c)->numBytes += cBinop_init(&_c->cBinop_lT4qw, 0.0f); // __mul 114 Base(_c)->numBytes += cBinop_init(&_c->cBinop_79eIJ, 8388610.0f); // __mul
115 Base(_c)->numBytes += cVar_init_f(&_c->cVar_cPxQc, 1.0f); 115 Base(_c)->numBytes += cRandom_init(&_c->cRandom_zn9Go, 1159211063);
116 116
117 // loadbang 117 // loadbang
118 ctx_scheduleMessage(Base(_c), msg_initWithBang(HV_MESSAGE_ON_STACK(1), 0), &cLoadbang_AXnu9_sendMessage, 0); 118 ctx_scheduleMessage(Base(_c), msg_initWithBang(HV_MESSAGE_ON_STACK(1), 0), &cLoadbang_0Dgs1_sendMessage, 0);
119 ctx_scheduleMessage(Base(_c), msg_initWithBang(HV_MESSAGE_ON_STACK(1), 0), &cLoadbang_XJMP6_sendMessage, 0); 119 ctx_scheduleMessage(Base(_c), msg_initWithBang(HV_MESSAGE_ON_STACK(1), 0), &cLoadbang_bGFum_sendMessage, 0);
120 120
121 return _c; 121 return _c;
122 } 122 }
123 123
124 Hv_bbb *hv_bbb_new(double sampleRate) { 124 Hv_bbb *hv_bbb_new(double sampleRate) {
136 136
137 137
138 /* 138 /*
139 * Static Function Implementation 139 * Static Function Implementation
140 */ 140 */
141 static void cBinop_62MLs_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 141 static void cMsg_5KHpJ_sendMessage(HvBase *_c, int letIn, const HvMessage *const n) {
142 cUnop_onMessage(_c, HV_UNOP_FLOOR, m, &cUnop_Rm4T9_sendMessage); 142 HvMessage *m = NULL;
143 } 143 m = HV_MESSAGE_ON_STACK(1);
144 144 msg_init(m, 1, msg_getTimestamp(n));
145 static void cUnop_Rm4T9_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 145 msg_setSymbol(m, 0, "samplerate");
146 cMsg_eMw6t_sendMessage(_c, 0, m); 146 cSystem_onMessage(_c, NULL, 0, m, &cSystem_tEzb9_sendMessage);
147 } 147 }
148 148
149 static void cRandom_Uxs9y_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 149 static void cSystem_tEzb9_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
150 cBinop_onMessage(_c, &Context(_c)->cBinop_62MLs, HV_BINOP_MULTIPLY, 0, m, &cBinop_62MLs_sendMessage); 150 cMsg_QrCwu_sendMessage(_c, 0, m);
151 } 151 }
152 152
153 static void cLoadbang_XJMP6_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 153 static void cBinop_DXD3m_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
154 cRandom_onMessage(_c, &Context(_c)->cRandom_Uxs9y, 0, m, &cRandom_Uxs9y_sendMessage); 154 cBinop_onMessage(_c, &Context(_c)->cBinop_tyjup, HV_BINOP_MULTIPLY, 1, m, &cBinop_tyjup_sendMessage);
155 } 155 }
156 156
157 static void cMsg_eMw6t_sendMessage(HvBase *_c, int letIn, const HvMessage *const n) { 157 static void cBinop_tyjup_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
158 cBinop_onMessage(_c, &Context(_c)->cBinop_6USpC, HV_BINOP_MIN, 0, m, &cBinop_6USpC_sendMessage);
159 }
160
161 static void cMsg_QrCwu_sendMessage(HvBase *_c, int letIn, const HvMessage *const n) {
162 HvMessage *m = NULL;
163 m = HV_MESSAGE_ON_STACK(2);
164 msg_init(m, 2, msg_getTimestamp(n));
165 msg_setFloat(m, 0, 6.28319f);
166 msg_setElementToFrom(m, 1, n, 0);
167 cBinop_k_onMessage(_c, NULL, HV_BINOP_DIVIDE, 0.0f, 0, m, &cBinop_DXD3m_sendMessage);
168 }
169
170 static void cBinop_iWcBL_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
171 cBinop_k_onMessage(_c, NULL, HV_BINOP_SUBTRACT, 1.0f, 0, m, &cBinop_QuDfQ_sendMessage);
172 sVarf_onMessage(_c, &Context(_c)->sVarf_a6sNx, m);
173 }
174
175 static void cBinop_6USpC_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
176 cBinop_onMessage(_c, &Context(_c)->cBinop_iWcBL, HV_BINOP_MAX, 0, m, &cBinop_iWcBL_sendMessage);
177 }
178
179 static void cBinop_QuDfQ_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
180 sVarf_onMessage(_c, &Context(_c)->sVarf_l59CR, m);
181 }
182
183 static void cLoadbang_0Dgs1_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
184 cMsg_5KHpJ_sendMessage(_c, 0, m);
185 cVar_onMessage(_c, &Context(_c)->cVar_lxt7X, 0, m, &cVar_lxt7X_sendMessage);
186 }
187
188 static void cVar_lxt7X_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
189 cBinop_onMessage(_c, &Context(_c)->cBinop_tyjup, HV_BINOP_MULTIPLY, 0, m, &cBinop_tyjup_sendMessage);
190 }
191
192 static void cMsg_qW1tH_sendMessage(HvBase *_c, int letIn, const HvMessage *const n) {
158 HvMessage *m = NULL; 193 HvMessage *m = NULL;
159 m = HV_MESSAGE_ON_STACK(2); 194 m = HV_MESSAGE_ON_STACK(2);
160 msg_init(m, 2, msg_getTimestamp(n)); 195 msg_init(m, 2, msg_getTimestamp(n));
161 msg_setElementToFrom(m, 0, n, 0); 196 msg_setElementToFrom(m, 0, n, 0);
162 msg_setFloat(m, 1, 1.0f); 197 msg_setFloat(m, 1, 1.0f);
163 sVari_onMessage(_c, &Context(_c)->sVari_ecpIx, m); 198 sVari_onMessage(_c, &Context(_c)->sVari_9lqOg, m);
164 } 199 }
165 200
166 static void cBinop_vHnCM_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 201 static void cLoadbang_bGFum_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
167 cBinop_onMessage(_c, &Context(_c)->cBinop_PmuD1, HV_BINOP_MAX, 0, m, &cBinop_PmuD1_sendMessage); 202 cRandom_onMessage(_c, &Context(_c)->cRandom_zn9Go, 0, m, &cRandom_zn9Go_sendMessage);
168 } 203 }
169 204
170 static void cBinop_PmuD1_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 205 static void cBinop_79eIJ_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
171 cBinop_k_onMessage(_c, NULL, HV_BINOP_SUBTRACT, 1.0f, 0, m, &cBinop_1u9M5_sendMessage); 206 cUnop_onMessage(_c, HV_UNOP_FLOOR, m, &cUnop_2Y2rq_sendMessage);
172 sVarf_onMessage(_c, &Context(_c)->sVarf_VF9rD, m); 207 }
173 } 208
174 209 static void cRandom_zn9Go_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
175 static void cBinop_lT4qw_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 210 cBinop_onMessage(_c, &Context(_c)->cBinop_79eIJ, HV_BINOP_MULTIPLY, 0, m, &cBinop_79eIJ_sendMessage);
176 cBinop_onMessage(_c, &Context(_c)->cBinop_vHnCM, HV_BINOP_MIN, 0, m, &cBinop_vHnCM_sendMessage); 211 }
177 } 212
178 213 static void cUnop_2Y2rq_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
179 static void cBinop_vpZDi_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) { 214 cMsg_qW1tH_sendMessage(_c, 0, m);
180 cBinop_onMessage(_c, &Context(_c)->cBinop_lT4qw, HV_BINOP_MULTIPLY, 1, m, &cBinop_lT4qw_sendMessage);
181 }
182
183 static void cMsg_zpcIL_sendMessage(HvBase *_c, int letIn, const HvMessage *const n) {
184 HvMessage *m = NULL;
185 m = HV_MESSAGE_ON_STACK(2);
186 msg_init(m, 2, msg_getTimestamp(n));
187 msg_setFloat(m, 0, 6.28319f);
188 msg_setElementToFrom(m, 1, n, 0);
189 cBinop_k_onMessage(_c, NULL, HV_BINOP_DIVIDE, 0.0f, 0, m, &cBinop_vpZDi_sendMessage);
190 }
191
192 static void cMsg_pfnj7_sendMessage(HvBase *_c, int letIn, const HvMessage *const n) {
193 HvMessage *m = NULL;
194 m = HV_MESSAGE_ON_STACK(1);
195 msg_init(m, 1, msg_getTimestamp(n));
196 msg_setSymbol(m, 0, "samplerate");
197 cSystem_onMessage(_c, NULL, 0, m, &cSystem_lJZJR_sendMessage);
198 }
199
200 static void cSystem_lJZJR_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
201 cMsg_zpcIL_sendMessage(_c, 0, m);
202 }
203
204 static void cVar_cPxQc_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
205 cBinop_onMessage(_c, &Context(_c)->cBinop_lT4qw, HV_BINOP_MULTIPLY, 0, m, &cBinop_lT4qw_sendMessage);
206 }
207
208 static void cBinop_1u9M5_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
209 sVarf_onMessage(_c, &Context(_c)->sVarf_0bFmM, m);
210 }
211
212 static void cLoadbang_AXnu9_sendMessage(HvBase *_c, int letIn, const HvMessage *const m) {
213 cMsg_pfnj7_sendMessage(_c, 0, m);
214 cVar_onMessage(_c, &Context(_c)->cVar_cPxQc, 0, m, &cVar_cPxQc_sendMessage);
215 } 215 }
216 216
217 217
218 218
219 219
250 // zero output buffers 250 // zero output buffers
251 __hv_zero_f(VOf(O0)); 251 __hv_zero_f(VOf(O0));
252 __hv_zero_f(VOf(O1)); 252 __hv_zero_f(VOf(O1));
253 253
254 // process all signal functions 254 // process all signal functions
255 __hv_var_i(&_c->sVari_ecpIx, VOi(Bi0)); 255 __hv_var_i(&_c->sVari_9lqOg, VOi(Bi0));
256 __hv_var_k_i(VOi(Bi1), 16807, 16807, 16807, 16807, 16807, 16807, 16807, 16807, 0); 256 __hv_var_k_i(VOi(Bi1), 16807, 16807, 16807, 16807, 16807, 16807, 16807, 16807, 0);
257 __hv_mul_i(VIi(Bi0), VIi(Bi1), VOi(Bi1)); 257 __hv_mul_i(VIi(Bi0), VIi(Bi1), VOi(Bi1));
258 sVarseti_process(&_c->sVari_9lqOg, VIi(Bi1));
258 __hv_cast_if(VIi(Bi1), VOf(Bf0)); 259 __hv_cast_if(VIi(Bi1), VOf(Bf0));
259 __hv_var_k_f(VOf(Bf1), 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 0); 260 __hv_var_k_f(VOf(Bf1), 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 4.65661e-10f, 0);
260 __hv_mul_f(VIf(Bf0), VIf(Bf1), VOf(Bf1)); 261 __hv_mul_f(VIf(Bf0), VIf(Bf1), VOf(Bf1));
261 sVarseti_process(&_c->sVari_ecpIx, VIi(Bi1)); 262 __hv_var_f(&_c->sVarf_a6sNx, VOf(Bf0));
262 __hv_var_f(&_c->sVarf_VF9rD, VOf(Bf0));
263 __hv_mul_f(VIf(Bf1), VIf(Bf0), VOf(Bf0)); 263 __hv_mul_f(VIf(Bf1), VIf(Bf0), VOf(Bf0));
264 __hv_var_f(&_c->sVarf_0bFmM, VOf(Bf1)); 264 __hv_var_f(&_c->sVarf_l59CR, VOf(Bf1));
265 __hv_rpole_f(&_c->sRPole_WxgWS, VIf(Bf0), VIf(Bf1), VOf(Bf1)); 265 __hv_rpole_f(&_c->sRPole_ACVjc, VIf(Bf0), VIf(Bf1), VOf(Bf1));
266 __hv_var_k_f(VOf(Bf0), 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 0); 266 __hv_var_k_f(VOf(Bf0), 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 1000000.0f, 0);
267 __hv_mul_f(VIf(Bf1), VIf(Bf0), VOf(Bf0)); 267 __hv_mul_f(VIf(Bf1), VIf(Bf0), VOf(Bf0));
268 __hv_phasor_k_f(&_c->sPhasor_YcHM3, VOf(Bf1)); 268 __hv_phasor_k_f(&_c->sPhasor_GKtI5, VOf(Bf1));
269 __hv_del1_f(&_c->sDel1_FfVih, VIf(Bf1), VOf(Bf2)); 269 __hv_del1_f(&_c->sDel1_OZ8Kl, VIf(Bf1), VOf(Bf2));
270 __hv_lt_f(VIf(Bf1), VIf(Bf2), VOf(Bf2)); 270 __hv_lt_f(VIf(Bf1), VIf(Bf2), VOf(Bf2));
271 __hv_samphold_f(&_c->sSamphold_hq9sm, VIf(Bf0), VIf(Bf2), VOf(Bf2)); 271 __hv_samphold_f(&_c->sSamphold_XcpkT, VIf(Bf0), VIf(Bf2), VOf(Bf2));
272 __hv_phasor_f(&_c->sPhasor_n1TcS, VIf(Bf2), VOf(Bf2)); 272 __hv_phasor_f(&_c->sPhasor_6rvdw, VIf(Bf2), VOf(Bf2));
273 __hv_var_k_f(VOf(Bf0), 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0); 273 __hv_var_k_f(VOf(Bf0), 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0);
274 __hv_sub_f(VIf(Bf2), VIf(Bf0), VOf(Bf0)); 274 __hv_sub_f(VIf(Bf2), VIf(Bf0), VOf(Bf0));
275 __hv_abs_f(VIf(Bf0), VOf(Bf0)); 275 __hv_abs_f(VIf(Bf0), VOf(Bf0));
276 __hv_var_k_f(VOf(Bf2), 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0); 276 __hv_var_k_f(VOf(Bf2), 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0);
277 __hv_sub_f(VIf(Bf0), VIf(Bf2), VOf(Bf2)); 277 __hv_sub_f(VIf(Bf0), VIf(Bf2), VOf(Bf2));