2 #include "ViMic_Engine.h"
3 #include "Properties.h"
12 #include "ext_common.h"
14 #include "TTClassWrapperMax.h"
21 int C74_EXPORT main(
void)
26 common_symbols_init();
28 c = class_new(
"j.vimic~", (method)vimic_new, (method)vimic_free,
sizeof(t_vimic), (method)0L, A_GIMME, 0);
31 class_addmethod(c,(method)vimic_dsp,
"dsp", A_CANT, 0);
32 class_addmethod(c,(method)vimic_dsp64,
"dsp64", A_CANT, 0);
33 class_addmethod(c,(method)vimic_bang,
"bang", 0);
37 class_addmethod(c,(method)vimic_sourcePosAbs,
"sourcePosAbs", A_GIMME, 0);
38 class_addmethod(c,(method)vimic_sourcePos,
"sourcePos", A_GIMME, 0);
39 class_addmethod(c,(method)vimic_reflGain,
"reflGain", A_GIMME, 0);
40 class_addmethod(c,(method)vimic_micPos,
"micPos", A_GIMME, 0);
41 class_addmethod(c,(method)vimic_micAngle,
"micAngle", A_GIMME, 0);
42 class_addmethod(c,(method)vimic_micDirectivity,
"directivity", A_GIMME, 0);
43 class_addmethod(c,(method)vimic_micGain,
"micGain", A_GIMME, 0);
44 class_addmethod(c,(method)vimic_roomSize,
"roomSize", A_GIMME, 0);
45 class_addmethod(c,(method)vimic_disPow,
"disPow", A_GIMME, 0);
46 class_addmethod(c,(method)vimic_dirPow,
"dirPow", A_GIMME, 0);
47 class_addmethod(c,(method)vimic_dbUnit,
"dbUnit", A_GIMME, 0);
48 class_addmethod(c,(method)vimic_temperature,
"temperature", A_FLOAT, 0);
49 class_addmethod(c,(method)vimic_minSensi,
"minSensi", A_FLOAT, 0);
50 class_addmethod(c,(method)vimic_directBang,
"directBang", A_LONG, 0);
51 class_addmethod(c,(method)vimic_micPolarity,
"micPolarity", A_LONG, 0);
52 class_addmethod(c,(method)vimic_distModel,
"distModel", A_LONG, 0);
53 class_addmethod(c,(method)vimic_renderType,
"renderType", A_LONG, 0);
54 class_addmethod(c,(method)vimic_report,
"report", A_LONG, 0);
55 class_addmethod(c,(method)vimic_sourceYaw,
"sourceYaw", A_LONG, 0);
56 class_addmethod(c,(method)vimic_renderintervall,
"renderintervall", A_LONG, 0);
57 class_addmethod(c,(method)vimic_sourceDirectivityFlag,
"sourceDirectivityFlag", A_LONG, 0);
58 class_addmethod(c,(method)vimic_normalizeSensiFlag,
"normalizeSensiFlag", A_LONG, 0);
59 class_addmethod(c,(method)vimic_minimumDelayFlag,
"minimumDelayFlag", A_LONG, 0);
60 class_addmethod(c,(method)vimic_minSensiFlag,
"minSensiFlag", A_LONG, 0);
61 class_addmethod(c,(method)vimic_xFadeLength,
"xFadeLength", A_LONG, 0);
62 class_addmethod(c,(method)vimic_xFadeFunction,
"xFadeFunction", A_LONG, 0);
63 class_addmethod(c,(method)vimic_xFadeThreshold,
"xFadeThreshold", A_LONG, 0);
64 class_addmethod(c,(method)vimic_reportAll,
"reportAll", 0);
65 class_addmethod(c,(method)vimic_warnings,
"warnings", A_LONG, 0);
66 class_addmethod(c,(method)vimic_airfilter,
"airfilter", A_LONG, 0);
67 class_addmethod(c,(method)vimic_getDirTable,
"getDirTable", A_DEFSYM, 0);
68 class_addmethod(c,(method)vimic_highCf,
"highCf", A_LONG, A_LONG, 0);
69 class_addmethod(c,(method)vimic_lowCf,
"lowCf", A_LONG, A_LONG, 0);
70 class_addmethod(c,(method)vimic_lowAbsorption,
"lowAbsorption", A_GIMME, 0);
71 class_addmethod(c,(method)vimic_midAbsorption,
"midAbsorption", A_GIMME, 0);
72 class_addmethod(c,(method)vimic_highAbsorption,
"highAbsorption", A_GIMME, 0);
73 class_addmethod(c,(method)vimic_wallFilter,
"wallFilter", A_GIMME, 0);
74 class_addmethod(c,(method)vimic_assist,
"assist",A_CANT,0);
76 #ifdef __INTEL_COMPILER
77 post(
"ViMiC for Max/MSP, © 2005-2012 Nils Peters, Tristan Matthews, Jonas Braasch. Version built with icc on " __DATE__
" at " __TIME__);
79 post(
"ViMiC for Max/MSP, © 2005-2012 Nils Peters, Tristan Matthews, Jonas Braasch. Version built on " __DATE__
" at " __TIME__);
83 class_register(CLASS_BOX, c);
89 void *vimic_new(t_symbol *s,
int argc, t_atom *argv)
92 t_vimic *x = (t_vimic*)object_alloc(vimic_class);
98 globWarningFlag =
false;
99 globReportFlag =
false;
100 x->normalizeSensiFlag =
false;
101 x->minSensiFlag =
false;
102 x->minimumDelayFlag =
false;
107 if (argv[0].a_w.w_long > 0 && argv[0].a_w.w_long <= Properties::MAXNUMCHANNELS)
108 x->numOfChannels = (int) argv[0].a_w.w_long;
109 else if (globWarningFlag)
110 post(
"requested number of channels could not be set. Set to default of 8 instead");
119 dsp_setup((t_pxobject*)x, 1);
131 x->numRefl = Properties::REFLECTIONS_PER_REFLECTION_ORDER[x->reflOrder];
133 x->maxDynRefl = x->numRefl;
134 x->reflGains[0] = 0.0;
135 x->reflGains[1] = 0.0;
136 x->reflGains[2] = 0.0;
137 x->reflGainFlag =
true;
139 x->bufSz = x->numRefl * x->numOfChannels;
141 x->room =
new Room(20, 30, 8, x->numOfChannels, x->numOfSources, x->reflOrder);
143 x->AudioProcType = Properties::VIMIC_LITE;
146 x->x_sr = Properties::SAMPLERATE;
147 x->micPolarity = -1.0;
149 x->renderInterval = 50;
151 x->grainsize = (double) 1.0 / (x->renderInterval * x->blocksize);
154 x->fades =
new CrossFadeQueue(10, Properties::FADE_TABLE_SIZE, Properties::COS, x->x_sr);
158 x->speedOfSound = (331.3 * sqrt(1.0 + x->temperature / 273.15)) / x->x_sr;
159 x->invSpeedOfSound = 1.0 / x->speedOfSound;
161 if ((x->c_vec = (
double *) malloc(Properties::DELAYBYTES *
sizeof(
double))) == NULL)
164 for (n = 0; n < Properties::DELAYBYTES; n++)
167 if ((x->delay = (
double *) getbytes((
short) x->bufSz *
sizeof(
double))) == NULL)
169 if ((x->currentDelay = (
double *) getbytes((
short) x->bufSz *
sizeof(
double))) == NULL)
171 if ((x->delGrain= (
double *) getbytes((
short) x->bufSz *
sizeof(
double))) == NULL)
173 if ((x->sensiGrain= (
double *) getbytes((
short) x->bufSz *
sizeof(
double))) == NULL)
175 if ((x->sensitivity= (
double *) getbytes((
short) x->bufSz *
sizeof(
double))) == NULL)
177 if ((x->currentSensitivity= (
double *) getbytes((
short) x->bufSz *
sizeof(
double))) == NULL)
180 for (n = 0; n < x->bufSz; n++) {
181 x->currentDelay[n] = 0.0;
183 x->sensitivity[n] = 0.0;
184 x->currentSensitivity[n] = 0.0;
185 x->delGrain[n] = 0.0;
186 x->sensiGrain[n] = 0.0;
190 for (n = 0; n < x->numOfChannels; n++)
191 outlet_new((t_pxobject *)x,
"signal");
193 x->room->renderMirrors();
194 x->room->mics.renderMics();
200 void vimic_free(t_vimic *x)
202 dsp_free((t_pxobject*)x);
204 freebytes(x->delay, (
short) x->bufSz *
sizeof(
double));
205 freebytes(x->currentDelay, (
short) x->bufSz *
sizeof(
double));
206 freebytes(x->delGrain, (
short) x->bufSz *
sizeof(
double));
207 freebytes(x->sensiGrain, (
short) x->bufSz *
sizeof(
double));
208 freebytes(x->sensitivity, (
short) x->bufSz *
sizeof(
double));
209 freebytes(x->currentSensitivity, (
short) x->bufSz *
sizeof(
double));
216 void vimic_sourcePosAbs(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
220 if (argv[0].a_type == A_FLOAT)
222 x->room->sources[0].xPosAbs(argv[0].a_w.w_float);
224 if (argv[1].a_type == A_FLOAT)
226 x->room->sources[0].yPosAbs(argv[1].a_w.w_float);
228 if (argv[2].a_type == A_FLOAT)
229 x->room->sources[0].zPosAbs(argv[2].a_w.w_float);
232 if (x->directBang == 1) vimic_bang(x);
234 else if (globWarningFlag) error(
"Numbers of args. is wrong");
239 void vimic_sourcePos(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
243 if (argv[0].a_type == A_FLOAT)
245 x->room->sources[0].xPosRel(argv[0].a_w.w_float);
247 if (argv[1].a_type == A_FLOAT)
249 x->room->sources[0].yPosRel(argv[1].a_w.w_float);
251 if (argv[2].a_type == A_FLOAT)
252 x->room->sources[0].zPosRel(argv[2].a_w.w_float);
255 if (x->directBang == 1) vimic_bang(x);
257 else if (globWarningFlag) error(
"Numbers of args. is wrong");
261 void vimic_micPos(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
268 if (argv[0].a_type == A_FLOAT)
270 x->room->mics.xPos(argv[0].a_w.w_float);
271 if (argv[1].a_type == A_FLOAT)
273 x->room->mics.yPos(argv[1].a_w.w_float);
275 if (argv[2].a_type == A_FLOAT)
276 x->room->mics.zPos(argv[2].a_w.w_float);
281 if (argv[0].a_type == A_LONG)
282 b = argv[0].a_w.w_long;
284 if (x->room->mics.validChannel(b))
287 x->room->mics[b - 1].xPos(argv[1].a_w.w_float);
290 x->room->mics[b - 1].yPos(argv[2].a_w.w_float);
293 x->room->mics[b - 1].zPos(argv[3].a_w.w_float);
295 else if (globWarningFlag) post(
"Invalid channel number %d", b);
298 if (globWarningFlag) error(
"Incorrect # of args.");
301 if (x->directBang == 1) vimic_bang(x);
307 void vimic_micAngle(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
313 if (argv[0].a_type == A_LONG)
315 b = argv[0].a_w.w_long;
316 if (argv[1].a_type == A_FLOAT)
318 if (x->room->mics.validChannel(b))
320 x->room->mics[b - 1].azi(argv[1].a_w.w_float);
322 if (argv[2].a_type == A_FLOAT)
323 x->room->mics[b - 1].ele(argv[2].a_w.w_float);
325 else if (globWarningFlag) post(
"Invalid channel number %d", b);
328 if (x->directBang == 1) vimic_bang(x);
330 else if (globWarningFlag) error(
"Incorrect # of args.");
334 void vimic_micDirectivity(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
340 if (argv[0].a_type == A_LONG)
342 b = argv[0].a_w.w_long;
343 if (argv[1].a_type == A_FLOAT)
345 if (x->room->mics.validChannel(b))
346 x->room->mics[b - 1].dirGainA(argv[1].a_w.w_float);
347 else if (globWarningFlag) post(
"Invalid channel number %d", b);
352 if (argv[0].a_type == A_FLOAT)
353 x->room->mics.dirGain(argv[0].a_w.w_float);
356 if (globWarningFlag) error(
"Incorrect # of args.");
359 if (x->directBang == 1) vimic_bang(x);
362 void vimic_micGain(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
369 if (argv[0].a_type == A_LONG)
371 b = argv[0].a_w.w_long;
372 if (argv[1].a_type == A_FLOAT)
374 if (x->room->mics.validChannel(b))
375 x->room->mics[b - 1].gain(argv[1].a_w.w_float);
376 else if (globWarningFlag) error(
"Invalid channel number %d", b);
381 if (argv[0].a_type == A_FLOAT)
382 x->room->mics.gain(argv[0].a_w.w_float);
385 if (globWarningFlag) error(
"Incorrect # of args.");
388 if (x->directBang == 1) vimic_bang(x);
393 void vimic_roomSize(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
397 if (argv[0].a_type == A_FLOAT)
399 x->room->width(argv[0].a_w.w_float);
401 if (argv[1].a_type == A_FLOAT)
403 x->room->depth(argv[1].a_w.w_float);
405 if (argv[2].a_type == A_FLOAT)
406 x->room->height(argv[2].a_w.w_float);
409 if (x->directBang == 1) vimic_bang(x);
411 else if (globWarningFlag)
412 error(
"Incorrect # of args.");
417 void vimic_reflGain(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
423 if (argv[0].a_type == A_LONG)
425 b = argv[0].a_w.w_long;
426 if (b >= 0 && b < Properties::REFLECTIONORDER)
428 if (argv[1].a_type == A_FLOAT)
432 x->reflGains[b] = TTClip<float>(argv[1].a_w.w_float,0.0, 8.0);
434 if (x->reflGains[2] > 0.0) {
436 x->numRefl = Properties::REFLECTIONS_PER_REFLECTION_ORDER[x->reflOrder];
437 x->maxReflOrder = x->reflOrder;
438 x->maxDynRefl = x->numRefl;
440 else if (x->reflGains[1] > 0.0) {
442 x->numRefl = Properties::REFLECTIONS_PER_REFLECTION_ORDER[x->reflOrder];
443 x->maxReflOrder = x->reflOrder;
444 x->maxDynRefl = x->numRefl;
448 x->numRefl = Properties::REFLECTIONS_PER_REFLECTION_ORDER[x->reflOrder];
449 x->maxReflOrder = x->reflOrder;
450 x->maxDynRefl = x->numRefl;
453 x->reflGainFlag =
true;
456 post(
"Reflection order %d gain: %f", b, x->reflGains[b]);
460 else if (globWarningFlag) post(
"Invalid channel number %d", b);
462 if (x->directBang == 1) vimic_bang(x);
464 else if (globWarningFlag) error(
"Incorrect # of args.");
468 void vimic_dirPow(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
475 if (argv[0].a_type == A_LONG)
477 b = argv[0].a_w.w_long;
478 if (argv[1].a_type == A_LONG)
480 if (x->room->mics.validChannel(b))
481 x->room->mics[b - 1].dirPow(argv[1].a_w.w_long);
482 else if (globWarningFlag)
483 error(
"Invalid channel number %d", b);
488 if (argv[0].a_type == A_LONG)
489 x->room->mics.dirPow(argv[0].a_w.w_long);
493 error(
"Incorrect # of args.");
496 if (x->directBang == 1) vimic_bang(x);
499 void vimic_disPow(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
505 if (argv[0].a_type == A_LONG)
507 b = argv[0].a_w.w_long;
508 if (argv[1].a_type == A_FLOAT)
510 if (x->room->mics.validChannel(b))
511 x->room->mics[b - 1].distPow(argv[1].a_w.w_float);
512 else if (globWarningFlag)
513 error(
"Invalid channel number %d", b);
518 if (argv[0].a_type == A_FLOAT)
519 x->room->mics.distPow(argv[0].a_w.w_float);
523 error(
"Incorrect # of args.");
526 if (x->directBang == 1) vimic_bang(x);
530 void vimic_dbUnit(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
537 if (argv[0].a_type == A_LONG)
539 b = argv[0].a_w.w_long;
540 if (argv[1].a_type == A_FLOAT)
542 if (x->room->mics.validChannel(b))
543 x->room->mics[b - 1].dbUnit(argv[1].a_w.w_float);
544 else if (globWarningFlag) error(
"Invalid channel number %d", b);
549 if (argv[0].a_type == A_FLOAT)
550 x->room->mics.dbUnit(argv[0].a_w.w_float);
553 if (globWarningFlag) error(
"Incorrect # of args.");
556 if (x->directBang == 1) vimic_bang(x);
561 void vimic_directBang(t_vimic *x,
long n)
566 post(
"Automatic Rendering Update: On");
571 post(
"Automatic Rendering Update: Off");
578 void vimic_temperature(t_vimic *x,
double n)
580 if ((n >= -20.0)||(n <= 40.0))
583 x->speedOfSound = (331.3 * sqrt(1.0 + x->temperature / 273.15)) / x->x_sr;
584 x->invSpeedOfSound = 1.0 / x->speedOfSound;
585 if (globReportFlag) post(
"expected speed of sound is %f at %f degree celius", x->speedOfSound * x->x_sr, x->temperature);
586 if (x->directBang == 1) vimic_bang(x);
588 else if (globWarningFlag) post(
"Temperature must be between -20 and 40 degree");
592 void vimic_minSensi(t_vimic *x,
double n)
595 if (n >= 0.0 && n <= 1.0)
598 x->room->sources[0].flag(
true);
599 if (x->directBang == 1) vimic_bang(x);
600 if (globReportFlag) post(
"Minimum sensitivity: %f", x->minSensi);
602 else if (globWarningFlag) error(
"Minimum sensitivity must be >= 0.0 and <= 1.0");
610 void vimic_distModel(t_vimic *x,
long n)
612 x->distModel = TTClip<int>(n,1,2);
613 x->room->sources[0].flag(
true);
614 if (x->directBang == 1) vimic_bang(x);
620 void vimic_warnings(t_vimic *x,
long n)
625 if (globWarningFlag ==
true) post(
"Warnings off");
626 globWarningFlag =
false;
629 if (globWarningFlag ==
false) post(
"Warnings on");
630 globWarningFlag =
true;
635 void vimic_reportAll(t_vimic *x)
639 post(
"This is ViMiC for Max/MSP, (c) 2005-2012 Nils Peters, Tristan Matthews, Jonas Braasch. Version built on " __DATE__
" at " __TIME__);
640 post(
"renderInterval: %d",x->renderInterval);
641 post(
"Grainsize: %f",x->grainsize);
642 post(
"expected speed of sound is %f at %f degrees celsius", x->speedOfSound * x->x_sr, x->temperature);
643 x->room->mics.print();
645 for (m = 0; m < x->room->mics.numChannels(); m++)
647 for (n = 0; n < x->numRefl; n++)
649 post(
"Mic %d, Refl %d, Sensi: %f", m, n, *(x->sensitivity + (x->numRefl * m) + n));
650 post(
"Mic %d, Refl %d, Delay: %f", m, n, *(x->delay + (x->numRefl * m) + n));
654 for (m = 0; m < Properties::REFLECTIONORDER; m++)
655 post(
"Reflgains[%d] = %f", m, x->reflGains[m]);
661 void vimic_report(t_vimic *x,
long n)
666 if (globReportFlag ==
true) {
669 globReportFlag =
false;
672 if (globReportFlag ==
false) {
675 globReportFlag =
true;
680 void vimic_sourceYaw(t_vimic *x,
long n)
682 x->room->sources[0].aziAngle(n);
686 void vimic_normalizeSensiFlag(t_vimic *x,
long n)
691 x->normalizeSensiFlag =
false;
692 x->room->sources[0].flag(
true);
693 if (x->directBang == 1) vimic_bang(x);
694 if (globReportFlag) post(
"Sensitivity normalization: off");
697 x->normalizeSensiFlag =
true;
698 x->room->sources[0].flag(
true);
699 if (x->directBang == 1) vimic_bang(x);
700 if (globReportFlag) post(
"Sensitivity normalization: on");
705 void vimic_minimumDelayFlag(t_vimic *x,
long n)
710 x->minimumDelayFlag =
false;
711 x->room->sources[0].flag(
true);
712 if (x->directBang == 1) vimic_bang(x);
713 if (globReportFlag) post(
"Minimizing time-of-fights delays: off");
716 x->minimumDelayFlag =
true;
717 x->room->sources[0].flag(
true);
718 if (x->directBang == 1) vimic_bang(x);
719 if (globReportFlag) post(
"Minimizing time-of-fights delays: on");
724 void vimic_minSensiFlag(t_vimic *x,
long n)
729 x->minSensiFlag =
false;
730 x->room->sources[0].flag(
true);
731 if (x->directBang == 1) vimic_bang(x);
732 if (globReportFlag) post(
"Sensitivity minimum: off");
735 x->minSensiFlag =
true;
736 x->room->sources[0].flag(
true);
737 if (x->directBang == 1) vimic_bang(x);
738 if (globReportFlag) post(
"Sensitivity minimum: on");
745 void vimic_sourceDirectivityFlag(t_vimic *x,
long n)
751 x->room->sources[0].directivityFlag(
false);
752 if (x->directBang == 1) vimic_bang(x);
753 if (globReportFlag) post(
"Source directivity: off");
756 x->room->sources[0].directivityFlag(
true);
757 if (x->directBang == 1) vimic_bang(x);
758 if (globReportFlag) post(
"Source directivity: on");
764 void vimic_micPolarity(t_vimic *x,
long n)
769 x->micPolarity = -1.0;
770 x->room->sources[0].flag(
true);
771 if (x->directBang == 1) vimic_bang(x);
772 if (globReportFlag) post(
"Microphone polarity is unrestricted, microphone gains are between -1 and 1");
775 x->micPolarity = 0.0;
776 x->room->sources[0].flag(
true);
777 if (x->directBang == 1) vimic_bang(x);
778 if (globReportFlag) post(
"Microphone polarity is restricted, microphone gains are between 0 and 1");
781 if (globWarningFlag) error(
"Argument must be either 1 or 0");
786 void vimic_renderintervall(t_vimic *x,
long n)
790 x->renderInterval = n;
791 x->grainsize = 1.0 / (x->renderInterval * x->blocksize);
793 else post(
"renderInterval must be more than 1 blocks");
794 if (globReportFlag) post(
"renderInterval is %d blocks", x->renderInterval);
797 void vimic_xFadeFunction(t_vimic *x,
long n)
799 x->fades->fadeFunction((Properties::fadeMode) n);
804 void vimic_xFadeLength(t_vimic *x,
long n)
807 if (x->fades->isActive()) post(
"No change, can't change fade time while actively crossfading.");
808 else x->fades->fadeLength(n);
813 void vimic_xFadeThreshold(t_vimic *x,
long n)
816 if (n >= 1) x->fades->fadeThreshold(n);
817 else post(
"Crossfade threshold must be >= 1");
818 if (globReportFlag) post(
"Crossfade threshold in samples: %d", x->fades->fadeThreshold());
822 void vimic_airfilter(t_vimic *x,
long n)
824 for (
int i = 0; i < x->numOfChannels; i++) {
825 x->room->air[i][0].cutOff(n);
826 x->room->xfadeAir[i].cutOff(n);
827 x->room->air[i][1].cutOff(n);
829 if (x->directBang == 1)
832 post(
"Air absorption cutoff: %ld", n);
836 void vimic_renderType(t_vimic *x,
long n)
841 x->AudioProcType = Properties::NONE;
847 x->AudioProcType = Properties::VIMIC_LITE;
849 post(
"Processing: ViMiC lite -> ViMiC with one Filter for all walls");
853 x->AudioProcType = Properties::AMP_PAN;
855 post(
"Processing: Amplitude Panning");
859 x->AudioProcType = Properties::X_FADE_LITE;
861 post(
"Processing: Delay w/o Pitch Shift");
865 x->AudioProcType = Properties::X_FADE_XL;
867 post(
"Processing: Delay w/o Pitch Shift");
871 x->AudioProcType = Properties::VIMIC_XL;
873 post(
"Processing: ViMiC XL -> ViMiC with separate Filter for each wall");
877 x->AudioProcType = Properties::STATIC;
879 post(
"Processing: Integer delays only.");
884 error(
"Unknown rendering type.");
887 if (x->directBang == 1) vimic_bang(x);
891 void vimic_getDirTable(t_vimic *x, t_symbol *s)
895 if (!table_get(s, &storage, &size))
896 x->room->sources[0].updateDirectivity(storage);
903 void vimic_highCf(t_vimic *x,
long n,
long freq)
907 if (n > 0 && n <= Properties::NUMWALLS)
909 for (
int i = 0; i < x->numOfChannels; i++)
911 if (n == Properties::LEFT)
913 for (
int filterNum = 0; filterNum < 2; filterNum++)
914 x->room->xfadeWalls[i][filterNum].highShelfFrequency(freq);
916 x->room->walls[i][n - 1].highShelfFrequency(freq);
919 x->room->walls[i][n + Properties::NUMWALLS - 1].highShelfFrequency(freq);
922 else if (globWarningFlag) post(
"Invalid wall index %d", n);
923 if (x->directBang == 1) vimic_bang(x);
924 if (globReportFlag) post(
"Wall %d high shelf centre frequency: %ld", n, freq);
930 void vimic_lowCf(t_vimic *x,
long n,
long freq)
934 if (n > 0 && n <= Properties::NUMWALLS)
936 for (
int i = 0; i < x->numOfChannels; i++)
938 if (n == Properties::LEFT)
940 for (
int filterNum = 0; filterNum < 2; filterNum++)
941 x->room->xfadeWalls[i][filterNum].lowShelfFrequency(freq);
943 x->room->walls[i][n - 1].lowShelfFrequency(freq);
945 x->room->walls[i][n + Properties::NUMWALLS - 1].lowShelfFrequency(freq);
948 else if (globWarningFlag) post(
"Invalid wall index %d", n);
949 if (x->directBang == 1) vimic_bang(x);
950 if (globReportFlag) post(
"Wall %d low shelf centre frequency: %ld", n, freq);
955 void vimic_lowAbsorption(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
963 if (argv[0].a_type == A_LONG)
965 b = argv[0].a_w.w_long;
966 if (argv[1].a_type == A_FLOAT)
968 if (b > 0 && b <= Properties::NUMWALLS)
970 for (
int i = 0; i < x->numOfChannels; i++)
972 if (b == Properties::LEFT)
974 for (
int filterNum = 0; filterNum < 2; filterNum++)
975 x->room->xfadeWalls[i][filterNum].lowGain(argv[1].a_w.w_float);
978 x->room->walls[i][b - 1].lowGain(argv[1].a_w.w_float);
982 x->room->walls[i][b + Properties::NUMWALLS - 1].lowGain(argv[1].a_w.w_float);
986 else if (globWarningFlag) post(
"Invalid wall index %d", b);
988 if (globReportFlag) post(
"Wall %d low gain: %f", b, argv[1].a_w.w_float);
992 else if (globWarningFlag) error(
"Incorrect # of args.");
993 if (x->directBang == 1) vimic_bang(x);
1002 void vimic_midAbsorption(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
1010 if (argv[0].a_type == A_LONG)
1012 b = argv[0].a_w.w_long;
1013 if (argv[1].a_type == A_FLOAT)
1015 if (b > 0 && b <= Properties::NUMWALLS)
1017 for (
int i = 0; i < x->numOfChannels; i++)
1019 if (b == Properties::LEFT)
1021 for (
int filterNum = 0; filterNum < 2; filterNum++)
1022 x->room->xfadeWalls[i][filterNum].midGain(argv[1].a_w.w_float);
1025 x->room->walls[i][b - 1].midGain(argv[1].a_w.w_float);
1029 x->room->walls[i][b + Properties::NUMWALLS - 1].midGain(argv[1].a_w.w_float);
1033 else if (globWarningFlag) post(
"Invalid wall index %d", b);
1034 if (globReportFlag) post(
"Wall %d mid gain: %f", b, argv[1].a_w.w_float);
1038 else if (globWarningFlag)
1039 error(
"Incorrect # of args.");
1046 void vimic_highAbsorption(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
1054 if (argv[0].a_type == A_LONG)
1056 b = argv[0].a_w.w_long;
1058 if (argv[1].a_type == A_FLOAT)
1060 if (b > 0 && b <= Properties::NUMWALLS)
1062 for (
int i = 0; i < x->numOfChannels; i++)
1064 if (b == Properties::LEFT)
1066 for (
int filterNum = 0; filterNum < 2; filterNum++)
1067 x->room->xfadeWalls[i][filterNum].highGain(argv[1].a_w.w_float);
1070 x->room->walls[i][b - 1].highGain(argv[1].a_w.w_float);
1075 x->room->walls[i][b + Properties::NUMWALLS - 1].highGain(argv[1].a_w.w_float);
1079 else if (globWarningFlag) post(
"Invalid wall index %d", b);
1081 if (globReportFlag) post(
"Wall %d high gain: %f", b, argv[1].a_w.w_float);
1085 else if (globWarningFlag) error(
"Incorrect # of args.");
1090 void vimic_wallFilter(t_vimic *x, t_symbol *s,
short argc, t_atom *argv)
1098 if (argv[0].a_type == A_LONG)
1100 b = argv[0].a_w.w_long;
1102 if ((argv[1].a_type == A_FLOAT) && (argv[2].a_type == A_FLOAT) && (argv[3].a_type == A_FLOAT) && (argv[4].a_type == A_LONG) && (argv[5].a_type == A_LONG))
1104 if (b > 0 && b <= Properties::NUMWALLS)
1106 for (
int i = 0; i < x->numOfChannels; i++)
1108 if (b == Properties::LEFT)
1110 for (
int filterNum = 0; filterNum < 2; filterNum++)
1112 x->room->xfadeWalls[i][filterNum].lowGain(argv[1].a_w.w_float);
1113 x->room->xfadeWalls[i][filterNum].midGain(argv[2].a_w.w_float);
1114 x->room->xfadeWalls[i][filterNum].highGain(argv[3].a_w.w_float);
1115 x->room->xfadeWalls[i][filterNum].lowShelfFrequency(argv[4].a_w.w_long);
1116 x->room->xfadeWalls[i][filterNum].highShelfFrequency(argv[5].a_w.w_long);
1120 x->room->walls[i][b - 1].lowGain(argv[1].a_w.w_float);
1121 x->room->walls[i][b - 1].midGain(argv[2].a_w.w_float);
1122 x->room->walls[i][b - 1].highGain(argv[3].a_w.w_float);
1123 x->room->walls[i][b - 1].lowShelfFrequency(argv[4].a_w.w_long);
1124 x->room->walls[i][b - 1].highShelfFrequency(argv[5].a_w.w_long);
1129 x->room->walls[i][b + Properties::NUMWALLS - 1].lowGain(argv[1].a_w.w_float);
1130 x->room->walls[i][b + Properties::NUMWALLS - 1].midGain(argv[2].a_w.w_float);
1131 x->room->walls[i][b + Properties::NUMWALLS - 1].highGain(argv[3].a_w.w_float);
1132 x->room->walls[i][b + Properties::NUMWALLS - 1].lowShelfFrequency(argv[4].a_w.w_long);
1133 x->room->walls[i][b + Properties::NUMWALLS - 1].highShelfFrequency(argv[5].a_w.w_long);
1137 else if (globWarningFlag) post(
"Invalid wall index %d", b);
1138 if (globReportFlag) post(
"Wall %d lowGain %f, midGain: %f, highGain: %f, lowShelfFreq %f, highShelfFreq %f", b, argv[1].a_w.w_float, argv[2].a_w.w_float, argv[3].a_w.w_float, argv[4].a_w.w_float, argv[5].a_w.w_float);
1140 else if (globWarningFlag) error(
"Incorrect syntax. wallFilter index <int> lowGain <float> midGain <float> highGain <float> lowShelfFrequency <int> highShelfFrequency <int>");
1143 else if (globWarningFlag) error(
"Incorrect # of args.");
1181 void vimic_bang(t_vimic *x)
1184 bool grainCounterFlag =
false;
1186 if (x->room->mirrorFlag())
1188 grainCounterFlag =
true;
1189 x->room->renderMirrors();
1196 for (m = 0; m < x->numOfChannels; m++)
1198 if (x->room->sources[0].flag() || x->room->mics[m].flag() || x->room->mics.flag() || x->reflGainFlag)
1200 grainCounterFlag =
true;
1201 vimic_mirrors(x->sensitivity + x->numRefl * m,
1202 x->delay + x->numRefl * m,
1205 &x->room->sources[0],
1207 x->numRefl, x->AudioProcType, x->currentDelay + x->numRefl * m, x->reflGains, x->fades, x->micPolarity, x->distModel);
1210 x->room->mics[m].flag(
false);
1212 x->room->mics.flag(
false);
1217 if (grainCounterFlag)
1219 if (x->minSensiFlag)
1221 for (
int i = 0; i < x->bufSz; i++)
1222 vimic_floorSensi(x->sensitivity + i, x->minSensi);
1226 if (x->normalizeSensiFlag) {
1228 double invSqrtSumSensi = vimic_invSqrtSumSensi(x->sensitivity, x->bufSz);
1229 for (
int i = 0; i < x->bufSz; i++)
1230 vimic_normalizeSensi(x->sensitivity + i, invSqrtSumSensi);
1234 if (x->minimumDelayFlag) {
1235 double minDelay = vimic_findMinDelayValue(x->delay, x->bufSz);
1236 for (
int i = 0; i < x->bufSz; i++)
1237 vimic_minimizeDelay(x->delay + i, minDelay);
1241 for (m = 0; m < x->bufSz; m++) {
1242 x->delGrain[m] = ((double) x->delay[m] - x->currentDelay[m]) * x->grainsize;
1243 #ifndef __INTEL_COMPILER
1244 TTZeroDenormal(x->delGrain[m]);
1246 x->sensiGrain[m] = (x->sensitivity[m] - x->currentSensitivity[m]) * x->grainsize;
1247 #ifndef __INTEL_COMPILER
1248 TTZeroDenormal(x->sensiGrain[m]);
1252 x->grainCounter = 0;
1254 x->room->sources[0].flag(
false);
1255 x->reflGainFlag =
false;
1258 #pragma warning(push)
1259 #pragma warning(disable: 4312; disable : 4700)
1260 t_int* vimic_perform(t_int *w)
1262 t_vimic *x = (t_vimic *)(w[1]);
1263 int numChannels = x->numOfChannels;
1265 if (x->x_obj.z_disabled)
1266 return (w + 4 + numChannels);
1271 t_sample *out[Properties::MAXNUMCHANNELS];
1272 bool micGainNonZero[Properties::MAXNUMCHANNELS];
1274 int n = (t_int)(w[3 + x->numOfChannels]);
1275 int phase = x->c_phase;
1277 int renderInterval = x->renderInterval;
1278 int GrainCounter = x->grainCounter;
1279 int numOfRefl = x->numRefl;
1280 int maxDynRefl = x->maxDynRefl;
1281 int reflOrderIndex = 0;
1282 double *reflGains = x->reflGains;
1283 double *currentDelay = x->currentDelay;
1284 double *currentSensitivity = x->currentSensitivity;
1285 double *delGrain = x->delGrain;
1286 double *sensiGrain = x->sensiGrain;
1287 double *bp = x->c_vec + phase;
1288 double *ep = x->c_vec + Properties::DELAYSIZE;
1290 int idelay, idelayOld;
1291 double newSamp, oldSamp, newReflSamps, oldReflSamps, reflSamps = 0.0;
1293 double *delay = x->delay;
1294 double *sensitivity = x->sensitivity;
1295 int numwallsMinusOne = Properties::NUMWALLS - 1;
1296 int numOfReflTimesK;
1301 HiMidLow **xfadeWalls = x->room->xfadeWalls;
1302 LowPass *xfadeAir = x->room->xfadeAir;
1306 in = (t_sample *)(w[2]);
1308 for (
int i = 0; i < numChannels; ++i)
1310 out[i] = (t_sample *)(w[3 + i]);
1311 if (x->room->mics[i].gain() != 0.0)
1312 micGainNonZero[i] =
true;
1314 micGainNonZero[i] =
false;
1317 switch (x->AudioProcType)
1319 case Properties::VIMIC_LITE:
1321 if (GrainCounter < renderInterval)
1323 double a, b, c, d, cminusb;
1329 *(bp + Properties::DELAYSIZE) = f;
1331 for (
int k = 0; k < numChannels; ++k)
1335 numOfReflTimesK = numOfRefl * k;
1337 if (micGainNonZero[k])
1339 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
1341 reflOrderIndex = reflNum + numOfReflTimesK;
1343 *(currentDelay + reflOrderIndex) += *(delGrain + reflOrderIndex);
1344 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
1346 if (*(currentSensitivity + reflOrderIndex) != 0.0)
1348 idelay = *(currentDelay + reflOrderIndex) + 0.5;
1349 frac = *(currentDelay + reflOrderIndex) - (
double) idelay;
1350 sampPos = Properties::DELAYSIZE - idelay;
1352 d = *(bp + sampPos - 3);
1353 c = *(bp + sampPos - 2);
1354 b = *(bp + sampPos - 1);
1355 a = *(bp + sampPos);
1361 *out[k] = (*(currentSensitivity + reflOrderIndex) * (b + frac * (cminusb - 0.1666667 * (1.0 - frac)
1362 * ((d - a - 3.0 * cminusb) * frac + (d + 2.0 * a - 3.0 * b))))) + reflSamps;
1365 reflSamps += *(currentSensitivity + reflOrderIndex)
1366 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb)
1367 * frac + (d + 2.0 * a - 3.0 * b))));
1368 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
1371 reflSamps += *(currentSensitivity + reflOrderIndex)
1372 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb)
1373 * frac + (d + 2.0 * a - 3.0 * b))));
1374 reflSamps = walls[k][6].
tick(reflSamps);
1377 reflSamps += *(currentSensitivity + reflOrderIndex)
1378 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb)
1379 * frac + (d + 2.0 * a - 3.0 * b))));
1388 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
1391 reflSamps = walls[k][6].
tick(reflSamps);
1402 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
1404 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
1405 x->currentDelay[reflNum] = *(currentDelay + reflNum);
1415 *(bp + Properties::DELAYSIZE) = f;
1417 for (
int k = 0; k < numChannels; ++k)
1419 numOfReflTimesK = numOfRefl * k;
1422 if (micGainNonZero[k])
1424 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
1426 reflOrderIndex = reflNum + numOfReflTimesK;
1427 idelay = *(currentDelay + reflOrderIndex) +1.5;
1432 *out[k] = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay) + reflSamps;
1436 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1437 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
1441 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1442 reflSamps = walls[k][6].
tick(reflSamps);
1446 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1462 x->c_phase = phase + blocksize;
1464 if (x->grainCounter < renderInterval)
1468 case Properties::VIMIC_XL:
1469 double frontSamps, rearSamps, floorSamps, ceilSamps, filterInputSamp;
1470 if (GrainCounter < renderInterval)
1472 double a, b, c, d, cminusb;
1477 *(bp + Properties::DELAYSIZE) = f;
1479 for (
int k = 0; k < numChannels; ++k)
1482 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = filterInputSamp = 0.0;
1483 numOfReflTimesK = numOfRefl * k;
1484 if (micGainNonZero[k])
1486 for (
int reflNum = maxDynRefl - 1; reflNum >= 0; --reflNum)
1488 reflOrderIndex = reflNum + numOfReflTimesK;
1489 *(currentDelay + reflOrderIndex) += *(delGrain + reflOrderIndex);
1490 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
1492 if (*(sensitivity + reflOrderIndex) != 0.0)
1494 idelay = 0.5 + *(currentDelay + reflOrderIndex);
1495 frac = *(currentDelay + reflOrderIndex) - (
double) idelay;
1496 sampPos = Properties::DELAYSIZE - idelay;
1498 d = *(bp + sampPos - 3);
1499 c = *(bp + sampPos - 2);
1500 b = *(bp + sampPos - 1);
1501 a = *(bp + sampPos);
1504 filterInputSamp = *(currentSensitivity + reflOrderIndex)
1505 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb) * frac + (d + 2.0 * a - 3.0 * b))));
1509 case Properties::FRONT_FLOOR:
1510 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
1512 case Properties::REAR_FLOOR:
1513 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
1515 case Properties::LEFT_FLOOR:
1516 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1518 case Properties::RIGHT_FLOOR:
1519 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1522 case Properties::LEFT_CEILING:
1523 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1525 case Properties::RIGHT_CEILING:
1526 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1528 case Properties::FRONT_CEILING:
1529 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
1531 case Properties::REAR_CEILING:
1532 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
1535 case Properties::LEFT_FRONT:
1536 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1538 case Properties::RIGHT_FRONT:
1539 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1542 case Properties::LEFT_REAR:
1543 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1545 case Properties::RIGHT_REAR:
1546 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1549 case Properties::AIR:
1550 *out[k] += filterInputSamp;
1555 case Properties::LEFT:
1556 reflSamps += walls[k][0].
tick(filterInputSamp);
1557 *out[k] = air[k][0].
tick(reflSamps);
1560 case Properties::RIGHT:
1561 reflSamps += walls[k][1].
tick(filterInputSamp);
1565 case Properties::FRONT:
1566 frontSamps += filterInputSamp;
1567 reflSamps += walls[k][2].
tick(frontSamps);
1570 case Properties::REAR:
1571 rearSamps += filterInputSamp;
1572 reflSamps += walls[k][3].
tick(rearSamps);
1575 case Properties::FLOOR:
1576 floorSamps += filterInputSamp;
1577 reflSamps += walls[k][4].
tick(floorSamps);
1580 case Properties::CEILING:
1581 ceilSamps += filterInputSamp;
1582 reflSamps += walls[k][5].
tick(ceilSamps);
1590 case Properties::FRONT_FLOOR:
1591 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
1593 case Properties::REAR_FLOOR:
1594 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
1596 case Properties::LEFT_FLOOR:
1597 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1599 case Properties::RIGHT_FLOOR:
1600 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1602 case Properties::LEFT_CEILING:
1603 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1605 case Properties::RIGHT_CEILING:
1606 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1608 case Properties::FRONT_CEILING:
1609 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
1611 case Properties::REAR_CEILING:
1612 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
1615 case Properties::LEFT_FRONT:
1616 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1618 case Properties::RIGHT_FRONT:
1619 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1622 case Properties::LEFT_REAR:
1623 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1625 case Properties::RIGHT_REAR:
1626 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1635 case Properties::LEFT:
1636 reflSamps += walls[k][0].
tick(filterInputSamp);
1637 *out[k] += air[k][0].
tick(reflSamps);
1639 case Properties::RIGHT:
1640 reflSamps += walls[k][1].
tick(filterInputSamp);
1644 case Properties::FRONT:
1646 reflSamps += walls[k][2].
tick(frontSamps);
1649 case Properties::REAR:
1651 reflSamps += walls[k][3].
tick(rearSamps);
1654 case Properties::FLOOR:
1656 reflSamps += walls[k][4].
tick(floorSamps);
1659 case Properties::CEILING:
1661 reflSamps += walls[k][5].
tick(ceilSamps);
1672 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
1674 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
1675 x->currentDelay[reflNum] = *(currentDelay + reflNum);
1687 *(bp + Properties::DELAYSIZE) = f;
1689 for (
int k = 0; k < numChannels; ++k)
1692 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = filterInputSamp = 0.0;
1693 numOfReflTimesK = numOfRefl * k;
1694 if (micGainNonZero[k])
1696 for (
int reflNum = numOfRefl - 1; reflNum >= 0; --reflNum)
1698 if (reflGains[0] != 0.0 || reflGains[1] != 0.0 || reflGains[2] != 0.0)
1700 reflOrderIndex = reflNum + numOfReflTimesK;
1701 idelay = *(currentDelay + reflOrderIndex) +0.5;
1702 filterInputSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1706 case Properties::FRONT_FLOOR:
1707 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
1709 case Properties::REAR_FLOOR:
1710 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
1712 case Properties::LEFT_FLOOR:
1713 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1715 case Properties::RIGHT_FLOOR:
1716 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1718 case Properties::LEFT_CEILING:
1719 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1721 case Properties::RIGHT_CEILING:
1722 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1724 case Properties::FRONT_CEILING:
1725 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
1727 case Properties::REAR_CEILING:
1728 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
1731 case Properties::LEFT_FRONT:
1732 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1734 case Properties::RIGHT_FRONT:
1735 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1738 case Properties::LEFT_REAR:
1739 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
1741 case Properties::RIGHT_REAR:
1742 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
1745 case Properties::AIR:
1746 *out[k] += filterInputSamp;
1750 case Properties::LEFT:
1751 reflSamps += walls[k][0].
tick(filterInputSamp);
1752 *out[k] += air[k][0].
tick(reflSamps);
1755 case Properties::RIGHT:
1756 reflSamps += walls[k][1].
tick(filterInputSamp);
1760 case Properties::FRONT:
1761 frontSamps += filterInputSamp;
1762 reflSamps += walls[k][2].
tick(frontSamps);
1765 case Properties::REAR:
1766 rearSamps += filterInputSamp;
1767 reflSamps += walls[k][3].
tick(rearSamps);
1770 case Properties::FLOOR:
1771 floorSamps += filterInputSamp;
1772 reflSamps += walls[k][4].
tick(floorSamps);
1775 case Properties::CEILING:
1776 ceilSamps += filterInputSamp;
1777 reflSamps += walls[k][5].
tick(ceilSamps);
1793 x->c_phase = phase + blocksize;
1795 if (x->grainCounter < renderInterval)
1800 case Properties::X_FADE_LITE:
1807 *(bp + Properties::DELAYSIZE) = f;
1811 for (
int k = 0; k < numChannels; ++k)
1813 oldSamp = newSamp = 0.0;
1818 if (micGainNonZero[k])
1820 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
1822 reflOrderIndex = reflNum + maxDynRefl * k;
1824 idelay = *(delay + reflOrderIndex) - 0.5;
1825 idelayOld = *(currentDelay + reflOrderIndex) - 0.5;
1831 oldSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
1832 newSamp = *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1833 *out[k] += fades->
tick(newSamp, oldSamp);
1838 oldReflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
1839 newReflSamps += *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1841 *out[k] = xfadeWalls[k][0].
tick(*out[k] + fades->
tick(newReflSamps, oldReflSamps));
1842 *out[k] = xfadeAir[k].
tick(*out[k]);
1847 oldReflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
1848 newReflSamps += *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1850 *out[k] = xfadeWalls[k][1].
tick(fades->
tick(newReflSamps, oldReflSamps));
1856 oldReflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
1857 newReflSamps += *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1869 for (
int k = 0; k < numChannels; ++k)
1871 numOfReflTimesK = numOfRefl * k;
1872 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
1874 reflOrderIndex = reflNum + numOfReflTimesK;
1875 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
1876 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
1881 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
1883 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
1884 x->currentDelay[reflNum] = *(currentDelay + reflNum);
1890 for (
int k = 0; k < numChannels; ++k)
1894 numOfReflTimesK = numOfRefl * k;
1895 if (micGainNonZero[k])
1897 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
1899 reflOrderIndex = reflNum +numOfReflTimesK;
1902 if (GrainCounter < renderInterval)
1903 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
1906 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
1907 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
1910 idelay = *(currentDelay + reflOrderIndex) - 0.5;
1914 case Properties::DIRECT:
1915 *out[k] = (*(currentSensitivity + reflOrderIndex) *
1916 *(bp + Properties::DELAYSIZE - idelay)) + reflSamps;
1920 reflSamps += (*(currentSensitivity + reflOrderIndex) *
1921 *(bp + Properties::DELAYSIZE - idelay));
1923 reflSamps = xfadeWalls[k][0].
tick(reflSamps);
1924 reflSamps = xfadeAir[k].
tick(reflSamps);
1928 reflSamps += (*(currentSensitivity + reflOrderIndex) *
1929 *(bp + Properties::DELAYSIZE - idelay));
1931 reflSamps = xfadeWalls[k][1].
tick(reflSamps);
1935 reflSamps += (*(currentSensitivity + reflOrderIndex) *
1936 *(bp + Properties::DELAYSIZE - idelay));
1950 x->c_phase = phase + blocksize;
1952 if (x->grainCounter < renderInterval)
1959 case Properties::X_FADE_XL:
1960 double oldFilterInputSamp, newFilterInputSamp;
1967 *(bp + Properties::DELAYSIZE) = f;
1971 for (
int k = 0; k < numChannels; ++k)
1973 oldFilterInputSamp = newFilterInputSamp = 0.0;
1974 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = 0.0;
1976 numOfReflTimesK = numOfRefl * k;
1978 if (micGainNonZero[k])
1980 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
1982 reflOrderIndex = reflNum + numOfReflTimesK;
1983 idelay = *(delay + reflOrderIndex) - 0.5;
1984 idelayOld = *(currentDelay + reflOrderIndex) - 0.5;
1986 oldFilterInputSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
1987 newFilterInputSamp = *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
1991 case Properties::FRONT_FLOOR:
1992 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
1994 case Properties::REAR_FLOOR:
1995 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
1997 case Properties::LEFT_FLOOR:
1998 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2000 case Properties::RIGHT_FLOOR:
2001 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2004 case Properties::LEFT_CEILING:
2005 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2007 case Properties::RIGHT_CEILING:
2008 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2010 case Properties::FRONT_CEILING:
2011 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2013 case Properties::REAR_CEILING:
2014 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2017 case Properties::LEFT_FRONT:
2018 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2020 case Properties::RIGHT_FRONT:
2021 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2024 case Properties::LEFT_REAR:
2025 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2027 case Properties::RIGHT_REAR:
2028 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2032 case Properties::AIR:
2033 *out[k] +=fades->
tick(newFilterInputSamp, oldFilterInputSamp);
2036 case Properties::LEFT:
2037 reflSamps = walls[k][Properties::LEFT - 1].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2038 *out[k] = walls[k][0].
tick(reflSamps);
2041 case Properties::RIGHT:
2042 reflSamps += walls[k][Properties::RIGHT - 1].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
2045 case Properties::FRONT:
2046 frontSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
2047 reflSamps += walls[k][Properties::FRONT - 1].
tick(frontSamps);
2050 case Properties::REAR:
2051 rearSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
2052 reflSamps += walls[k][Properties::REAR - 1].
tick(rearSamps);
2055 case Properties::FLOOR:
2056 floorSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
2057 reflSamps += walls[k][Properties::FLOOR - 1].
tick(floorSamps);
2060 case Properties::CEILING:
2061 ceilSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
2062 reflSamps += walls[k][Properties::CEILING - 1].
tick(ceilSamps);
2075 for (
int k = 0; k < numChannels; ++k)
2077 numOfReflTimesK = numOfRefl * k;
2078 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
2080 reflOrderIndex = reflNum + numOfReflTimesK;
2081 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
2082 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
2088 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
2090 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
2091 x->currentDelay[reflNum] = *(currentDelay + reflNum);
2096 for (
int k = 0; k < numChannels; ++k)
2100 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = filterInputSamp = 0.0;
2101 numOfReflTimesK = numOfRefl * k;
2102 if (micGainNonZero[k])
2104 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
2106 reflOrderIndex = reflNum + numOfReflTimesK;
2109 if (GrainCounter < renderInterval)
2110 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
2113 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
2114 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
2117 idelay = *(currentDelay + reflOrderIndex) - 0.5;
2118 filterInputSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2122 case Properties::FRONT_FLOOR:
2123 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2125 case Properties::REAR_FLOOR:
2126 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2128 case Properties::LEFT_FLOOR:
2129 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2131 case Properties::RIGHT_FLOOR:
2132 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2135 case Properties::LEFT_CEILING:
2136 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2138 case Properties::RIGHT_CEILING:
2139 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2141 case Properties::FRONT_CEILING:
2142 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2144 case Properties::REAR_CEILING:
2145 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2148 case Properties::LEFT_FRONT:
2149 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2151 case Properties::RIGHT_FRONT:
2152 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2155 case Properties::LEFT_REAR:
2156 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2158 case Properties::RIGHT_REAR:
2159 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2162 case Properties::DIRECT:
2163 *out[k] += filterInputSamp;
2167 case Properties::LEFT:
2168 reflSamps += walls[k][Properties::LEFT - 1].
tick(filterInputSamp);
2169 *out[k] = air[k][0].
tick(reflSamps);
2172 case Properties::RIGHT:
2173 reflSamps += walls[k][Properties::RIGHT - 1].
tick(filterInputSamp);
2176 case Properties::FRONT:
2177 frontSamps += filterInputSamp;
2178 reflSamps += walls[k][Properties::FRONT - 1].
tick(frontSamps);
2181 case Properties::REAR:
2182 rearSamps += filterInputSamp;
2183 reflSamps += walls[k][Properties::REAR - 1].
tick(rearSamps);
2186 case Properties::FLOOR:
2187 floorSamps += filterInputSamp;
2188 reflSamps += walls[k][Properties::FLOOR - 1].
tick(floorSamps);
2191 case Properties::CEILING:
2192 ceilSamps += filterInputSamp;
2193 reflSamps += walls[k][Properties::CEILING - 1].
tick(ceilSamps);
2207 x->c_phase = phase + blocksize;
2208 if (x->grainCounter < renderInterval)
2216 case Properties::AMP_PAN:
2217 if (GrainCounter < renderInterval)
2224 *(bp + Properties::DELAYSIZE) = f;
2226 for (
int k = 0; k < numChannels; ++k)
2229 if (micGainNonZero[k])
2231 reflOrderIndex = numOfRefl * k;
2232 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
2233 *out[k] = (*(currentSensitivity + reflOrderIndex) * f);
2239 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
2241 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
2252 *(bp + Properties::DELAYSIZE) = f;
2254 for (
int k = 0; k < numChannels; ++k)
2256 if (micGainNonZero[k])
2257 *out[k] = (*(currentSensitivity + numOfRefl * k) * f);
2265 if (x->grainCounter < renderInterval)
2269 case Properties::STATIC:
2270 if (GrainCounter < renderInterval)
2277 *(bp + Properties::DELAYSIZE) = f;
2279 for (
int k = 0; k < numChannels; ++k)
2283 numOfReflTimesK = numOfRefl * k;
2285 if (micGainNonZero[k])
2287 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
2289 reflOrderIndex = reflNum + numOfReflTimesK;
2290 *(currentDelay + reflOrderIndex) += *(delGrain + reflOrderIndex);
2291 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
2292 idelay = *(currentDelay + reflOrderIndex) - 0.5;
2297 *out[k] = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay) + reflSamps;
2301 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2302 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
2306 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2307 reflSamps = walls[k][6].
tick(reflSamps);
2311 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2321 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
2323 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
2324 x->currentDelay[reflNum] = *(currentDelay + reflNum);
2335 *(bp + Properties::DELAYSIZE) = f;
2337 for (
int k=0; k < numChannels; ++k)
2341 numOfReflTimesK = numOfRefl * k;
2343 if (micGainNonZero[k])
2345 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
2347 reflOrderIndex = reflNum + numOfReflTimesK;
2348 idelay = *(currentDelay + reflOrderIndex) - 0.5;
2353 *out[k] = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay) + reflSamps;
2357 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2358 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
2362 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2363 reflSamps = walls[k][6].
tick(reflSamps);
2367 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2380 x->c_phase = phase + blocksize;
2381 if (x->grainCounter < renderInterval)
2385 case Properties::NONE:
2391 *(bp + Properties::DELAYSIZE) = f;
2393 for (
int k = 0; k < numChannels; ++k)
2400 x->c_phase = phase + blocksize;
2401 if (x->grainCounter < renderInterval)
2405 return (w + 4 + numChannels);
2408 #pragma warning(pop)
2410 void vimic_dsp(t_vimic *x, t_signal **sp,
short *count)
2413 for (
int n = 0; n < Properties::DELAYBYTES; n++)
2416 if (x->x_sr != (
double)sp[0]->s_sr)
2418 x->x_sr = (double) sp[0]->s_sr;
2419 x->speedOfSound = (331.3 * sqrt(1.0 + x->temperature / 273.15)) / x->x_sr;
2420 x->invSpeedOfSound = 1.0 / x->speedOfSound;
2424 if (x->blocksize != (
int)sp[0]->s_n)
2426 x->blocksize = (int)sp[0]->s_n;
2428 x->grainsize = 1.0 / (x->blocksize * x->renderInterval);
2433 short num_args = x->numOfChannels + 3;
2435 if (num_args < 4 || num_args > 147)
2436 post(
"j.vimic~ : Combination of Reflection Order and Channels not supported" );
2438 t_int **vec = (t_int **) getbytes(
sizeof(t_int *) * num_args);
2440 vec[0] = (t_int *)x;
2442 for (i = 0; i < num_args - 2; i++)
2443 vec[i + 1] = (t_int *) sp[i]->s_vec;
2445 vec[i + 1] = (t_int *) sp[0]->s_n;
2447 dsp_addv(vimic_perform, num_args, (
void **)vec);
2449 freebytes(vec,
sizeof(t_int *) * num_args);
2452 void vimic_assist(t_vimic *x, Object *b,
long msg,
long arg,
char *s)
2455 if (msg == ASSIST_INLET)
2460 snprintf(s, 256,
"%s",
"Bang, anything, direct sound");
2473 else if (msg == ASSIST_OUTLET)
2474 snprintf(s, 256,
"%s %ld",
"Output", arg + 1);
2477 void vimic_perform64(t_vimic *x, t_object *dsp64,
double **ins,
long numins,
double **outs,
long numouts,
long sampleframes,
long flags,
void *userparam)
2479 int numChannels = x->numOfChannels;
2480 bool micGainNonZero[Properties::MAXNUMCHANNELS];
2482 int phase = x->c_phase;
2483 int renderInterval = x->renderInterval;
2484 int GrainCounter = x->grainCounter;
2485 int numOfRefl = x->numRefl;
2486 int maxDynRefl = x->maxDynRefl;
2487 int reflOrderIndex = 0;
2489 double *reflGains = x->reflGains;
2490 double *currentDelay = x->currentDelay;
2491 double *currentSensitivity = x->currentSensitivity;
2492 double *delGrain = x->delGrain;
2493 double *sensiGrain = x->sensiGrain;
2494 double *bp = x->c_vec + phase;
2495 double *ep = x->c_vec + Properties::DELAYSIZE;
2496 double *delay = x->delay;
2497 double *sensitivity = x->sensitivity;
2500 int idelay, idelayOld;
2501 double newSamp, oldSamp, newReflSamps, oldReflSamps, reflSamps = 0.0;
2505 int numwallsMinusOne = Properties::NUMWALLS - 1;
2506 int numOfReflTimesK;
2512 HiMidLow **xfadeWalls = x->room->xfadeWalls;
2513 LowPass *xfadeAir = x->room->xfadeAir;
2517 double a, b, c, d, cminusb;
2519 for (
int i = 0; i < numChannels; ++i)
2521 if (x->room->mics[i].gain() != 0.0)
2522 micGainNonZero[i] =
true;
2524 micGainNonZero[i] =
false;
2528 memcpy(bp, ins[0],
sizeof(
double) * sampleframes);
2529 memcpy((bp + Properties::DELAYSIZE), ins[0],
sizeof(
double) * sampleframes);
2531 switch (x->AudioProcType)
2533 case Properties::VIMIC_LITE:
2535 if (GrainCounter < renderInterval) {
2536 for (
int k = 0; k < numChannels; ++k) {
2537 memset(outs[k], 0,
sizeof(
double) * sampleframes);
2538 numOfReflTimesK = numOfRefl * k;
2539 if (micGainNonZero[k]) {
2540 for (
int n=0 ; n < sampleframes; n++) {
2543 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum) {
2544 reflOrderIndex = reflNum + numOfReflTimesK;
2545 *(currentDelay + reflOrderIndex) += *(delGrain + reflOrderIndex);
2546 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
2547 if (*(currentSensitivity + reflOrderIndex) != 0.0) {
2548 idelay = *(currentDelay + reflOrderIndex) + 0.5;
2549 frac = *(currentDelay + reflOrderIndex) - (
double) idelay;
2550 sampPos = Properties::DELAYSIZE - idelay + n;
2552 d = *(bp + sampPos - 3);
2553 c = *(bp + sampPos - 2);
2554 b = *(bp + sampPos - 1);
2555 a = *(bp + sampPos);
2560 outs[k][n] = (*(currentSensitivity + reflOrderIndex) * (b + frac * (cminusb - 0.1666667 * (1.0 - frac)
2561 * ((d - a - 3.0 * cminusb) * frac + (d + 2.0 * a - 3.0 * b))))) + reflSamps;
2564 reflSamps += *(currentSensitivity + reflOrderIndex)
2565 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb)
2566 * frac + (d + 2.0 * a - 3.0 * b))));
2567 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
2570 reflSamps += *(currentSensitivity + reflOrderIndex)
2571 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb)
2572 * frac + (d + 2.0 * a - 3.0 * b))));
2573 reflSamps = walls[k][6].
tick(reflSamps);
2576 reflSamps += *(currentSensitivity + reflOrderIndex)
2577 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb)
2578 * frac + (d + 2.0 * a - 3.0 * b))));
2585 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
2588 reflSamps = walls[k][6].
tick(reflSamps);
2597 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum) {
2599 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
2600 x->currentDelay[reflNum] = *(currentDelay + reflNum);
2604 for (
int k = 0; k < numChannels; ++k) {
2605 memset(outs[k], 0,
sizeof(
double) * sampleframes);
2606 numOfReflTimesK = numOfRefl * k;
2607 if (micGainNonZero[k]) {
2608 for (
int n=0 ; n < sampleframes; n++) {
2610 sampPos = n + Properties::DELAYSIZE;
2611 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum) {
2612 reflOrderIndex = reflNum + numOfReflTimesK;
2613 idelay = *(currentDelay + reflOrderIndex) +1.5;
2617 outs[k][n] = *(currentSensitivity + reflOrderIndex) * *(bp+ sampPos - idelay) + reflSamps;
2621 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp+sampPos - idelay);
2622 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
2626 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp+sampPos - idelay);
2627 reflSamps = walls[k][6].
tick(reflSamps);
2631 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp+sampPos - idelay);
2644 x->c_phase = phase + sampleframes;
2646 if (x->grainCounter < renderInterval)
2650 case Properties::VIMIC_XL:
2651 double frontSamps, rearSamps, floorSamps, ceilSamps, filterInputSamp;
2652 if (GrainCounter < renderInterval) {
2653 for (
int k = 0; k < numChannels; ++k) {
2654 memset(outs[k],0 ,
sizeof(
double)*sampleframes);
2655 if (micGainNonZero[k]) {
2656 numOfReflTimesK = numOfRefl * k;
2657 for (
int n=0 ; n < sampleframes; n++) {
2658 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = filterInputSamp = 0.0;
2659 for (
int reflNum = maxDynRefl - 1; reflNum >= 0; --reflNum) {
2660 reflOrderIndex = reflNum + numOfReflTimesK;
2661 *(currentDelay + reflOrderIndex) += *(delGrain + reflOrderIndex);
2662 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
2664 if (*(sensitivity + reflOrderIndex) != 0.0) {
2665 idelay = 0.5 + *(currentDelay + reflOrderIndex);
2666 frac = *(currentDelay + reflOrderIndex) - (
double) idelay;
2667 sampPos = Properties::DELAYSIZE - idelay + n;
2669 d = *(bp + sampPos - 3);
2670 c = *(bp + sampPos - 2);
2671 b = *(bp + sampPos - 1);
2672 a = *(bp + sampPos);
2675 filterInputSamp = *(currentSensitivity + reflOrderIndex)
2676 * (b + frac * (cminusb - 0.1666667 * (1.0 - frac) * ((d - a - 3.0 * cminusb) * frac + (d + 2.0 * a - 3.0 * b))));
2680 case Properties::FRONT_FLOOR:
2681 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2683 case Properties::REAR_FLOOR:
2684 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2686 case Properties::LEFT_FLOOR:
2687 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2689 case Properties::RIGHT_FLOOR:
2690 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2693 case Properties::LEFT_CEILING:
2694 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2696 case Properties::RIGHT_CEILING:
2697 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2699 case Properties::FRONT_CEILING:
2700 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2702 case Properties::REAR_CEILING:
2703 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2706 case Properties::LEFT_FRONT:
2707 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2709 case Properties::RIGHT_FRONT:
2710 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2713 case Properties::LEFT_REAR:
2714 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2716 case Properties::RIGHT_REAR:
2717 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2720 case Properties::AIR:
2721 outs[k][n] += filterInputSamp;
2726 case Properties::LEFT:
2727 reflSamps += walls[k][0].
tick(filterInputSamp);
2728 outs[k][n] = air[k][0].
tick(reflSamps);
2731 case Properties::RIGHT:
2732 reflSamps += walls[k][1].
tick(filterInputSamp);
2736 case Properties::FRONT:
2737 frontSamps += filterInputSamp;
2738 reflSamps += walls[k][2].
tick(frontSamps);
2741 case Properties::REAR:
2742 rearSamps += filterInputSamp;
2743 reflSamps += walls[k][3].
tick(rearSamps);
2746 case Properties::FLOOR:
2747 floorSamps += filterInputSamp;
2748 reflSamps += walls[k][4].
tick(floorSamps);
2751 case Properties::CEILING:
2752 ceilSamps += filterInputSamp;
2753 reflSamps += walls[k][5].
tick(ceilSamps);
2760 case Properties::FRONT_FLOOR:
2761 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2763 case Properties::REAR_FLOOR:
2764 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2766 case Properties::LEFT_FLOOR:
2767 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2769 case Properties::RIGHT_FLOOR:
2770 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2772 case Properties::LEFT_CEILING:
2773 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2775 case Properties::RIGHT_CEILING:
2776 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2778 case Properties::FRONT_CEILING:
2779 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2781 case Properties::REAR_CEILING:
2782 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2785 case Properties::LEFT_FRONT:
2786 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2788 case Properties::RIGHT_FRONT:
2789 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2792 case Properties::LEFT_REAR:
2793 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2795 case Properties::RIGHT_REAR:
2796 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2805 case Properties::LEFT:
2806 reflSamps += walls[k][0].
tick(filterInputSamp);
2807 outs[k][n] += air[k][0].
tick(reflSamps);
2809 case Properties::RIGHT:
2810 reflSamps += walls[k][1].
tick(filterInputSamp);
2814 case Properties::FRONT:
2816 reflSamps += walls[k][2].
tick(frontSamps);
2819 case Properties::REAR:
2821 reflSamps += walls[k][3].
tick(rearSamps);
2824 case Properties::FLOOR:
2826 reflSamps += walls[k][4].
tick(floorSamps);
2829 case Properties::CEILING:
2831 reflSamps += walls[k][5].
tick(ceilSamps);
2839 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum) {
2841 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
2842 x->currentDelay[reflNum] = *(currentDelay + reflNum);
2847 for (
int k = 0; k < numChannels; ++k) {
2848 memset(outs[k], 0,
sizeof(
double)*sampleframes);
2849 if (micGainNonZero[k]) {
2850 numOfReflTimesK = numOfRefl * k;
2851 for (
int n=0 ; n < sampleframes; n++) {
2852 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = filterInputSamp = 0.0;
2853 for (
int reflNum = numOfRefl - 1; reflNum >= 0; --reflNum)
2855 if (reflGains[0] != 0.0 || reflGains[1] != 0.0 || reflGains[2] != 0.0)
2857 reflOrderIndex = reflNum + numOfReflTimesK;
2858 idelay = *(currentDelay + reflOrderIndex) +0.5;
2859 filterInputSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay + n);
2863 case Properties::FRONT_FLOOR:
2864 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2866 case Properties::REAR_FLOOR:
2867 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2869 case Properties::LEFT_FLOOR:
2870 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2872 case Properties::RIGHT_FLOOR:
2873 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2875 case Properties::LEFT_CEILING:
2876 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2878 case Properties::RIGHT_CEILING:
2879 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2881 case Properties::FRONT_CEILING:
2882 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
2884 case Properties::REAR_CEILING:
2885 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
2888 case Properties::LEFT_FRONT:
2889 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2891 case Properties::RIGHT_FRONT:
2892 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2895 case Properties::LEFT_REAR:
2896 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
2898 case Properties::RIGHT_REAR:
2899 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
2902 case Properties::AIR:
2903 outs[k][n] += filterInputSamp;
2907 case Properties::LEFT:
2908 reflSamps += walls[k][0].
tick(filterInputSamp);
2909 outs[k][n] += air[k][0].
tick(reflSamps);
2912 case Properties::RIGHT:
2913 reflSamps += walls[k][1].
tick(filterInputSamp);
2917 case Properties::FRONT:
2918 frontSamps += filterInputSamp;
2919 reflSamps += walls[k][2].
tick(frontSamps);
2922 case Properties::REAR:
2923 rearSamps += filterInputSamp;
2924 reflSamps += walls[k][3].
tick(rearSamps);
2927 case Properties::FLOOR:
2928 floorSamps += filterInputSamp;
2929 reflSamps += walls[k][4].
tick(floorSamps);
2932 case Properties::CEILING:
2933 ceilSamps += filterInputSamp;
2934 reflSamps += walls[k][5].
tick(ceilSamps);
2947 x->c_phase = phase + sampleframes;
2949 if (x->grainCounter < renderInterval)
2954 case Properties::X_FADE_LITE:
2956 for (
int n=0 ; n < sampleframes; n++)
2960 for (
int k = 0; k < numChannels; ++k)
2962 oldSamp = newSamp = 0.0;
2967 if (micGainNonZero[k])
2969 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
2971 reflOrderIndex = reflNum + maxDynRefl * k;
2973 idelay = *(delay + reflOrderIndex) - 0.5;
2974 idelayOld = *(currentDelay + reflOrderIndex) - 0.5;
2980 oldSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
2981 newSamp = *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2982 outs[k][n] += fades->
tick(newSamp, oldSamp);
2987 oldReflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
2988 newReflSamps += *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2990 outs[k][n] = xfadeWalls[k][0].
tick(outs[k][n] + fades->
tick(newReflSamps, oldReflSamps));
2991 outs[k][n] = xfadeAir[k].
tick(outs[k][n]);
2996 oldReflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
2997 newReflSamps += *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
2999 outs[k][n] = xfadeWalls[k][1].
tick(fades->
tick(newReflSamps, oldReflSamps));
3005 oldReflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
3006 newReflSamps += *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3017 for (
int k = 0; k < numChannels; ++k)
3019 numOfReflTimesK = numOfRefl * k;
3020 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
3022 reflOrderIndex = reflNum + numOfReflTimesK;
3023 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
3024 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
3029 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
3031 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
3032 x->currentDelay[reflNum] = *(currentDelay + reflNum);
3038 for (
int k = 0; k < numChannels; ++k)
3042 numOfReflTimesK = numOfRefl * k;
3043 if (micGainNonZero[k])
3045 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
3047 reflOrderIndex = reflNum +numOfReflTimesK;
3050 if (GrainCounter < renderInterval)
3051 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
3054 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
3055 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
3058 idelay = *(currentDelay + reflOrderIndex) - 0.5;
3062 case Properties::DIRECT:
3063 outs[k][n] = (*(currentSensitivity + reflOrderIndex) *
3064 *(bp + Properties::DELAYSIZE - idelay)) + reflSamps;
3068 reflSamps += (*(currentSensitivity + reflOrderIndex) *
3069 *(bp + Properties::DELAYSIZE - idelay));
3071 reflSamps = xfadeWalls[k][0].
tick(reflSamps);
3072 reflSamps = xfadeAir[k].
tick(reflSamps);
3076 reflSamps += (*(currentSensitivity + reflOrderIndex) *
3077 *(bp + Properties::DELAYSIZE - idelay));
3079 reflSamps = xfadeWalls[k][1].
tick(reflSamps);
3083 reflSamps += (*(currentSensitivity + reflOrderIndex) *
3084 *(bp + Properties::DELAYSIZE - idelay));
3097 x->c_phase = phase + sampleframes;
3099 if (x->grainCounter < renderInterval)
3104 case Properties::X_FADE_XL:
3105 double oldFilterInputSamp, newFilterInputSamp;
3107 for (
int n=0 ; n < sampleframes; n++)
3111 for (
int k = 0; k < numChannels; ++k)
3113 oldFilterInputSamp = newFilterInputSamp = 0.0;
3114 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = 0.0;
3116 numOfReflTimesK = numOfRefl * k;
3118 if (micGainNonZero[k])
3120 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
3122 reflOrderIndex = reflNum + numOfReflTimesK;
3123 idelay = *(delay + reflOrderIndex) - 0.5;
3124 idelayOld = *(currentDelay + reflOrderIndex) - 0.5;
3126 oldFilterInputSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelayOld);
3127 newFilterInputSamp = *(sensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3131 case Properties::FRONT_FLOOR:
3132 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3134 case Properties::REAR_FLOOR:
3135 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3137 case Properties::LEFT_FLOOR:
3138 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3140 case Properties::RIGHT_FLOOR:
3141 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3144 case Properties::LEFT_CEILING:
3145 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3147 case Properties::RIGHT_CEILING:
3148 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3150 case Properties::FRONT_CEILING:
3151 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3153 case Properties::REAR_CEILING:
3154 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3157 case Properties::LEFT_FRONT:
3158 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3160 case Properties::RIGHT_FRONT:
3161 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3164 case Properties::LEFT_REAR:
3165 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3167 case Properties::RIGHT_REAR:
3168 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3172 case Properties::AIR:
3173 outs[k][n] +=fades->
tick(newFilterInputSamp, oldFilterInputSamp);
3176 case Properties::LEFT:
3177 reflSamps = walls[k][Properties::LEFT - 1].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3178 outs[k][n] = walls[k][0].
tick(reflSamps);
3181 case Properties::RIGHT:
3182 reflSamps += walls[k][Properties::RIGHT - 1].
tick(fades->
tick(newFilterInputSamp, oldFilterInputSamp));
3185 case Properties::FRONT:
3186 frontSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
3187 reflSamps += walls[k][Properties::FRONT - 1].
tick(frontSamps);
3190 case Properties::REAR:
3191 rearSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
3192 reflSamps += walls[k][Properties::REAR - 1].
tick(rearSamps);
3195 case Properties::FLOOR:
3196 floorSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
3197 reflSamps += walls[k][Properties::FLOOR - 1].
tick(floorSamps);
3200 case Properties::CEILING:
3201 ceilSamps += fades->
tick(newFilterInputSamp, oldFilterInputSamp);
3202 reflSamps += walls[k][Properties::CEILING - 1].
tick(ceilSamps);
3214 for (
int k = 0; k < numChannels; ++k)
3216 numOfReflTimesK = numOfRefl * k;
3217 for (
int reflNum = maxDynRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
3219 reflOrderIndex = reflNum + numOfReflTimesK;
3220 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
3221 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
3227 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
3229 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
3230 x->currentDelay[reflNum] = *(currentDelay + reflNum);
3235 for (
int k = 0; k < numChannels; ++k)
3239 frontSamps = rearSamps = floorSamps = ceilSamps = reflSamps = filterInputSamp = 0.0;
3240 numOfReflTimesK = numOfRefl * k;
3241 if (micGainNonZero[k])
3243 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
3245 reflOrderIndex = reflNum + numOfReflTimesK;
3248 if (GrainCounter < renderInterval)
3249 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
3252 *(currentSensitivity + reflOrderIndex) = *(sensitivity + reflOrderIndex);
3253 *(currentDelay + reflOrderIndex) = *(delay + reflOrderIndex);
3256 idelay = *(currentDelay + reflOrderIndex) - 0.5;
3257 filterInputSamp = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3261 case Properties::FRONT_FLOOR:
3262 floorSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
3264 case Properties::REAR_FLOOR:
3265 floorSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
3267 case Properties::LEFT_FLOOR:
3268 floorSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
3270 case Properties::RIGHT_FLOOR:
3271 floorSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
3274 case Properties::LEFT_CEILING:
3275 ceilSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
3277 case Properties::RIGHT_CEILING:
3278 ceilSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
3280 case Properties::FRONT_CEILING:
3281 ceilSamps += walls[k][Properties::FRONT + numwallsMinusOne].
tick(filterInputSamp);
3283 case Properties::REAR_CEILING:
3284 ceilSamps += walls[k][Properties::REAR + numwallsMinusOne].
tick(filterInputSamp);
3287 case Properties::LEFT_FRONT:
3288 frontSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
3290 case Properties::RIGHT_FRONT:
3291 frontSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
3294 case Properties::LEFT_REAR:
3295 rearSamps += walls[k][Properties::LEFT + numwallsMinusOne].
tick(filterInputSamp);
3297 case Properties::RIGHT_REAR:
3298 rearSamps += walls[k][Properties::RIGHT + numwallsMinusOne].
tick(filterInputSamp);
3301 case Properties::DIRECT:
3302 outs[k][n] += filterInputSamp;
3306 case Properties::LEFT:
3307 reflSamps += walls[k][Properties::LEFT - 1].
tick(filterInputSamp);
3308 outs[k][n] = air[k][0].
tick(reflSamps);
3311 case Properties::RIGHT:
3312 reflSamps += walls[k][Properties::RIGHT - 1].
tick(filterInputSamp);
3315 case Properties::FRONT:
3316 frontSamps += filterInputSamp;
3317 reflSamps += walls[k][Properties::FRONT - 1].
tick(frontSamps);
3320 case Properties::REAR:
3321 rearSamps += filterInputSamp;
3322 reflSamps += walls[k][Properties::REAR - 1].
tick(rearSamps);
3325 case Properties::FLOOR:
3326 floorSamps += filterInputSamp;
3327 reflSamps += walls[k][Properties::FLOOR - 1].
tick(floorSamps);
3330 case Properties::CEILING:
3331 ceilSamps += filterInputSamp;
3332 reflSamps += walls[k][Properties::CEILING - 1].
tick(ceilSamps);
3345 x->c_phase = phase + sampleframes;
3346 if (x->grainCounter < renderInterval)
3351 case Properties::AMP_PAN:
3352 if (GrainCounter < renderInterval) {
3353 for (
int k = 0; k < numChannels; k++) {
3354 memset(outs[k], 0,
sizeof(
double)*sampleframes);
3355 if (micGainNonZero[k]) {
3356 reflOrderIndex = numOfRefl * k;
3357 for (
int n=0 ; n < sampleframes; n++) {
3358 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
3359 outs[k][n] = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE + n);
3363 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum) {
3365 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
3369 for (
int k = 0; k < numChannels; k++) {
3370 memset(outs[k], 0,
sizeof(
double)*sampleframes);
3371 if (micGainNonZero[k]) {
3372 reflOrderIndex = numOfRefl * k;
3373 for (
int n=0 ; n < sampleframes; n++) {
3374 outs[k][n] = *(bp + Properties::DELAYSIZE + n) * *(currentSensitivity + reflOrderIndex);
3384 x->c_phase = phase + sampleframes;
3386 if (x->grainCounter < renderInterval)
3390 case Properties::STATIC:
3391 if (GrainCounter < renderInterval)
3393 for (
int n=0 ; n < sampleframes; n++)
3395 for (
int k = 0; k < numChannels; ++k)
3399 numOfReflTimesK = numOfRefl * k;
3401 if (micGainNonZero[k])
3403 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
3405 reflOrderIndex = reflNum + numOfReflTimesK;
3406 *(currentDelay + reflOrderIndex) += *(delGrain + reflOrderIndex);
3407 *(currentSensitivity + reflOrderIndex) += *(sensiGrain + reflOrderIndex);
3408 idelay = *(currentDelay + reflOrderIndex) - 0.5;
3413 outs[k][n] = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay) + reflSamps;
3417 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3418 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
3422 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3423 reflSamps = walls[k][6].
tick(reflSamps);
3427 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3436 for (
int reflNum = 0 ; reflNum < numChannels * numOfRefl ; ++reflNum)
3438 x->currentSensitivity[reflNum] = *(currentSensitivity + reflNum);
3439 x->currentDelay[reflNum] = *(currentDelay + reflNum);
3445 for (
int n=0 ; n < sampleframes; n++)
3447 for (
int k=0; k < numChannels; ++k)
3451 numOfReflTimesK = numOfRefl * k;
3453 if (micGainNonZero[k])
3455 for (
int reflNum = numOfRefl - 1; reflNum >= Properties::DIRECT; --reflNum)
3457 reflOrderIndex = reflNum + numOfReflTimesK;
3458 idelay = *(currentDelay + reflOrderIndex) - 0.5;
3463 outs[k][n] = *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay) + reflSamps;
3467 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3468 reflSamps = air[k][0].
tick(walls[k][0].tick(reflSamps));
3472 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3473 reflSamps = walls[k][6].
tick(reflSamps);
3477 reflSamps += *(currentSensitivity + reflOrderIndex) * *(bp + Properties::DELAYSIZE - idelay);
3489 x->c_phase = phase + sampleframes;
3490 if (x->grainCounter < renderInterval)
3495 case Properties::NONE:
3497 for (
int k = 0; k < numChannels; k++) {
3498 memset(outs[k], 0,
sizeof(
double) * sampleframes);
3504 x->c_phase = phase + sampleframes;
3506 if (x->grainCounter < renderInterval)
3513 void vimic_dsp64(t_vimic *x, t_object *dsp64,
short *count,
double samplerate,
long maxvectorsize,
long flags)
3516 for (
int n = 0; n < Properties::DELAYBYTES; n++)
3519 if (x->x_sr != samplerate)
3521 x->x_sr = samplerate;
3522 x->speedOfSound = (331.3 * sqrt(1.0 + x->temperature / 273.15)) / x->x_sr;
3523 x->invSpeedOfSound = 1.0 / x->speedOfSound;
3526 if (x->blocksize != (
int)maxvectorsize) {
3527 x->blocksize = (int)maxvectorsize;
3528 x->grainsize = 1.0 / (x->blocksize * x->renderInterval);
3531 object_method(dsp64, gensym(
"dsp_add64"), x, vimic_perform64, 0, NULL);
bool isActive() const
True if a crossfade is underway, false othewise.
double tick(double input)
Given an input sample, returns a filtered output sample.
void TTDSP_EXPORT TTDSPInit(const char *pathToBinaries=NULL)
Initialise the Jamoma DSP library, as well as Jamoma Foundation foundation if needed.
void increment()
Increment top level crossfade.
double tick(double fadeInInput, double fadeOutInput)
Out value of crossfade.