owl_patch 0.8.0

Rust SDK for Rebel Technology Owl2/3 devices
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
//      _____ _____ _____ __
//     |   __|     |  |  |  |        Auto-generated C++
//     |__   |  |  |  |  |  |__      SOUL Version 0.9.0
//     |_____|_____|_____|_____|     https://soul.dev
//

#include <array>
#include <functional>
#include <cmath>
#include <cstddef>
#include <limits>
#include <cstring>

#ifndef SOUL_CPP_ASSERT
 #define SOUL_CPP_ASSERT(x)
#endif

// If you need to provide custom implementations of the instrinsics that soul uses,
// you can set this macro to provide your own namespace containing them.
#ifndef SOUL_INTRINSICS
 #define SOUL_INTRINSICS std
#endif

//==============================================================================
// Generated from graph 'SineSynth', source file: SineSynth.soul
//
class SineSynth
{
public:
    SineSynth() = default;
    ~SineSynth() = default;

    //==============================================================================
    template <typename Type, int32_t size> struct Vector;
    template <typename Type, int32_t size> struct FixedArray;
    template <typename Type> struct DynamicArray;

    static constexpr uint32_t maxBlockSize  = 1024;
    static constexpr uint32_t latency       = 0;

    template <typename Item>
    struct span
    {
        Item* start = nullptr;
        size_t numItems = 0;

        constexpr size_t size() const               { return numItems; }
        constexpr bool empty() const                { return numItems == 0; }
        constexpr Item* begin() const               { return start; }
        constexpr Item* end() const                 { return start + numItems; }
        const Item& operator[] (size_t index) const { SOUL_CPP_ASSERT (index < numItems); return start[index]; }
    };

    struct _RenderStats;
    struct _SparseStreamStatus;
    struct _Event_in_f32_1;
    struct _Event_in_struct_Message_1;
    struct _Stream_out_f32_1024;
    struct soul__midi__MPEParser___State;
    struct soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator__VoiceInfo;
    struct soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State;
    struct SineOsc___State;
    struct soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___State;
    struct soul__gain__DynamicGain___for__root__Voice_attenuator___State;
    struct Voice___State;
    struct soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___State;
    struct soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___State;
    struct _State;
    struct soul__midi__Message;
    struct soul__note_events__NoteOn;
    struct soul__note_events__NoteOff;
    struct soul__note_events__PitchBend;
    struct soul__note_events__Pressure;
    struct soul__note_events__Slide;
    struct soul__note_events__Control;
    struct soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___IO;
    struct soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___IO;
    struct soul__gain__DynamicGain___for__root__Voice_attenuator___IO;
    struct soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___IO;
    struct SineOsc___IO;
    struct Voice___IO;
    struct StringLiteral;

    //==============================================================================
    // The following methods provide basic initialisation and control for the processor

    void init (double newSampleRate, int sessionID)
    {
        memset (reinterpret_cast<void*> (std::addressof (state)), 0, sizeof (state));
        sampleRate = newSampleRate;
        _initialise (state, sessionID);
        initialisedState = state;
    }

    void reset() noexcept
    {
        state = initialisedState;
    }

    uint32_t getNumXRuns() noexcept
    {
        return static_cast<uint32_t> (_get_num_xruns (state));
    }

    //==============================================================================
    // These classes and functions provide a high-level rendering method that
    // presents the processor as a set of standard audio and MIDI channels.

    static constexpr uint32_t numAudioInputChannels  = 0;
    static constexpr uint32_t numAudioOutputChannels = 1;

    struct MIDIMessage
    {
        uint32_t frameIndex = 0;
        uint8_t byte0 = 0, byte1 = 0, byte2 = 0;
    };

    struct MIDIMessageArray
    {
        const MIDIMessage* messages = nullptr;
        uint32_t numMessages = 0;
    };

    template <typename FloatType = float>
    struct RenderContext
    {
        std::array<const FloatType*, 0> inputChannels;
        std::array<FloatType*, 1> outputChannels;
        MIDIMessageArray  incomingMIDI;
        uint32_t          numFrames = 0;
    };

    //==============================================================================
    template <typename FloatType>
    void render (RenderContext<FloatType> context)
    {
        uint32_t startFrame = 0, startMIDIIndex = 0;

        while (startFrame < context.numFrames)
        {
            auto framesRemaining = context.numFrames - startFrame;
            auto numFramesToDo = framesRemaining < maxBlockSize ? framesRemaining : maxBlockSize;
            auto endMIDIIndex = startMIDIIndex;

            while (endMIDIIndex < context.incomingMIDI.numMessages)
            {
                auto eventTime = context.incomingMIDI.messages[endMIDIIndex].frameIndex;

                if (eventTime > startFrame)
                {
                    auto framesUntilEvent = eventTime - startFrame;

                    if (framesUntilEvent < numFramesToDo)
                        numFramesToDo = framesUntilEvent;

                    break;
                }

                ++endMIDIIndex;
            }

            prepare (numFramesToDo);

            while (startMIDIIndex < endMIDIIndex)
            {
                auto midi = context.incomingMIDI.messages[startMIDIIndex++];
                auto packed = (static_cast<uint32_t> (midi.byte0) << 16) | (static_cast<uint32_t> (midi.byte1) << 8) | static_cast<uint32_t> (midi.byte2);
                _addInputEvent_midiIn_struct_Message (state, { static_cast<int32_t> (packed) });
            }

            advance();

            copyFromInterleaved (&context.outputChannels[0], startFrame, _getOutputFrameArrayRef_audioOut (state).elements, numFramesToDo);
            startFrame += numFramesToDo;
        }
    }

    //==============================================================================
    // The following methods provide low-level access for read/write to all the
    // endpoints directly, and to run the prepare/advance loop.

    void prepare (uint32_t numFramesToBeRendered)
    {
        SOUL_CPP_ASSERT (numFramesToBeRendered != 0);
        framesToAdvance = numFramesToBeRendered;
        _prepare (state, static_cast<int32_t> (numFramesToBeRendered));
    }

    void advance()
    {
        SOUL_CPP_ASSERT (framesToAdvance != 0); // you must call prepare() before advance()!
        auto framesRemaining = framesToAdvance;

        while (framesRemaining > 0)
        {
            auto framesThisCall = framesRemaining < maxBlockSize ? framesRemaining : maxBlockSize;

            run (state, static_cast<int32_t> (framesThisCall));

            totalFramesElapsed += framesThisCall;
            framesRemaining -= framesThisCall;
        }
    }

    void addInputEvent_volume (float eventValue)
    {
        _addInputEvent_volume_f32 (state, eventValue);
    }

    void addInputEvent_midiIn (const soul__midi__Message& eventValue)
    {
        _addInputEvent_midiIn_struct_Message (state, eventValue);
    }

    DynamicArray<const float> getOutputStreamFrames_audioOut()
    {
        return { &(_getOutputFrameArrayRef_audioOut (state).elements[0]), static_cast<int32_t> (framesToAdvance) };
    }

    //==============================================================================
    // The following methods provide a fixed interface for finding out about
    // the input/output endpoints that this processor provides.

    using EndpointID = const char*;
    enum class EndpointType     { value, stream, event };

    struct EndpointDetails
    {
        const char* name;
        EndpointID endpointID;
        EndpointType endpointType;
        const char* frameType;
        uint32_t numAudioChannels;
        const char* annotation;
    };

    std::array<EndpointDetails, 2> getInputEndpoints() const
    {
        return
        {
            EndpointDetails { "volume", "in:volume", EndpointType::event, "float32",                     0, "{ \"name\": \"Volume\", \"min\": -40, \"max\": 0, \"init\": -6, \"step\": 1, \"unit\": \"dB\" }" },
            EndpointDetails { "midiIn", "in:midiIn", EndpointType::event, "Message { int32 midiBytes }", 0, ""                                                                                                }
        };
    }

    std::array<EndpointDetails, 1> getOutputEndpoints() const
    {
        return
        {
            EndpointDetails { "audioOut", "out:audioOut", EndpointType::stream, "float32", 1, "" }
        };
    }

    //==============================================================================
    // The following methods provide help in dealing with the processor's endpoints
    // in a format suitable for traditional audio plugin channels and parameters.

    struct ParameterProperties
    {
        const char* UID;
        const char* name;
        const char* unit;
        float minValue, maxValue, step, initialValue;
        bool isAutomatable, isBoolean, isHidden;
        const char* group;
        const char* textValues;
    };

    struct Parameter
    {
        ParameterProperties properties;
        float currentValue;
        std::function<void(float)> applyValue;

        void setValue (float f)
        {
            currentValue = snapToLegalValue (f);
            applyValue (f);
        }

        float getValue() const
        {
            return currentValue;
        }

    private:
        float snapToLegalValue (float v) const
        {
            if (properties.step > 0)
                v = properties.minValue + properties.step * SOUL_INTRINSICS::floor ((v - properties.minValue) / properties.step + 0.5f);

            return v < properties.minValue ? properties.minValue : (v > properties.maxValue ? properties.maxValue : v);
        }
    };

    struct AudioBus
    {
        const char* name;
        uint32_t numChannels;
    };

    static constexpr bool      hasMIDIInput = true;
    static constexpr uint32_t  numParameters = 1;

    static constexpr const std::array<const ParameterProperties, numParameters> parameters =
    {
        ParameterProperties {  "volume",  "Volume",  "dB",  -40.0f,  0.0f,  1.0f,  -6.0f,  true,  false,  false,  "",  ""  }
    };

    static span<const ParameterProperties> getParameterProperties() { return { parameters.data(), numParameters }; }

    static constexpr uint32_t numInputBuses  = 0;
    static constexpr uint32_t numOutputBuses = 1;

    static constexpr std::array<const AudioBus, numOutputBuses> outputBuses = { AudioBus { "audioOut", 1 } };

    static span<const AudioBus> getInputBuses()  { return {}; }
    static span<const AudioBus> getOutputBuses() { return { outputBuses.data(), numOutputBuses }; }

    struct ParameterList
    {
        Parameter* begin()                      { return params; }
        Parameter* end()                        { return params + numParameters; }
        size_t size() const                     { return numParameters; }
        Parameter& operator[] (size_t index)    { SOUL_CPP_ASSERT (index < numParameters); return params[index]; }

        Parameter params[numParameters == 0 ? 1 : numParameters];
    };

    ParameterList createParameterList()
    {
        return
        {
            {
                Parameter {  parameters[0],  -6.0f,  [this] (float v) { addInputEvent_volume (v); }  }
            }
        };
    }

    static constexpr bool hasTimelineEndpoints = false;

    void setTimeSignature (int32_t newNumerator, int32_t newDenominator)
    {
        (void) newNumerator; (void) newDenominator;
    }

    void setTempo (float newBPM)
    {
        (void) newBPM;
    }

    void setTransportState (int32_t newState)
    {
        (void) newState;
    }

    void setPosition (int64_t currentFrame, double currentQuarterNote, double lastBarStartQuarterNote)
    {
        (void) currentFrame; (void) currentQuarterNote; (void) lastBarStartQuarterNote;
    }

    //==============================================================================
    struct ZeroInitialiser
    {
        template <typename Type>   operator Type() const   { return {}; }
        template <typename Index>  ZeroInitialiser operator[] (Index) const { return {}; }
    };

    //==============================================================================
    template <typename Type>
    struct DynamicArray
    {
        using ElementType = Type;
        ElementType* elements = nullptr;
        int32_t numElements = 0;

        constexpr ElementType& operator[] (int i) noexcept                   { return elements[i]; }
        constexpr const ElementType& operator[] (int i) const noexcept       { return elements[i]; }
        constexpr int getElementSizeBytes() const noexcept                   { return sizeof (ElementType); }
    };

    //==============================================================================
    template <typename Type, int32_t size>
    struct FixedArray
    {
        using ElementType = Type;
        ElementType elements[size];
        static constexpr int32_t numElements = size;

        static constexpr FixedArray fromRepeatedValue (ElementType value)
        {
            FixedArray a;

            for (auto& element : a.elements)
                element = value;

            return a;
        }

        static size_t elementOffset (int i) noexcept               { return sizeof (ElementType) * i; }
        ElementType& operator[] (int i) noexcept                   { return elements[i]; }
        const ElementType& operator[] (int i) const noexcept       { return elements[i]; }
        int getElementSizeBytes() const noexcept                   { return sizeof (ElementType); }
        DynamicArray<ElementType> toDynamicArray() const noexcept  { return { const_cast<ElementType*> (&elements[0]), size }; }
        operator ElementType*() const noexcept                     { return const_cast<ElementType*> (&elements[0]); }

        FixedArray& operator= (ZeroInitialiser)
        {
            for (auto& e : elements)
                e = ElementType {};

            return *this;
        }

        template <int start, int end>
        constexpr FixedArray<Type, end - start> slice() const noexcept
        {
            FixedArray<Type, end - start> newSlice;

            for (int i = 0; i < end - start; ++i)
                newSlice.elements[i] = elements[start + i];

            return newSlice;
        }
    };

    //==============================================================================
    template <typename Type, int32_t size>
    struct Vector
    {
        using ElementType = Type;
        ElementType elements[size] = {};
        static constexpr int32_t numElements = size;

        constexpr Vector() = default;
        constexpr Vector (const Vector&) = default;
        constexpr Vector& operator= (const Vector&) = default;

        explicit constexpr Vector (Type value)
        {
            for (auto& element : elements)
                element = value;
        }

        template <typename OtherType>
        constexpr Vector (const Vector<OtherType, size>& other)
        {
            for (int32_t i = 0; i < size; ++i)
                elements[i] = static_cast<Type> (other.elements[i]);
        }

        constexpr Vector (std::initializer_list<Type> i)
        {
            int n = 0;

            for (auto e : i)
                elements[n++] = e;
        }

        static constexpr Vector fromRepeatedValue (Type value)
        {
            return Vector (value);
        }

        constexpr Vector operator+ (const Vector& rhs) const                { return apply<Vector> (rhs, [] (Type a, Type b) { return a + b; }); }
        constexpr Vector operator- (const Vector& rhs) const                { return apply<Vector> (rhs, [] (Type a, Type b) { return a - b; }); }
        constexpr Vector operator* (const Vector& rhs) const                { return apply<Vector> (rhs, [] (Type a, Type b) { return a * b; }); }
        constexpr Vector operator/ (const Vector& rhs) const                { return apply<Vector> (rhs, [] (Type a, Type b) { return a / b; }); }
        constexpr Vector operator% (const Vector& rhs) const                { return apply<Vector> (rhs, [] (Type a, Type b) { return a % b; }); }
        constexpr Vector operator-() const                                  { return apply<Vector> ([] (Type n) { return -n; }); }
        constexpr Vector operator~() const                                  { return apply<Vector> ([] (Type n) { return ~n; }); }
        constexpr Vector operator!() const                                  { return apply<Vector> ([] (Type n) { return ! n; }); }

        Vector& operator= (ZeroInitialiser)
        {
            for (auto& e : elements)
                e = {};

            return *this;
        }

        constexpr Vector<bool, size> operator== (const Vector& rhs) const   { return apply<Vector<bool, size>> (rhs, [] (Type a, Type b) { return a == b; }); }
        constexpr Vector<bool, size> operator!= (const Vector& rhs) const   { return apply<Vector<bool, size>> (rhs, [] (Type a, Type b) { return a != b; }); }

        template <typename ReturnType, typename Op>
        constexpr ReturnType apply (const Vector& rhs, Op&& op) const noexcept
        {
            ReturnType v;

            for (int i = 0; i < size; ++i)
                v.elements[i] = op (elements[i], rhs.elements[i]);

            return v;
        }

        template <typename ReturnType, typename Op>
        constexpr ReturnType apply (Op&& op) const noexcept
        {
            ReturnType v;

            for (int i = 0; i < size; ++i)
                v.elements[i] = op (elements[i]);

            return v;
        }

        template <int start, int end>
        constexpr Vector<Type, end - start> slice() const noexcept
        {
            Vector<Type, end - start> newSlice;

            for (int i = 0; i < end - start; ++i)
                newSlice.elements[i] = elements[start + i];

            return newSlice;
        }

        constexpr const Type& operator[] (int i) const noexcept  { return elements[i]; }
        constexpr Type& operator[] (int i) noexcept              { return elements[i]; }
    };

    //==============================================================================
    struct StringLiteral
    {
        constexpr StringLiteral (int32_t h) noexcept : handle (h) {}
        StringLiteral() = default;
        StringLiteral (const StringLiteral&) = default;
        StringLiteral& operator= (const StringLiteral&) = default;

        const char* toString() const       { return lookupStringLiteral (handle); }
        operator const char*() const       { return lookupStringLiteral (handle); }

        bool operator== (StringLiteral other) const noexcept    { return handle == other.handle; }
        bool operator!= (StringLiteral other) const noexcept    { return handle != other.handle; }

        int32_t handle = 0;
    };


    //==============================================================================
    //==============================================================================
    //
    //    All the code that follows this point should be considered internal.
    //    User code should rarely need to refer to anything beyond this point..
    //
    //==============================================================================
    //==============================================================================

    template <typename Vec>  static Vec _vec_sqrt  (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::sqrt (x); }); }
    template <typename Vec>  static Vec _vec_pow   (Vec a, Vec b)  { return a.template apply<Vec> ([&] (typename Vec::ElementType x) { return SOUL_INTRINSICS::pow (x, b); }); }
    template <typename Vec>  static Vec _vec_exp   (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::exp (x); }); }
    template <typename Vec>  static Vec _vec_log   (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::log (x); }); }
    template <typename Vec>  static Vec _vec_log10 (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::log10 (x); }); }
    template <typename Vec>  static Vec _vec_sin   (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::sin (x); }); }
    template <typename Vec>  static Vec _vec_cos   (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::cos (x); }); }
    template <typename Vec>  static Vec _vec_tan   (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::tan (x); }); }
    template <typename Vec>  static Vec _vec_sinh  (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::sinh (x); }); }
    template <typename Vec>  static Vec _vec_cosh  (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::cosh (x); }); }
    template <typename Vec>  static Vec _vec_tanh  (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::tanh (x); }); }
    template <typename Vec>  static Vec _vec_asinh (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::asinh (x); }); }
    template <typename Vec>  static Vec _vec_acosh (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::acosh (x); }); }
    template <typename Vec>  static Vec _vec_atanh (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::atanh (x); }); }
    template <typename Vec>  static Vec _vec_asin  (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::asin (x); }); }
    template <typename Vec>  static Vec _vec_acos  (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::acos (x); }); }
    template <typename Vec>  static Vec _vec_atan  (Vec a)         { return a.template apply<Vec> ([]  (typename Vec::ElementType x) { return SOUL_INTRINSICS::atan (x); }); }
    template <typename Vec>  static Vec _vec_atan2 (Vec a, Vec b)  { return a.template apply<Vec> ([&] (typename Vec::ElementType x) { return SOUL_INTRINSICS::atan2 (x, b); }); }

    static constexpr int32_t _intrin_clamp (int32_t n, int32_t low, int32_t high)  { return n < low ? low : (n > high ? high : n); }
    static constexpr int32_t _intrin_wrap (int32_t n, int32_t range)   { if (range == 0) return 0; auto x = n % range; return x < 0 ? x + range : x; }

    static constexpr float  _nan32 = std::numeric_limits<float>::quiet_NaN();
    static constexpr double _nan64 = std::numeric_limits<double>::quiet_NaN();

    static constexpr float  _inf32 = std::numeric_limits<float>::infinity();
    static constexpr double _inf64 = std::numeric_limits<double>::infinity();

    static constexpr float  _ninf32 = -_inf32;
    static constexpr double _ninf64 = -_inf64;

    template <typename SourceFloatType, typename DestFloatType>
    static inline void copyToInterleaved (DestFloatType* monoDest, const SourceFloatType* const* sourceChannels, uint32_t sourceStartFrame, uint32_t numFrames)
    {
        auto source = *sourceChannels + sourceStartFrame;

        for (uint32_t i = 0; i < numFrames; ++i)
            monoDest[i] = static_cast<DestFloatType> (source[i]);
    }

    template <typename SourceFloatType, typename DestFloatType, int32_t numChannels>
    static inline void copyToInterleaved (Vector<DestFloatType, numChannels>* vectorDest, const SourceFloatType* const* sourceChannels, uint32_t sourceStartFrame, uint32_t numFrames)
    {
        for (uint32_t i = 0; i < numFrames; ++i)
            for (uint32_t chan = 0; chan < static_cast<uint32_t> (numChannels); ++chan)
                vectorDest[i].elements[chan] = static_cast<DestFloatType> (sourceChannels[chan][sourceStartFrame + i]);
    }

    template <typename SourceFloatType, typename DestFloatType>
    static inline void copyFromInterleaved (DestFloatType* const* destChannels, uint32_t destStartFrame, const SourceFloatType* monoSource, uint32_t numFrames)
    {
        auto dest = *destChannels + destStartFrame;

        for (uint32_t i = 0; i < numFrames; ++i)
            dest[i] = static_cast<DestFloatType> (monoSource[i]);
    }

    template <typename SourceFloatType, typename DestFloatType, int32_t numChannels>
    static inline void copyFromInterleaved (DestFloatType* const* destChannels, uint32_t destStartFrame, const Vector<SourceFloatType, numChannels>* vectorSource, uint32_t numFrames)
    {
        for (uint32_t i = 0; i < numFrames; ++i)
            for (uint32_t chan = 0; chan < static_cast<uint32_t> (numChannels); ++chan)
                destChannels[chan][destStartFrame + i] = static_cast<DestFloatType> (vectorSource[i].elements[chan]);
    }

    //==============================================================================
    struct _RenderStats
    {
        int32_t m_underrunCount, m_underrunFrames, m_overrunCount, m_overrunFrames;
    };

    struct _SparseStreamStatus
    {
        int32_t m_activeRamps;
        FixedArray<int32_t, 2> m_rampArray;
    };

    struct _Event_in_f32_1
    {
        int32_t m_numFrames;
    };

    struct _Event_in_struct_Message_1
    {
        int32_t m_numFrames;
    };

    struct _Stream_out_f32_1024
    {
        FixedArray<float, 1024> m_buffer;
    };

    struct soul__midi__MPEParser___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId;
    };

    struct soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator__VoiceInfo
    {
        bool m_active;
        int32_t m_channel;
        float m_note;
        int32_t m_voiceAge;
        bool m_noteReleased;
    };

    struct soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId, m_nextAllocatedVoiceAge, m_nextUnallocatedVoiceAge;
        FixedArray<soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator__VoiceInfo, 8> m_voiceInfo;
        FixedArray<bool, 16> m_channelSustainActive;
        bool m_masterSustainActive;
    };

    struct SineOsc___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId;
        float m_notePitch, m_bendSemitones, m_phase, m_phaseIncrement;
    };

    struct soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId;
        bool m_active;
        float m_targetLevel, m_attackLevel, m_attackMultiplier, m_level, m_releaseMultiplier;
    };

    struct soul__gain__DynamicGain___for__root__Voice_attenuator___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId;
    };

    struct Voice___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId;
        SineOsc___State m_osc_state;
        soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___State m_amplitudeEnvelope_state;
        soul__gain__DynamicGain___for__root__Voice_attenuator___State m_attenuator_state;
    };

    struct soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId;
    };

    struct soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId;
        float m_targetGain, m_currentGain, m_increment;
        int32_t m_remainingRampSamples;
    };

    struct _State
    {
        int32_t m__resumePoint, m__frameCount, m__arrayEntry, m__sessionID, m__processorId, m__framesToAdvance;
        _RenderStats m__renderStats;
        _SparseStreamStatus m__sparseStreamStatus;
        _Event_in_f32_1 m__in_volume;
        _Event_in_struct_Message_1 m__in_midiIn;
        _Stream_out_f32_1024 m__out_audioOut;
        soul__midi__MPEParser___State m_MPEParser_state;
        soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State m_voiceAllocator_state;
        FixedArray<Voice___State, 8> m_voices_state;
        soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___State m_gainProcessor_state;
        soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___State m_smoothedGain_state;
    };

    struct soul__midi__Message
    {
        int32_t m_midiBytes;
    };

    struct soul__note_events__NoteOn
    {
        int32_t m_channel;
        float m_note, m_velocity;
    };

    struct soul__note_events__NoteOff
    {
        int32_t m_channel;
        float m_note, m_velocity;
    };

    struct soul__note_events__PitchBend
    {
        int32_t m_channel;
        float m_bendSemitones;
    };

    struct soul__note_events__Pressure
    {
        int32_t m_channel;
        float m_pressure;
    };

    struct soul__note_events__Slide
    {
        int32_t m_channel;
        float m_slide;
    };

    struct soul__note_events__Control
    {
        int32_t m_channel, m_control;
        float m_value;
    };

    struct soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___IO
    {
        float m__out_gain;
    };

    struct soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___IO
    {
        float m__in_in, m__in_gain, m__out_out;
    };

    struct soul__gain__DynamicGain___for__root__Voice_attenuator___IO
    {
        float m__in_in, m__in_gain, m__out_out;
    };

    struct soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___IO
    {
        float m__out_levelOut;
    };

    struct SineOsc___IO
    {
        float m__out_audioOut;
    };

    struct Voice___IO
    {
        float m__out_audioOut;
    };

    //==============================================================================
    #if __clang__
     #pragma clang diagnostic push
     #pragma clang diagnostic ignored "-Wunused-label"
     #pragma clang diagnostic ignored "-Wunused-parameter"
     #pragma clang diagnostic ignored "-Wshadow"
    #elif defined(__GNUC__)
     #pragma GCC diagnostic push
     #pragma GCC diagnostic ignored "-Wunused-label"
     #pragma GCC diagnostic ignored "-Wunused-parameter"
     #pragma GCC diagnostic ignored "-Wshadow"
    #elif defined(_MSC_VER)
     #pragma warning (push)
     #pragma warning (disable: 4100 4102 4458)
    #endif

    //==============================================================================
    int32_t run (_State& _state, int32_t maxFrames) noexcept
    {
        int32_t _2 = {};
        FixedArray<Voice___IO, 8> _3 = {};
        soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___IO _4 = {};
        soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___IO _5 = {};

        _2 = _internal___minInt32 (1024, maxFrames);
        _updateRampingStreams (_state, _2);
        _state.m__frameCount = 0;
        _main_loop_check: { if (! (_state.m__frameCount < _2)) goto _exit; }
        _main_loop_body: { _3 = ZeroInitialiser();
                           Voice__run (_state.m_voices_state[0], _3[0]);
                           Voice__run (_state.m_voices_state[1], _3[1]);
                           Voice__run (_state.m_voices_state[2], _3[2]);
                           Voice__run (_state.m_voices_state[3], _3[3]);
                           Voice__run (_state.m_voices_state[4], _3[4]);
                           Voice__run (_state.m_voices_state[5], _3[5]);
                           Voice__run (_state.m_voices_state[6], _3[6]);
                           Voice__run (_state.m_voices_state[7], _3[7]);
                           _4 = ZeroInitialiser();
                           soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain__run (_state.m_smoothedGain_state, _4);
                           _5 = ZeroInitialiser();
                           _5.m__in_in = ((((((_3[0].m__out_audioOut + _3[1].m__out_audioOut) + _3[2].m__out_audioOut) + _3[3].m__out_audioOut) + _3[4].m__out_audioOut) + _3[5].m__out_audioOut) + _3[6].m__out_audioOut) + _3[7].m__out_audioOut;
                           _5.m__in_gain = _4.m__out_gain;
                           soul__gain__DynamicGain___for__root__SineSynth_gainProcessor__run (_state.m_gainProcessor_state, _5);
                           _writeToStream_struct__Stream_out_f32_1024 (_state.m__out_audioOut, _state.m__frameCount, _5.m__out_out);
                           _state.m__frameCount = _state.m__frameCount + 1;
                           goto _main_loop_check;
        }
        _exit: { _state.m__frameCount = 0;
                 return _2;
        }
    }

    void _initialise (_State& _state, int32_t sessionID) noexcept
    {
        _state.m__sessionID = sessionID;
        _state.m_MPEParser_state.m__arrayEntry = 0;
        _state.m_MPEParser_state.m__sessionID = _state.m__sessionID;
        _state.m_MPEParser_state.m__processorId = 4;
        _state.m_voiceAllocator_state.m__arrayEntry = 0;
        _state.m_voiceAllocator_state.m__sessionID = _state.m__sessionID;
        _state.m_voiceAllocator_state.m__processorId = 5;
        soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___initialise (_state.m_voiceAllocator_state);
        _state.m_voices_state[0].m__arrayEntry = 0;
        _state.m_voices_state[0].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[0].m__processorId = 6;
        Voice___initialise (_state.m_voices_state[0]);
        _state.m_voices_state[1].m__arrayEntry = 1;
        _state.m_voices_state[1].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[1].m__processorId = 7;
        Voice___initialise (_state.m_voices_state[1]);
        _state.m_voices_state[2].m__arrayEntry = 2;
        _state.m_voices_state[2].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[2].m__processorId = 8;
        Voice___initialise (_state.m_voices_state[2]);
        _state.m_voices_state[3].m__arrayEntry = 3;
        _state.m_voices_state[3].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[3].m__processorId = 9;
        Voice___initialise (_state.m_voices_state[3]);
        _state.m_voices_state[4].m__arrayEntry = 4;
        _state.m_voices_state[4].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[4].m__processorId = 10;
        Voice___initialise (_state.m_voices_state[4]);
        _state.m_voices_state[5].m__arrayEntry = 5;
        _state.m_voices_state[5].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[5].m__processorId = 11;
        Voice___initialise (_state.m_voices_state[5]);
        _state.m_voices_state[6].m__arrayEntry = 6;
        _state.m_voices_state[6].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[6].m__processorId = 12;
        Voice___initialise (_state.m_voices_state[6]);
        _state.m_voices_state[7].m__arrayEntry = 7;
        _state.m_voices_state[7].m__sessionID = _state.m__sessionID;
        _state.m_voices_state[7].m__processorId = 13;
        Voice___initialise (_state.m_voices_state[7]);
        _state.m_gainProcessor_state.m__arrayEntry = 0;
        _state.m_gainProcessor_state.m__sessionID = _state.m__sessionID;
        _state.m_gainProcessor_state.m__processorId = 14;
        _state.m_smoothedGain_state.m__arrayEntry = 0;
        _state.m_smoothedGain_state.m__sessionID = _state.m__sessionID;
        _state.m_smoothedGain_state.m__processorId = 15;
        soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___initialise (_state.m_smoothedGain_state);
    }

    void _addInputEvent_volume_f32 (_State& _state, const float& event) noexcept
    {
        soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___volume_f32 (_state.m_smoothedGain_state, event);
    }

    void _addInputEvent_midiIn_struct_Message (_State& _state, const soul__midi__Message& event) noexcept
    {
        soul__midi__MPEParser___parseMIDI_struct_Message (_state.m_MPEParser_state, event);
    }

    FixedArray<float, 1024>& _getOutputFrameArrayRef_audioOut (_State& state) noexcept
    {
        return state.m__out_audioOut.m_buffer;
    }

    void _prepare (_State& state, int32_t frames) noexcept
    {
        state.m__framesToAdvance = frames;
    }

    int32_t _get_num_xruns (_State& state) noexcept
    {
        return state.m__renderStats.m_underrunCount + state.m__renderStats.m_overrunCount;
    }

    //==============================================================================
    bool _updateRampingStream (_State& _state, int32_t streamId, int32_t framesToRender) noexcept
    {
        bool rampComplete = {};

        rampComplete = false;
        return rampComplete;
    }

    void _updateRampingStreams (_State& _state, int32_t framesToRender) noexcept
    {
        bool rampComplete = {};
        int32_t readPos = {}, writePos = {};

        rampComplete = false;
        readPos = 0;
        writePos = 0;
        if (_state.m__sparseStreamStatus.m_activeRamps == 0) goto _exit;
        _loop: { rampComplete = _updateRampingStream (_state, _state.m__sparseStreamStatus.m_rampArray[readPos], framesToRender);
                 if (rampComplete) goto _rampComplete;
        }
        _rampActive: { _state.m__sparseStreamStatus.m_rampArray[writePos] = _state.m__sparseStreamStatus.m_rampArray[readPos];
                       readPos = readPos + 1;
                       writePos = writePos + 1;
                       if (readPos == _state.m__sparseStreamStatus.m_activeRamps) goto _loopExit;
                       goto _loop;
        }
        _rampComplete: { readPos = readPos + 1;
                         if (! (readPos == _state.m__sparseStreamStatus.m_activeRamps)) goto _loop;
        }
        _loopExit: { _state.m__sparseStreamStatus.m_activeRamps = writePos; }
        _exit: {}
    }

    void _writeToStream_struct__Stream_out_f32_1024 (_Stream_out_f32_1024& stream, int32_t writePos, float value) noexcept
    {
        stream.m_buffer[writePos] = value;
    }

    //==============================================================================
    float soul__dBtoGain (float decibels) noexcept
    {
        float _2 = {}, _3 = {}, _4 = {}, _T0 = {};

        if (! (decibels > -100.0f)) goto _ternary_false_0;
        _ternary_true_0: { _2 = SOUL_INTRINSICS::pow (10.0f, decibels * 0.05f);
                           _T0 = _2;
                           goto _ternary_end_0;
        }
        _ternary_false_0: { _3 = 0;
                            _T0 = _3;
        }
        _ternary_end_0: { _4 = _T0;
                          return _4;
        }
    }

    float soul__noteNumberToFrequency_2 (float note) noexcept
    {
        float _2 = {};

        _2 = SOUL_INTRINSICS::pow (2.0f, (note - 69.0f) * 0.083333336f);
        return 440.0f * _2;
    }

    //==============================================================================
    float soul__intrinsics___pow_specialised (float a, float b) noexcept
    {
        return 0;
    }

    float soul__intrinsics___sin_specialised (float n) noexcept
    {
        return 0;
    }

    float soul__intrinsics___abs_specialised (float n) noexcept
    {
        float _2 = {}, _3 = {}, _4 = {}, _T0 = {};

        if (! (n < 0)) goto _ternary_false_0;
        _ternary_true_0: { _2 = -n;
                           _T0 = _2;
                           goto _ternary_end_0;
        }
        _ternary_false_0: { _3 = n;
                            _T0 = _3;
        }
        _ternary_end_0: { _4 = _T0;
                          return _4;
        }
    }

    int32_t soul__intrinsics___max_specialised (int32_t a, int32_t b) noexcept
    {
        int32_t _2 = {}, _3 = {}, _4 = {}, _T0 = {};

        if (! (a > b)) goto _ternary_false_0;
        _ternary_true_0: { _2 = a;
                           _T0 = _2;
                           goto _ternary_end_0;
        }
        _ternary_false_0: { _3 = b;
                            _T0 = _3;
        }
        _ternary_end_0: { _4 = _T0;
                          return _4;
        }
    }

    float soul__intrinsics___addModulo2Pi_specialised (float value, float increment) noexcept
    {
        float _2 = {}, _3 = {}, _4 = {}, _T2 = {};

        value = value + increment;
        if (! (value >= 6.2831855f)) goto _ifnot_0;
        _if_0: { if (! (value >= 12.566371f)) goto _ifnot_1; }
        _if_1: { return SOUL_INTRINSICS::fmod (value, 6.2831855f); }
        _ifnot_1: { return value - 6.2831855f; }
        _ifnot_0: { if (! (value < 0)) goto _ternary_false_2; }
        _ternary_true_2: { _2 = SOUL_INTRINSICS::fmod (value, 6.2831855f) + 6.2831855f;
                           _T2 = _2;
                           goto _ternary_end_2;
        }
        _ternary_false_2: { _3 = value;
                            _T2 = _3;
        }
        _ternary_end_2: { _4 = _T2;
                          return _4;
        }
    }

    //==============================================================================
    int32_t soul__midi__getByte1 (soul__midi__Message m) noexcept
    {
        return (m.m_midiBytes >> 16) & 255;
    }

    int32_t soul__midi__getByte2 (soul__midi__Message m) noexcept
    {
        return (m.m_midiBytes >> 8) & 255;
    }

    int32_t soul__midi__getByte3 (soul__midi__Message m) noexcept
    {
        return m.m_midiBytes & 255;
    }

    //==============================================================================
    static _State& _stateUpCast (soul__midi__MPEParser___State& s)
    {
        auto offset = static_cast<int32_t> (offsetof (_State, m_MPEParser_state));
        return *reinterpret_cast<_State*> (reinterpret_cast<char*> (&s) - offset);
    }

    //==============================================================================
    void soul__midi__MPEParser___parseMIDI_struct_Message (soul__midi__MPEParser___State& _state, soul__midi__Message message) noexcept
    {
        int32_t _2 = {}, _3 = {}, _4 = {};
        int32_t messageByte1 = {}, messageByte2 = {}, messageByte3 = {}, messageType = {}, channel = {};
        soul__note_events__NoteOff _5 = {}, _6 = {};
        float _7 = {}, _8 = {}, _9 = {}, _10 = {}, _11 = {}, _12 = {};
        soul__note_events__NoteOn _13 = {};
        soul__note_events__Slide _14 = {};
        soul__note_events__Control _15 = {};
        soul__note_events__Pressure _16 = {};
        soul__note_events__PitchBend _17 = {};

        _2 = soul__midi__getByte1 (message);
        messageByte1 = static_cast<int32_t> (_2);
        _3 = soul__midi__getByte2 (message);
        messageByte2 = static_cast<int32_t> (_3);
        _4 = soul__midi__getByte3 (message);
        messageByte3 = static_cast<int32_t> (_4);
        messageType = static_cast<int32_t> (static_cast<int32_t> (messageByte1) & 240);
        channel = static_cast<int32_t> (static_cast<int32_t> (messageByte1) & 15);
        if (! (messageType == 128)) goto _ifnot_0;
        _if_0: { _5 = ZeroInitialiser();
                 _5.m_channel = static_cast<int32_t> (channel);
                 _5.m_note = static_cast<float> (messageByte2);
                 _7 = soul__midi__MPEParser__normaliseValue (_state, static_cast<int32_t> (messageByte3));
                 _5.m_velocity = _7;
                 soul__midi__MPEParser___eventOut_struct_NoteOff (_state, _5);
                 goto _ifend_0;
        }
        _ifnot_0: { if (! (messageType == 144)) goto _ifnot_1; }
        _if_1: { if (! (messageByte3 == 0)) goto _ifnot_2; }
        _if_2: { _6 = ZeroInitialiser();
                 _6.m_channel = static_cast<int32_t> (channel);
                 _6.m_note = static_cast<float> (messageByte2);
                 soul__midi__MPEParser___eventOut_struct_NoteOff (_state, _6);
                 goto _ifend_0;
        }
        _ifnot_2: { _13 = ZeroInitialiser();
                    _13.m_channel = static_cast<int32_t> (channel);
                    _13.m_note = static_cast<float> (messageByte2);
                    _8 = soul__midi__MPEParser__normaliseValue (_state, static_cast<int32_t> (messageByte3));
                    _13.m_velocity = _8;
                    soul__midi__MPEParser___eventOut_struct_NoteOn (_state, _13);
                    goto _ifend_0;
        }
        _ifnot_1: { if (! (messageType == 176)) goto _ifnot_3; }
        _if_3: { if (! (messageByte2 == 74)) goto _ifnot_4; }
        _if_4: { _14 = ZeroInitialiser();
                 _14.m_channel = static_cast<int32_t> (channel);
                 _9 = soul__midi__MPEParser__normaliseValue (_state, static_cast<int32_t> (messageByte3));
                 _14.m_slide = _9;
                 goto _ifend_0;
        }
        _ifnot_4: { _15 = ZeroInitialiser();
                    _15.m_channel = static_cast<int32_t> (channel);
                    _15.m_control = static_cast<int32_t> (messageByte2);
                    _10 = soul__midi__MPEParser__normaliseValue (_state, static_cast<int32_t> (messageByte3));
                    _15.m_value = _10;
                    soul__midi__MPEParser___eventOut_struct_Control (_state, _15);
                    goto _ifend_0;
        }
        _ifnot_3: { if (! (messageType == 208)) goto _ifnot_5; }
        _if_5: { _16 = ZeroInitialiser();
                 _16.m_channel = static_cast<int32_t> (channel);
                 _11 = soul__midi__MPEParser__normaliseValue (_state, static_cast<int32_t> (messageByte2));
                 _16.m_pressure = _11;
                 goto _ifend_0;
        }
        _ifnot_5: { if (! (messageType == 224)) goto _ifend_0; }
        _if_6: { _17 = ZeroInitialiser();
                 _17.m_channel = static_cast<int32_t> (channel);
                 _12 = soul__midi__MPEParser__translateBendSemitones (_state, static_cast<int32_t> (messageByte3), static_cast<int32_t> (messageByte2));
                 _17.m_bendSemitones = _12;
                 soul__midi__MPEParser___eventOut_struct_PitchBend (_state, _17);
        }
        _ifend_0: {}
    }

    float soul__midi__MPEParser__normaliseValue (soul__midi__MPEParser___State& _state, int32_t i) noexcept
    {
        return static_cast<float> (i) * 0.007874016f;
    }

    float soul__midi__MPEParser__translateBendSemitones (soul__midi__MPEParser___State& _state, int32_t msb, int32_t lsb) noexcept
    {
        int32_t value = {};

        value = static_cast<int32_t> ((msb * 128) + lsb);
        return static_cast<float> (value - 8192) / 170.66667f;
    }

    void soul__midi__MPEParser___eventOut_struct_NoteOff (soul__midi__MPEParser___State& _state, soul__note_events__NoteOff value) noexcept
    {
        auto& _2 = _stateUpCast (_state);
        soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_NoteOff (_2.m_voiceAllocator_state, value);
    }

    void soul__midi__MPEParser___eventOut_struct_NoteOn (soul__midi__MPEParser___State& _state, soul__note_events__NoteOn value) noexcept
    {
        auto& _2 = _stateUpCast (_state);
        soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_NoteOn (_2.m_voiceAllocator_state, value);
    }

    void soul__midi__MPEParser___eventOut_struct_Control (soul__midi__MPEParser___State& _state, soul__note_events__Control value) noexcept
    {
        auto& _2 = _stateUpCast (_state);
        soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_Control (_2.m_voiceAllocator_state, value);
    }

    void soul__midi__MPEParser___eventOut_struct_PitchBend (soul__midi__MPEParser___State& _state, soul__note_events__PitchBend value) noexcept
    {
        auto& _2 = _stateUpCast (_state);
        soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_PitchBend (_2.m_voiceAllocator_state, value);
    }

    //==============================================================================
    void soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___volume_f32 (soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___State& _state, float targetDB) noexcept
    {
        float _2 = {}, _3 = {};
        float maxDelta = {};
        int32_t _4 = {};

        _2 = soul__dBtoGain (targetDB);
        _state.m_targetGain = _2;
        maxDelta = static_cast<float> (static_cast<float> ((1.0 / (sampleRate * 1.0))) / 0.5f);
        _3 = soul__intrinsics___abs_specialised (_state.m_targetGain - _state.m_currentGain);
        _4 = soul__intrinsics___max_specialised (1, static_cast<int32_t> (_3 / static_cast<float> (maxDelta)));
        _state.m_remainingRampSamples = _4;
        _state.m_increment = (_state.m_targetGain - _state.m_currentGain) / static_cast<float> (_state.m_remainingRampSamples);
    }

    void soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain__run (soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___State& _state, soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___IO& _io) noexcept
    {
        float out_value_gain = {};
        int32_t _2 = {}, _3 = {};

        out_value_gain = 0;
        if (! (_state.m_remainingRampSamples != 0)) goto _ifnot_0;
        _if_0: { _2 = _state.m_remainingRampSamples;
                 _3 = _2 - 1;
                 _state.m_remainingRampSamples = _3;
                 if (! (_3 == 0)) goto _ifnot_1;
        }
        _if_1: { _state.m_currentGain = _state.m_targetGain;
                 goto _ifnot_0;
        }
        _ifnot_1: { _state.m_currentGain = _state.m_currentGain + _state.m_increment; }
        _ifnot_0: { out_value_gain = out_value_gain + _state.m_currentGain;
                    _state.m__resumePoint = 1;
                    _io.m__out_gain = out_value_gain;
        }
    }

    void soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___initialise (soul__gain__SmoothedGainParameter___for__root__SineSynth_smoothedGain___State& _state) noexcept
    {
        _state.m_targetGain = 0;
        _state.m_currentGain = 0;
        _state.m_increment = 0;
        _state.m_remainingRampSamples = 0;
    }

    //==============================================================================
    void soul__gain__DynamicGain___for__root__SineSynth_gainProcessor__run (soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___State& _state, soul__gain__DynamicGain___for__root__SineSynth_gainProcessor___IO& _io) noexcept
    {
        float out_value_out = {}, _2 = {}, _3 = {};

        out_value_out = 0;
        _2 = _io.m__in_in;
        _3 = _io.m__in_gain;
        out_value_out = out_value_out + (_2 * _3);
        _state.m__resumePoint = 1;
        _io.m__out_out = out_value_out;
    }

    //==============================================================================
    void soul__gain__DynamicGain___for__root__Voice_attenuator__run (soul__gain__DynamicGain___for__root__Voice_attenuator___State& _state, soul__gain__DynamicGain___for__root__Voice_attenuator___IO& _io) noexcept
    {
        float out_value_out = {}, _2 = {}, _3 = {};

        out_value_out = 0;
        _2 = _io.m__in_in;
        _3 = _io.m__in_gain;
        out_value_out = out_value_out + (_2 * _3);
        _state.m__resumePoint = 1;
        _io.m__out_out = out_value_out;
    }

    //==============================================================================
    void soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___noteIn_struct_NoteOn (soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___State& _state, soul__note_events__NoteOn e) noexcept
    {
        _state.m_active = true;
        _state.m_targetLevel = e.m_velocity;
    }

    void soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___noteIn_struct_NoteOff (soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___State& _state, soul__note_events__NoteOff e) noexcept
    {
        _state.m_active = false;
    }

    void soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope__run (soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___State& _state, soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___IO& _io) noexcept
    {
        float out_value_levelOut = {}, _2 = {}, _3 = {}, _4 = {};
        int32_t _resumePoint = {};
        int32_t attackSamples = {};
        bool _5 = {}, _6 = {}, _7 = {}, _8 = {}, _9 = {}, _10 = {}, _T0 = {}, _T1 = {};

        out_value_levelOut = 0;
        _resumePoint = _state.m__resumePoint;
        if (_resumePoint == 1) goto _loop_1;
        _check_resume_point_2: { if (_resumePoint == 2) goto _resume_point_2; }
        _check_resume_point_3: { if (_resumePoint == 3) goto _loop_3; }
        _check_resume_point_4: { if (_resumePoint == 4) goto _loop_4; }
        _loop_1: { if (! (! _state.m_active)) goto _break_1; }
        _advance_start_0: { _state.m__resumePoint = 1;
                            goto _exit;
        }
        _break_1: { _state.m_level = 0;
                    attackSamples = static_cast<int32_t> (static_cast<int32_t> (static_cast<float> ((sampleRate * 1.0)) * 0.02f));
                    _2 = SOUL_INTRINSICS::pow (2.0f, -1.0f / static_cast<float> (attackSamples));
                    _3 = SOUL_INTRINSICS::pow (_state.m_targetLevel + 2.0f, 1.0f / static_cast<float> (attackSamples));
                    _state.m_attackMultiplier = static_cast<float> (_2 * _3);
                    _state.m_attackLevel = 2.0f;
        }
        _loop_2: { if (! _state.m_active) goto _ternary_false_0; }
        _ternary_true_0: { _5 = _state.m_level < _state.m_targetLevel;
                           _T0 = _5;
                           goto _ternary_end_0;
        }
        _ternary_false_0: { _6 = false;
                            _T0 = _6;
        }
        _ternary_end_0: { _7 = _T0;
                          if (! _7) goto _loop_3;
        }
        _body_2: { _state.m_level = _state.m_attackLevel - 2.0f;
                   out_value_levelOut = out_value_levelOut + _state.m_level;
                   _state.m__resumePoint = 2;
                   goto _exit;
        }
        _resume_point_2: { _state.m_attackLevel = _state.m_attackLevel * static_cast<float> (_state.m_attackMultiplier);
                           goto _loop_2;
        }
        _loop_3: { if (! _state.m_active) goto _break_3; }
        _body_3: { out_value_levelOut = out_value_levelOut + _state.m_level;
                   _state.m__resumePoint = 3;
                   goto _exit;
        }
        _break_3: { _4 = SOUL_INTRINSICS::pow (0.0001f, static_cast<float> ((1.0 / (sampleRate * 1.0))) / 0.1f);
                    _state.m_releaseMultiplier = static_cast<float> (_4);
        }
        _loop_4: { if (! (! _state.m_active)) goto _ternary_false_1; }
        _ternary_true_1: { _8 = _state.m_level > 0.00001f;
                           _T1 = _8;
                           goto _ternary_end_1;
        }
        _ternary_false_1: { _9 = false;
                            _T1 = _9;
        }
        _ternary_end_1: { _10 = _T1;
                          if (! _10) goto _loop_1;
        }
        _body_4: { out_value_levelOut = out_value_levelOut + _state.m_level;
                   _state.m_level = _state.m_level * static_cast<float> (_state.m_releaseMultiplier);
                   _state.m__resumePoint = 4;
        }
        _exit: { _io.m__out_levelOut = out_value_levelOut; }
    }

    void soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___initialise (soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___State& _state) noexcept
    {
        _state.m_active = false;
        _state.m_targetLevel = 0;
    }

    //==============================================================================
    static _State& _stateUpCast (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& s)
    {
        auto offset = static_cast<int32_t> (offsetof (_State, m_voiceAllocator_state));
        return *reinterpret_cast<_State*> (reinterpret_cast<char*> (&s) - offset);
    }

    //==============================================================================
    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_NoteOn (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state, soul__note_events__NoteOn e) noexcept
    {
        int32_t allocatedVoice = {};
        int32_t allocatedVoiceAge = {}, i = {}, _2 = {}, _3 = {};
        int32_t age = {};
        soul__note_events__NoteOff noteOff = {};

        allocatedVoice = 0;
        allocatedVoiceAge = _state.m_voiceInfo[allocatedVoice].m_voiceAge;
        i = 1;
        _loop_0: { if (! (i < 8)) goto _break_0; }
        _body_0: { age = static_cast<int32_t> (_state.m_voiceInfo[_intrin_wrap (static_cast<int32_t> (i), 8) & 7].m_voiceAge);
                   if (! (age < static_cast<int32_t> (allocatedVoiceAge))) goto _cont_0;
        }
        _if_0: { allocatedVoiceAge = static_cast<int32_t> (age);
                 allocatedVoice = _intrin_wrap (static_cast<int32_t> (i), 8) & 7;
        }
        _cont_0: { _2 = i;
                   i = _2 + 1;
                   goto _loop_0;
        }
        _break_0: { if (! _state.m_voiceInfo[allocatedVoice].m_active) goto _ifnot_1; }
        _if_1: { noteOff = ZeroInitialiser();
                 noteOff.m_channel = _state.m_voiceInfo[allocatedVoice].m_channel;
                 noteOff.m_note = _state.m_voiceInfo[allocatedVoice].m_note;
                 soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_NoteOff (_state, static_cast<int32_t> (allocatedVoice) & 7, noteOff);
        }
        _ifnot_1: { soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_NoteOn (_state, static_cast<int32_t> (allocatedVoice) & 7, e);
                    _state.m_voiceInfo[allocatedVoice].m_active = true;
                    _state.m_voiceInfo[allocatedVoice].m_noteReleased = false;
                    _state.m_voiceInfo[allocatedVoice].m_channel = e.m_channel;
                    _state.m_voiceInfo[allocatedVoice].m_note = e.m_note;
                    _3 = _state.m_nextAllocatedVoiceAge;
                    _state.m_nextAllocatedVoiceAge = _3 + 1;
                    _state.m_voiceInfo[allocatedVoice].m_voiceAge = _3;
        }
    }

    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_NoteOff (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state, soul__note_events__NoteOff e) noexcept
    {
        int32_t voice = {}, _2 = {};
        bool _3 = {}, _4 = {}, pedalDown = {}, _5 = {}, _6 = {}, _7 = {}, _T0 = {}, _T2 = {};
        int32_t counter_0 = {};
        int32_t _8 = {};

        voice = 0;
        if (! _state.m_masterSustainActive) goto _ternary_false_0;
        _ternary_true_0: { _3 = true;
                           _T0 = _3;
                           goto _ternary_end_0;
        }
        _ternary_false_0: { _4 = _state.m_channelSustainActive[_intrin_wrap (static_cast<int32_t> (e.m_channel), 16) & 15];
                            _T0 = _4;
        }
        _ternary_end_0: { pedalDown = _T0;
                          counter_0 = 8;
        }
        _loop_0: { if (! (counter_0 > 0)) goto _break_0; }
        _body_0: { if (! (_state.m_voiceInfo[voice].m_channel == e.m_channel)) goto _ternary_false_2; }
        _ternary_true_2: { _5 = _state.m_voiceInfo[voice].m_note == e.m_note;
                           _T2 = _5;
                           goto _ternary_end_2;
        }
        _ternary_false_2: { _6 = false;
                            _T2 = _6;
        }
        _ternary_end_2: { _7 = _T2;
                          if (! _7) goto _ifnot_1;
        }
        _if_1: { if (! pedalDown) goto _ifnot_3; }
        _if_3: { _state.m_voiceInfo[voice].m_noteReleased = true;
                 goto _ifnot_1;
        }
        _ifnot_3: { _state.m_voiceInfo[voice].m_active = false;
                    _8 = _state.m_nextUnallocatedVoiceAge;
                    _state.m_nextUnallocatedVoiceAge = _8 + 1;
                    _state.m_voiceInfo[voice].m_voiceAge = _8;
                    soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_NoteOff (_state, static_cast<int32_t> (voice) & 7, e);
        }
        _ifnot_1: { _2 = voice;
                    voice = (_2 + 1) & 7;
                    counter_0 = counter_0 - 1;
                    goto _loop_0;
        }
        _break_0: {}
    }

    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_PitchBend (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state, soul__note_events__PitchBend e) noexcept
    {
        int32_t voice = {}, _2 = {};
        int32_t counter_0 = {};

        voice = 0;
        counter_0 = 8;
        _loop_0: { if (! (counter_0 > 0)) goto _break_0; }
        _body_0: { if (! (_state.m_voiceInfo[voice].m_channel == e.m_channel)) goto _ifnot_0; }
        _if_0: { soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_PitchBend (_state, static_cast<int32_t> (voice) & 7, e); }
        _ifnot_0: { _2 = voice;
                    voice = (_2 + 1) & 7;
                    counter_0 = counter_0 - 1;
                    goto _loop_0;
        }
        _break_0: {}
    }

    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___eventIn_struct_Control (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state, soul__note_events__Control c) noexcept
    {
        bool pedalDown = {}, isMasterChannel = {}, _2 = {}, _3 = {}, _4 = {}, _5 = {}, _6 = {}, _7 = {}, _8 = {}, _9 = {}, _10 = {}, _T6 = {}, _T5 = {}, _T4 = {};
        int32_t voice = {}, _11 = {}, voice_2 = {}, _12 = {};
        int32_t counter_0 = {}, counter_1 = {};
        soul__note_events__NoteOff noteOff = {};
        int32_t _13 = {};

        if (! (c.m_control == 64)) goto _ifnot_0;
        _if_0: { pedalDown = c.m_value >= 0.5f;
                 isMasterChannel = c.m_channel == 0;
                 _state.m_channelSustainActive[_intrin_wrap (static_cast<int32_t> (c.m_channel), 16) & 15] = pedalDown;
                 if (! isMasterChannel) goto _ifnot_1;
        }
        _if_1: { _state.m_masterSustainActive = pedalDown; }
        _ifnot_1: { if (! (! pedalDown)) goto _ifnot_2; }
        _if_2: { voice = 0;
                 counter_0 = 8;
        }
        _loop_0: { if (! (counter_0 > 0)) goto _ifnot_2; }
        _body_0: { if (! isMasterChannel) goto _ternary_false_6; }
        _ternary_true_6: { _2 = true;
                           _T6 = _2;
                           goto _ternary_end_6;
        }
        _ternary_false_6: { _3 = _state.m_voiceInfo[voice].m_channel == c.m_channel;
                            _T6 = _3;
        }
        _ternary_end_6: { _4 = _T6;
                          if (! _4) goto _ternary_false_5;
        }
        _ternary_true_5: { _5 = _state.m_voiceInfo[voice].m_active == true;
                           _T5 = _5;
                           goto _ternary_end_5;
        }
        _ternary_false_5: { _6 = false;
                            _T5 = _6;
        }
        _ternary_end_5: { _7 = _T5;
                          if (! _7) goto _ternary_false_4;
        }
        _ternary_true_4: { _8 = _state.m_voiceInfo[voice].m_noteReleased == true;
                           _T4 = _8;
                           goto _ternary_end_4;
        }
        _ternary_false_4: { _9 = false;
                            _T4 = _9;
        }
        _ternary_end_4: { _10 = _T4;
                          if (! _10) goto _ifnot_3;
        }
        _if_3: { noteOff = ZeroInitialiser();
                 noteOff.m_channel = _state.m_voiceInfo[voice].m_channel;
                 noteOff.m_note = _state.m_voiceInfo[voice].m_note;
                 soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_NoteOff (_state, static_cast<int32_t> (voice) & 7, noteOff);
                 _state.m_voiceInfo[voice].m_active = false;
                 _13 = _state.m_nextUnallocatedVoiceAge;
                 _state.m_nextUnallocatedVoiceAge = _13 + 1;
                 _state.m_voiceInfo[voice].m_voiceAge = _13;
        }
        _ifnot_3: { _11 = voice;
                    voice = (_11 + 1) & 7;
                    counter_0 = counter_0 - 1;
                    goto _loop_0;
        }
        _ifnot_2: { return; }
        _ifnot_0: { voice_2 = 0;
                    counter_1 = 8;
        }
        _loop_1: { if (! (counter_1 > 0)) goto _break_1; }
        _body_1: { if (! (_state.m_voiceInfo[voice_2].m_channel == c.m_channel)) goto _ifnot_7; }
        _if_7: {}
        _ifnot_7: { _12 = voice_2;
                    voice_2 = (_12 + 1) & 7;
                    counter_1 = counter_1 - 1;
                    goto _loop_1;
        }
        _break_1: {}
    }

    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___initialise (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state) noexcept
    {
        _state.m_nextAllocatedVoiceAge = 1000000000;
        _state.m_nextUnallocatedVoiceAge = 1;
        _state.m_voiceInfo = ZeroInitialiser();
        _state.m_channelSustainActive = ZeroInitialiser();
        _state.m_masterSustainActive = false;
    }

    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_NoteOff (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state, int32_t element, soul__note_events__NoteOff value) noexcept
    {
        if (element == 0) goto _element_0;
        _block_1: { if (element == 1) goto _element_1; }
        _block_2: { if (element == 2) goto _element_2; }
        _block_3: { if (element == 3) goto _element_3; }
        _block_4: { if (element == 4) goto _element_4; }
        _block_5: { if (element == 5) goto _element_5; }
        _block_6: { if (element == 6) goto _element_6; }
        _block_7: { if (element == 7) goto _element_7; }
        _block_8: { return; }
        _element_0: { auto& _2 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_2.m_voices_state[0], value);
                      return;
        }
        _element_1: { auto& _3 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_3.m_voices_state[1], value);
                      return;
        }
        _element_2: { auto& _4 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_4.m_voices_state[2], value);
                      return;
        }
        _element_3: { auto& _5 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_5.m_voices_state[3], value);
                      return;
        }
        _element_4: { auto& _6 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_6.m_voices_state[4], value);
                      return;
        }
        _element_5: { auto& _7 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_7.m_voices_state[5], value);
                      return;
        }
        _element_6: { auto& _8 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_8.m_voices_state[6], value);
                      return;
        }
        _element_7: { auto& _9 = _stateUpCast (_state);
                      Voice___noteOff_struct_NoteOff (_9.m_voices_state[7], value);
        }
    }

    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_NoteOn (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state, int32_t element, soul__note_events__NoteOn value) noexcept
    {
        if (element == 0) goto _element_0;
        _block_1: { if (element == 1) goto _element_1; }
        _block_2: { if (element == 2) goto _element_2; }
        _block_3: { if (element == 3) goto _element_3; }
        _block_4: { if (element == 4) goto _element_4; }
        _block_5: { if (element == 5) goto _element_5; }
        _block_6: { if (element == 6) goto _element_6; }
        _block_7: { if (element == 7) goto _element_7; }
        _block_8: { return; }
        _element_0: { auto& _2 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_2.m_voices_state[0], value);
                      return;
        }
        _element_1: { auto& _3 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_3.m_voices_state[1], value);
                      return;
        }
        _element_2: { auto& _4 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_4.m_voices_state[2], value);
                      return;
        }
        _element_3: { auto& _5 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_5.m_voices_state[3], value);
                      return;
        }
        _element_4: { auto& _6 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_6.m_voices_state[4], value);
                      return;
        }
        _element_5: { auto& _7 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_7.m_voices_state[5], value);
                      return;
        }
        _element_6: { auto& _8 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_8.m_voices_state[6], value);
                      return;
        }
        _element_7: { auto& _9 = _stateUpCast (_state);
                      Voice___noteOn_struct_NoteOn (_9.m_voices_state[7], value);
        }
    }

    void soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___voiceEventOut_struct_PitchBend (soul___voice_allocators__Basic___for__root__SineSynth_voiceAllocator___State& _state, int32_t element, soul__note_events__PitchBend value) noexcept
    {
        if (element == 0) goto _element_0;
        _block_1: { if (element == 1) goto _element_1; }
        _block_2: { if (element == 2) goto _element_2; }
        _block_3: { if (element == 3) goto _element_3; }
        _block_4: { if (element == 4) goto _element_4; }
        _block_5: { if (element == 5) goto _element_5; }
        _block_6: { if (element == 6) goto _element_6; }
        _block_7: { if (element == 7) goto _element_7; }
        _block_8: { return; }
        _element_0: { auto& _2 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_2.m_voices_state[0], value);
                      return;
        }
        _element_1: { auto& _3 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_3.m_voices_state[1], value);
                      return;
        }
        _element_2: { auto& _4 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_4.m_voices_state[2], value);
                      return;
        }
        _element_3: { auto& _5 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_5.m_voices_state[3], value);
                      return;
        }
        _element_4: { auto& _6 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_6.m_voices_state[4], value);
                      return;
        }
        _element_5: { auto& _7 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_7.m_voices_state[5], value);
                      return;
        }
        _element_6: { auto& _8 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_8.m_voices_state[6], value);
                      return;
        }
        _element_7: { auto& _9 = _stateUpCast (_state);
                      Voice___pitchBend_struct_PitchBend (_9.m_voices_state[7], value);
        }
    }

    //==============================================================================
    void SineOsc___noteOn_struct_NoteOn (SineOsc___State& _state, soul__note_events__NoteOn e) noexcept
    {
        _state.m_notePitch = e.m_note;
        _state.m_bendSemitones = 0;
        SineOsc__calculatePhaseIncrement (_state);
    }

    void SineOsc___pitchBend_struct_PitchBend (SineOsc___State& _state, soul__note_events__PitchBend e) noexcept
    {
        _state.m_bendSemitones = e.m_bendSemitones;
        SineOsc__calculatePhaseIncrement (_state);
    }

    void SineOsc__calculatePhaseIncrement (SineOsc___State& _state) noexcept
    {
        float _2 = {};
        float noteFrequency = {};

        _2 = soul__noteNumberToFrequency_2 (_state.m_notePitch + _state.m_bendSemitones);
        noteFrequency = static_cast<float> (_2);
        _state.m_phaseIncrement = static_cast<float> ((static_cast<double> (noteFrequency) * 6.283185307179586) * (1.0 / (sampleRate * 1.0)));
    }

    void SineOsc__run (SineOsc___State& _state, SineOsc___IO& _io) noexcept
    {
        float out_value_audioOut = {}, _2 = {}, _3 = {};

        out_value_audioOut = 0;
        _2 = soul__intrinsics___addModulo2Pi_specialised (_state.m_phase, _state.m_phaseIncrement);
        _state.m_phase = _2;
        _3 = SOUL_INTRINSICS::sin (_state.m_phase);
        out_value_audioOut = out_value_audioOut + _3;
        _state.m__resumePoint = 1;
        _io.m__out_audioOut = out_value_audioOut;
    }

    void SineOsc___initialise (SineOsc___State& _state) noexcept
    {
        _state.m_notePitch = 0;
        _state.m_bendSemitones = 0;
        _state.m_phase = 0;
        _state.m_phaseIncrement = 0;
    }

    //==============================================================================
    void Voice___initialise (Voice___State& _state) noexcept
    {
        _state.m_osc_state.m__arrayEntry = 0;
        _state.m_osc_state.m__sessionID = _state.m__sessionID;
        _state.m_osc_state.m__processorId = 1;
        SineOsc___initialise (_state.m_osc_state);
        _state.m_amplitudeEnvelope_state.m__arrayEntry = 0;
        _state.m_amplitudeEnvelope_state.m__sessionID = _state.m__sessionID;
        _state.m_amplitudeEnvelope_state.m__processorId = 2;
        soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___initialise (_state.m_amplitudeEnvelope_state);
        _state.m_attenuator_state.m__arrayEntry = 0;
        _state.m_attenuator_state.m__sessionID = _state.m__sessionID;
        _state.m_attenuator_state.m__processorId = 3;
    }

    void Voice__run (Voice___State& _state, Voice___IO& _io) noexcept
    {
        SineOsc___IO _2 = {};
        soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___IO _3 = {};
        soul__gain__DynamicGain___for__root__Voice_attenuator___IO _4 = {};

        _2 = ZeroInitialiser();
        SineOsc__run (_state.m_osc_state, _2);
        _3 = ZeroInitialiser();
        soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope__run (_state.m_amplitudeEnvelope_state, _3);
        _4 = ZeroInitialiser();
        _4.m__in_in = _2.m__out_audioOut;
        _4.m__in_gain = _3.m__out_levelOut;
        soul__gain__DynamicGain___for__root__Voice_attenuator__run (_state.m_attenuator_state, _4);
        _io.m__out_audioOut = _4.m__out_out;
    }

    void Voice___noteOn_struct_NoteOn (Voice___State& _state, soul__note_events__NoteOn event) noexcept
    {
        SineOsc___noteOn_struct_NoteOn (_state.m_osc_state, event);
        soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___noteIn_struct_NoteOn (_state.m_amplitudeEnvelope_state, event);
    }

    void Voice___noteOff_struct_NoteOff (Voice___State& _state, soul__note_events__NoteOff event) noexcept
    {
        soul__envelope__FixedAttackReleaseEnvelope___for__root__Voice_amplitudeEnvelope___noteIn_struct_NoteOff (_state.m_amplitudeEnvelope_state, event);
    }

    void Voice___pitchBend_struct_PitchBend (Voice___State& _state, soul__note_events__PitchBend event) noexcept
    {
        SineOsc___pitchBend_struct_PitchBend (_state.m_osc_state, event);
    }

    //==============================================================================
    int32_t _internal___minInt32 (int32_t a, int32_t b) noexcept
    {
        if (! (a < b)) goto _moreThan;
        _lessThan: { return a; }
        _moreThan: { return b; }
    }


    #if __clang__
     #pragma clang diagnostic pop
    #elif defined(__GNUC__)
     #pragma GCC diagnostic pop
    #elif defined(_MSC_VER)
     #pragma warning (pop)
    #endif

    //==============================================================================
    // The program contains no string literals, so this function should never be called
    static constexpr const char* lookupStringLiteral (int32_t)  { return {}; }

    //==============================================================================
    _State state = {}, initialisedState;

    double sampleRate = 1.0;
    uint32_t framesToAdvance = 0;
    uint64_t totalFramesElapsed = 0;
};