-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrnbo_source.cpp
1678 lines (1398 loc) · 48.4 KB
/
rnbo_source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************************************************
Copyright (c) 2023 Cycling '74
The code that Max generates automatically and that end users are capable of
exporting and using, and any associated documentation files (the “Software”)
is a work of authorship for which Cycling '74 is the author and owner for
copyright purposes.
This Software is dual-licensed either under the terms of the Cycling '74
License for Max-Generated Code for Export, or alternatively under the terms
of the General Public License (GPL) Version 3. You may use the Software
according to either of these licenses as it is most appropriate for your
project on a case-by-case basis (proprietary or not).
A) Cycling '74 License for Max-Generated Code for Export
A license is hereby granted, free of charge, to any person obtaining a copy
of the Software (“Licensee”) to use, copy, modify, merge, publish, and
distribute copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
The Software is licensed to Licensee for all uses that do not include the sale,
sublicensing, or commercial distribution of software that incorporates this
source code. This means that the Licensee is free to use this software for
educational, research, and prototyping purposes, to create musical or other
creative works with software that incorporates this source code, or any other
use that does not constitute selling software that makes use of this source
code. Commercial distribution also includes the packaging of free software with
other paid software, hardware, or software-provided commercial services.
For entities with UNDER $200k in annual revenue or funding, a license is hereby
granted, free of charge, for the sale, sublicensing, or commercial distribution
of software that incorporates this source code, for as long as the entity's
annual revenue remains below $200k annual revenue or funding.
For entities with OVER $200k in annual revenue or funding interested in the
sale, sublicensing, or commercial distribution of software that incorporates
this source code, please send inquiries to [email protected].
The above copyright notice and this license shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Please see
https://support.cycling74.com/hc/en-us/articles/10730637742483-RNBO-Export-Licensing-FAQ
for additional information
B) General Public License Version 3 (GPLv3)
Details of the GPLv3 license can be found at: https://www.gnu.org/licenses/gpl-3.0.html
*******************************************************************************************************************/
#include "RNBO_Common.h"
#include "RNBO_AudioSignal.h"
namespace RNBO {
#define trunc(x) ((Int)(x))
#if defined(__GNUC__) || defined(__clang__)
#define RNBO_RESTRICT __restrict__
#elif defined(_MSC_VER)
#define RNBO_RESTRICT __restrict
#endif
#define FIXEDSIZEARRAYINIT(...) { }
class rnbomatic : public PatcherInterfaceImpl {
public:
rnbomatic()
{
}
~rnbomatic()
{
}
rnbomatic* getTopLevelPatcher() {
return this;
}
void cancelClockEvents()
{
getEngine()->flushClockEvents(this, -871642103, false);
}
template <typename T> void listquicksort(T& arr, T& sortindices, Int l, Int h, bool ascending) {
if (l < h) {
Int p = (Int)(this->listpartition(arr, sortindices, l, h, ascending));
this->listquicksort(arr, sortindices, l, p - 1, ascending);
this->listquicksort(arr, sortindices, p + 1, h, ascending);
}
}
template <typename T> Int listpartition(T& arr, T& sortindices, Int l, Int h, bool ascending) {
number x = arr[(Index)h];
Int i = (Int)(l - 1);
for (Int j = (Int)(l); j <= h - 1; j++) {
bool asc = (bool)((bool)(ascending) && arr[(Index)j] <= x);
bool desc = (bool)((bool)(!(bool)(ascending)) && arr[(Index)j] >= x);
if ((bool)(asc) || (bool)(desc)) {
i++;
this->listswapelements(arr, i, j);
this->listswapelements(sortindices, i, j);
}
}
i++;
this->listswapelements(arr, i, h);
this->listswapelements(sortindices, i, h);
return i;
}
template <typename T> void listswapelements(T& arr, Int a, Int b) {
auto tmp = arr[(Index)a];
arr[(Index)a] = arr[(Index)b];
arr[(Index)b] = tmp;
}
number wrap(number x, number low, number high) {
number lo;
number hi;
if (low == high)
return low;
if (low > high) {
hi = low;
lo = high;
} else {
lo = low;
hi = high;
}
number range = hi - lo;
if (x >= lo && x < hi)
return x;
if (range <= 0.000000001)
return lo;
long numWraps = (long)(trunc((x - lo) / range));
numWraps = numWraps - ((x < lo ? 1 : 0));
number result = x - range * numWraps;
if (result >= hi)
return result - range;
else
return result;
}
number samplerate() {
return this->sr;
}
number minimum(number x, number y) {
return (y < x ? y : x);
}
number maximum(number x, number y) {
return (x < y ? y : x);
}
number mstosamps(MillisecondTime ms) {
return ms * this->sr * 0.001;
}
Index vectorsize() {
return this->vs;
}
MillisecondTime currenttime() {
return this->_currentTime;
}
number tempo() {
return this->getTopLevelPatcher()->globaltransport_getTempo(this->currenttime());
}
number mstobeats(number ms) {
return ms * this->tempo() * 0.008 / (number)480;
}
MillisecondTime sampstoms(number samps) {
return samps * 1000 / this->sr;
}
Index getNumMidiInputPorts() const {
return 1;
}
void processMidiEvent(MillisecondTime time, int port, ConstByteArray data, Index length) {
this->updateTime(time);
this->midiin_01_midihandler(data[0] & 240, (data[0] & 15) + 1, port, data, length);
}
Index getNumMidiOutputPorts() const {
return 1;
}
void process(
const SampleValue * const* inputs,
Index numInputs,
SampleValue * const* outputs,
Index numOutputs,
Index n
) {
this->vs = n;
this->updateTime(this->getEngine()->getCurrentTime());
const SampleValue * freq = (numInputs >= 1 && inputs[0] ? inputs[0] : this->zeroBuffer);
SampleValue * out0 = (numOutputs >= 1 && outputs[0] ? outputs[0] : this->dummyBuffer);
SampleValue * out1 = (numOutputs >= 2 && outputs[1] ? outputs[1] : this->dummyBuffer);
this->paramtilde_01_perform(freq, this->signals[0], n);
this->gen_01_perform(this->signals[0], this->signals[1], n);
this->groove_01_perform(
this->groove_01_rate_auto,
this->groove_01_begin,
this->groove_01_end,
this->signals[0],
this->dummyBuffer,
n
);
this->signaladder_01_perform(this->signals[1], this->signals[0], out0, n);
this->signaladder_02_perform(this->signals[1], this->signals[0], out1, n);
this->stackprotect_perform(n);
this->globaltransport_advance();
this->audioProcessSampleCount += this->vs;
}
void prepareToProcess(number sampleRate, Index maxBlockSize, bool force) {
if (this->maxvs < maxBlockSize || !this->didAllocateSignals) {
Index i;
for (i = 0; i < 2; i++) {
this->signals[i] = resizeSignal(this->signals[i], this->maxvs, maxBlockSize);
}
this->paramtilde_01_sigbuf = resizeSignal(this->paramtilde_01_sigbuf, this->maxvs, maxBlockSize);
this->globaltransport_tempo = resizeSignal(this->globaltransport_tempo, this->maxvs, maxBlockSize);
this->globaltransport_state = resizeSignal(this->globaltransport_state, this->maxvs, maxBlockSize);
this->zeroBuffer = resizeSignal(this->zeroBuffer, this->maxvs, maxBlockSize);
this->dummyBuffer = resizeSignal(this->dummyBuffer, this->maxvs, maxBlockSize);
this->didAllocateSignals = true;
}
const bool sampleRateChanged = sampleRate != this->sr;
const bool maxvsChanged = maxBlockSize != this->maxvs;
const bool forceDSPSetup = sampleRateChanged || maxvsChanged || force;
if (sampleRateChanged || maxvsChanged) {
this->vs = maxBlockSize;
this->maxvs = maxBlockSize;
this->sr = sampleRate;
this->invsr = 1 / sampleRate;
}
this->paramtilde_01_dspsetup(forceDSPSetup);
this->groove_01_dspsetup(forceDSPSetup);
this->data_01_dspsetup(forceDSPSetup);
this->globaltransport_dspsetup(forceDSPSetup);
if (sampleRateChanged)
this->onSampleRateChanged(sampleRate);
}
void setProbingTarget(MessageTag id) {
switch (id) {
default:
{
this->setProbingIndex(-1);
break;
}
}
}
void setProbingIndex(ProbingIndex ) {}
Index getProbingChannels(MessageTag outletId) const {
RNBO_UNUSED(outletId);
return 0;
}
DataRef* getDataRef(DataRefIndex index) {
switch (index) {
case 0:
{
return addressOf(this->test);
break;
}
default:
{
return nullptr;
}
}
}
DataRefIndex getNumDataRefs() const {
return 1;
}
void filltest(DataRef& ref) {
Float32BufferRef buffer;
buffer = new Float32Buffer(ref);
number bufsize = buffer->getSize();
for (number channel = 0; channel < buffer->getChannels(); channel++) {
for (int index = 0; index < bufsize; index++) {
number x = index / bufsize;
number value = rnbo_sin(2 * x);
buffer->setSample(channel, index, value);
}
}
}
void fillDataRef(DataRefIndex index, DataRef& ref) {
switch (index) {
case 0:
{
this->filltest(ref);
break;
}
}
}
void processDataViewUpdate(DataRefIndex index, MillisecondTime time) {
this->updateTime(time);
if (index == 0) {
this->groove_01_buffer = new Float32Buffer(this->test);
this->data_01_buffer = new Float32Buffer(this->test);
this->data_01_bufferUpdated();
}
}
void initialize() {
this->test = initDataRef("test", false, nullptr, "buffer~");
this->assign_defaults();
this->setState();
this->test->setIndex(0);
this->groove_01_buffer = new Float32Buffer(this->test);
this->data_01_buffer = new Float32Buffer(this->test);
this->initializeObjects();
this->allocateDataRefs();
this->startup();
}
Index getIsMuted() {
return this->isMuted;
}
void setIsMuted(Index v) {
this->isMuted = v;
}
Index getPatcherSerial() const {
return 0;
}
void getState(PatcherStateInterface& ) {}
void setState() {}
void getPreset(PatcherStateInterface& preset) {
preset["__presetid"] = "rnbo";
}
void setPreset(MillisecondTime , PatcherStateInterface& ) {}
void processTempoEvent(MillisecondTime time, Tempo tempo) {
this->updateTime(time);
if (this->globaltransport_setTempo(this->_currentTime, tempo, false))
{}
}
void processTransportEvent(MillisecondTime time, TransportState state) {
this->updateTime(time);
if (this->globaltransport_setState(this->_currentTime, state, false))
{}
}
void processBeatTimeEvent(MillisecondTime time, BeatTime beattime) {
this->updateTime(time);
if (this->globaltransport_setBeatTime(this->_currentTime, beattime, false))
{}
}
void onSampleRateChanged(double ) {}
void processTimeSignatureEvent(MillisecondTime time, int numerator, int denominator) {
this->updateTime(time);
if (this->globaltransport_setTimeSignature(this->_currentTime, numerator, denominator, false))
{}
}
void setParameterValue(ParameterIndex index, ParameterValue v, MillisecondTime time) {
this->updateTime(time);
switch (index) {
case 0:
{
this->paramtilde_01_value_set(v);
break;
}
case 1:
{
// namedAudioIn: freq
break;
}
}
}
void processParameterEvent(ParameterIndex index, ParameterValue value, MillisecondTime time) {
this->setParameterValue(index, value, time);
}
void processNormalizedParameterEvent(ParameterIndex index, ParameterValue value, MillisecondTime time) {
this->setParameterValueNormalized(index, value, time);
}
ParameterValue getParameterValue(ParameterIndex index) {
switch (index) {
case 0:
{
return this->paramtilde_01_value;
}
case 1:
{
// namedAudioIn: freq
return 0;
}
default:
{
return 0;
}
}
}
ParameterIndex getNumSignalInParameters() const {
return 1;
}
ParameterIndex getNumSignalOutParameters() const {
return 0;
}
ParameterIndex getNumParameters() const {
return 2;
}
ConstCharPointer getParameterName(ParameterIndex index) const {
switch (index) {
case 0:
{
return "freq";
}
case 1:
{
return "freq";
}
default:
{
return "bogus";
}
}
}
ConstCharPointer getParameterId(ParameterIndex index) const {
switch (index) {
case 0:
{
return "freq";
}
case 1:
{
return "/signals/freq";
}
default:
{
return "bogus";
}
}
}
void getParameterInfo(ParameterIndex index, ParameterInfo * info) const {
{
switch (index) {
case 0:
{
info->type = ParameterTypeNumber;
info->initialValue = 440;
info->min = 50;
info->max = 2000;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = true;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
}
case 1:
{
info->type = ParameterTypeSignal;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = false;
info->transmittable = false;
info->initialized = false;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeInput;
info->signalIndex = 0;
break;
}
}
}
}
void sendParameter(ParameterIndex index, bool ignoreValue) {
this->getEngine()->notifyParameterValueChanged(index, (ignoreValue ? 0 : this->getParameterValue(index)), ignoreValue);
}
ParameterValue applyStepsToNormalizedParameterValue(ParameterValue normalizedValue, int steps) const {
if (steps == 1) {
if (normalizedValue > 0) {
normalizedValue = 1.;
}
} else {
ParameterValue oneStep = (number)1. / (steps - 1);
ParameterValue numberOfSteps = rnbo_fround(normalizedValue / oneStep * 1 / (number)1) * (number)1;
normalizedValue = numberOfSteps * oneStep;
}
return normalizedValue;
}
ParameterValue convertToNormalizedParameterValue(ParameterIndex index, ParameterValue value) const {
switch (index) {
case 0:
{
{
value = (value < 50 ? 50 : (value > 2000 ? 2000 : value));
ParameterValue normalizedValue = (value - 50) / (2000 - 50);
return normalizedValue;
}
}
default:
{
return value;
}
}
}
ParameterValue convertFromNormalizedParameterValue(ParameterIndex index, ParameterValue value) const {
value = (value < 0 ? 0 : (value > 1 ? 1 : value));
switch (index) {
case 0:
{
{
value = (value < 0 ? 0 : (value > 1 ? 1 : value));
{
return 50 + value * (2000 - 50);
}
}
}
default:
{
return value;
}
}
}
ParameterValue constrainParameterValue(ParameterIndex index, ParameterValue value) const {
switch (index) {
default:
{
return value;
}
}
}
void scheduleParamInit(ParameterIndex index, Index order) {
this->paramInitIndices->push(index);
this->paramInitOrder->push(order);
}
void processParamInitEvents() {
this->listquicksort(
this->paramInitOrder,
this->paramInitIndices,
0,
(int)(this->paramInitOrder->length - 1),
true
);
for (Index i = 0; i < this->paramInitOrder->length; i++) {
this->getEngine()->scheduleParameterChange(
this->paramInitIndices[i],
this->getParameterValue(this->paramInitIndices[i]),
0
);
}
}
void processClockEvent(MillisecondTime time, ClockId index, bool hasValue, ParameterValue value) {
RNBO_UNUSED(value);
RNBO_UNUSED(hasValue);
this->updateTime(time);
switch (index) {
case -871642103:
{
this->loadbang_01_startupbang_bang();
break;
}
}
}
void processOutletAtCurrentTime(EngineLink* , OutletIndex , ParameterValue ) {}
void processOutletEvent(
EngineLink* sender,
OutletIndex index,
ParameterValue value,
MillisecondTime time
) {
this->updateTime(time);
this->processOutletAtCurrentTime(sender, index, value);
}
void processNumMessage(MessageTag , MessageTag , MillisecondTime , number ) {}
void processListMessage(MessageTag , MessageTag , MillisecondTime , const list& ) {}
void processBangMessage(MessageTag tag, MessageTag objectId, MillisecondTime time) {
this->updateTime(time);
switch (tag) {
case TAG("bangin"):
{
if (TAG("button_obj-10") == objectId)
this->button_01_bangin_bang();
break;
}
case TAG("startupbang"):
{
if (TAG("loadbang_obj-5") == objectId)
this->loadbang_01_startupbang_bang();
break;
}
}
}
MessageTagInfo resolveTag(MessageTag tag) const {
switch (tag) {
case TAG("bangout"):
{
return "bangout";
}
case TAG("button_obj-10"):
{
return "button_obj-10";
}
case TAG("bangin"):
{
return "bangin";
}
case TAG("startupbang"):
{
return "startupbang";
}
case TAG("loadbang_obj-5"):
{
return "loadbang_obj-5";
}
}
return "";
}
MessageIndex getNumMessages() const {
return 0;
}
const MessageInfo& getMessageInfo(MessageIndex index) const {
switch (index) {
}
return NullMessageInfo;
}
protected:
void paramtilde_01_value_set(number v) {
this->paramtilde_01_value_setter(v);
v = this->paramtilde_01_value;
this->sendParameter(0, false);
SampleIndex k = (SampleIndex)(this->sampleOffsetIntoNextAudioBuffer);
if ((bool)(this->paramtilde_01_sigbuf)) {
for (SampleIndex i = (SampleIndex)(this->paramtilde_01_lastIndex); i < k; i++) {
this->paramtilde_01_sigbuf[(Index)i] = v;
this->paramtilde_01_lastIndex = k;
}
}
}
void button_01_bangin_bang() {
this->button_01_bangval_bang();
}
void loadbang_01_startupbang_bang() {
this->loadbang_01_output_bang();
}
number msToSamps(MillisecondTime ms, number sampleRate) {
return ms * sampleRate * 0.001;
}
MillisecondTime sampsToMs(SampleIndex samps) {
return samps * (this->invsr * 1000);
}
Index getMaxBlockSize() const {
return this->maxvs;
}
number getSampleRate() const {
return this->sr;
}
bool hasFixedVectorSize() const {
return false;
}
Index getNumInputChannels() const {
return 0;
}
Index getNumOutputChannels() const {
return 2;
}
void allocateDataRefs() {
this->data_01_buffer->requestSize(this->mstosamps(100), 1);
this->data_01_buffer->setSampleRate(this->sr);
this->groove_01_buffer = this->groove_01_buffer->allocateIfNeeded();
this->data_01_buffer = this->data_01_buffer->allocateIfNeeded();
if (this->test->hasRequestedSize()) {
if (this->test->wantsFill())
this->filltest(this->test);
this->getEngine()->sendDataRefUpdated(0);
}
}
void initializeObjects() {
this->gen_01_phase_init();
this->data_01_init();
}
void sendOutlet(OutletIndex index, ParameterValue value) {
this->getEngine()->sendOutlet(this, index, value);
}
void startup() {
this->updateTime(this->getEngine()->getCurrentTime());
this->getEngine()->scheduleClockEvent(this, -871642103, 0 + this->_currentTime);;
this->processParamInitEvents();
}
void groove_01_rate_bang_bang() {
this->groove_01_changeIncomingInSamples = this->sampleOffsetIntoNextAudioBuffer + 1;
this->groove_01_incomingChange = 1;
}
void button_01_output_bang() {
this->groove_01_rate_bang_bang();
}
void button_01_bangval_bang() {
this->getEngine()->sendBangMessage(TAG("bangout"), TAG("button_obj-10"), this->_currentTime);;
this->button_01_output_bang();
}
void loadbang_01_output_bang() {
this->groove_01_rate_bang_bang();
}
void midiout_01_midiin_set(number v) {
int vi = (int)(v);
if (vi == 0xF6 || (vi >= MIDI_Clock && vi <= MIDI_Reset && vi != 0xF9 && vi != 0xFD)) {
this->getEngine()->sendMidiEvent(this->midiout_01_port, vi, 0, 0, this->_currentTime);
return;
}
this->midiout_01_currentStatus = parseMidi(this->midiout_01_currentStatus, vi, this->midiout_01_status);
bool clearSysex = true;
switch ((int)this->midiout_01_currentStatus) {
case MIDI_StatusByteReceived:
{
this->midiout_01_status = v;
this->midiout_01_byte1 = -1;
break;
}
case MIDI_SecondByteReceived:
{
this->midiout_01_byte1 = v;
break;
}
case MIDI_ProgramChange:
case MIDI_ChannelPressure:
case MIDI_QuarterFrame:
case MIDI_SongSel:
{
this->midiout_01_byte1 = v;
this->getEngine()->sendMidiEvent(
this->midiout_01_port,
this->midiout_01_status,
this->midiout_01_byte1,
0,
this->_currentTime
);
break;
}
case MIDI_NoteOff:
case MIDI_NoteOn:
case MIDI_Aftertouch:
case MIDI_CC:
case MIDI_PitchBend:
case MIDI_SongPos:
case MIDI_Generic:
{
this->getEngine()->sendMidiEvent(
this->midiout_01_port,
this->midiout_01_status,
this->midiout_01_byte1,
v,
this->_currentTime
);
break;
}
case MIDI_Sysex_Started:
{
this->midiout_01_sysex->push(vi);
clearSysex = false;
break;
}
case MIDI_Sysex_Complete:
{
this->midiout_01_sysex->push(vi);
this->getEngine()->sendMidiEventList(this->midiout_01_port, this->midiout_01_sysex, this->_currentTime);
break;
}
case MIDI_InvalidByte:
{
break;
}
default:
{
break;
}
}
if ((bool)(clearSysex) && this->midiout_01_sysex->length > 0) {
this->midiout_01_sysex = {};
}
}
void midiin_01_midiout_set(number v) {
this->midiout_01_midiin_set(v);
}
void midiin_01_midihandler(int status, int channel, int port, ConstByteArray data, Index length) {
RNBO_UNUSED(port);
RNBO_UNUSED(channel);
RNBO_UNUSED(status);
Index i;
for (i = 0; i < length; i++) {
this->midiin_01_midiout_set(data[i]);
}
}
void paramtilde_01_perform(const SampleValue * freq, SampleValue * out, Index n) {
auto __paramtilde_01_value = this->paramtilde_01_value;
auto __paramtilde_01_lastIndex = this->paramtilde_01_lastIndex;
for (Index i = 0; i < n; i++) {
if (i >= __paramtilde_01_lastIndex) {
out[(Index)i] = freq[(Index)i] + __paramtilde_01_value;
} else {
out[(Index)i] = freq[(Index)i] + this->paramtilde_01_sigbuf[(Index)i];
}
}
__paramtilde_01_lastIndex = 0;
this->paramtilde_01_lastIndex = __paramtilde_01_lastIndex;
}
void gen_01_perform(const Sample * in1, SampleValue * out1, Index n) {
auto __gen_01_phase_value = this->gen_01_phase_value;
Index i;
for (i = 0; i < n; i++) {
auto wrap_1_0 = this->wrap(__gen_01_phase_value, 0, 1);
out1[(Index)i] = wrap_1_0;
number div_2_1 = (this->samplerate() == 0. ? 0. : in1[(Index)i] / this->samplerate());
number add_3_2 = wrap_1_0 + div_2_1;
number phase_next_4_3 = fixdenorm(add_3_2);
__gen_01_phase_value = phase_next_4_3;
}
this->gen_01_phase_value = __gen_01_phase_value;
}
void groove_01_perform(
number rate_auto,
number begin,
number end,
SampleValue * out1,
SampleValue * sync,
Index n
) {
RNBO_UNUSED(out1);
RNBO_UNUSED(end);
RNBO_UNUSED(begin);
RNBO_UNUSED(rate_auto);
auto __groove_01_crossfade = this->groove_01_crossfade;
auto __groove_01_loop = this->groove_01_loop;
auto __groove_01_playStatus = this->groove_01_playStatus;
auto __groove_01_readIndex = this->groove_01_readIndex;
auto __groove_01_incomingChange = this->groove_01_incomingChange;
auto __groove_01_changeIncomingInSamples = this->groove_01_changeIncomingInSamples;
auto __groove_01_buffer = this->groove_01_buffer;
SampleArray<1> out = {out1};
SampleIndex bufferLength = (SampleIndex)(__groove_01_buffer->getSize());
Index i = 0;
if (bufferLength > 1) {
auto effectiveChannels = this->minimum(__groove_01_buffer->getChannels(), 1);
number srMult = 0.001 * __groove_01_buffer->getSampleRate();
number srInv = (number)1 / this->samplerate();
number rateMult = __groove_01_buffer->getSampleRate() * srInv;
for (; i < n; i++) {
Index channel = 0;
number offset = 0;
number loopMin = 0 * srMult;
loopMin = (loopMin > bufferLength - 1 ? bufferLength - 1 : (loopMin < 0 ? 0 : loopMin));
number loopMax = bufferLength;
loopMax = (loopMax > bufferLength ? bufferLength : (loopMax < 0 ? 0 : loopMax));
if (loopMin >= loopMax) {
offset = loopMax;
loopMax = bufferLength;
loopMin -= offset;
}
number loopLength = loopMax - loopMin;
number currentRate = 1 * rateMult;
number currentSync = 0;