-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSynthConfig.ts
More file actions
2585 lines (2440 loc) · 233 KB
/
Copy pathSynthConfig.ts
File metadata and controls
2585 lines (2440 loc) · 233 KB
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) 2012-2022 John Nesky and contributing authors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice 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 NONINFRINGEMENT. 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.
*/
export interface Dictionary<T> {
[K: string]: T;
}
// @TODO: Not ideal to make this writable like this.
// export interface DictionaryArray<T> extends ReadonlyArray<T> {
export interface DictionaryArray<T> extends Array<T> {
dictionary: Dictionary<T>;
}
export const enum FilterType {
lowPass,
highPass,
peak,
length,
}
export const enum SustainType {
bright,
acoustic,
length,
}
export const enum GranularEnvelopeType {
parabolic,
raisedCosineBell,
// trapezoid,
length
}
export const enum EnvelopeType {
none,
noteSize,
pitch, //slarmoo's box 0.9
pseudorandom, //slarmoo's box 1.3
punch,
flare,
twang,
swell,
lfo, //renamed from tremolo in slarmoo's box 1.3
tremolo2, //deprecated as of slarmoo's box 1.3; Kept for updating integrity and drumsets
decay,
wibble,
linear,
rise,
blip,
fall, //slarmoo's box 1.2
//add new envelope types here
}
export const enum InstrumentType {
chip,
fm,
noise,
spectrum,
drumset,
harmonics,
pwm,
pickedString,
supersaw,
customChipWave,
mod,
fm6op,
length,
}
export const TypePresets: ReadonlyArray<string> = ["chip", "FM", "noise", "spectrum", "drumset", "harmonics", "pulse width", "picked string", "supersaw", "chip (custom)", "mod", "FM (6-op)"];
export const enum DropdownID {
Vibrato = 0,
Pan = 1,
Chord = 2,
Transition = 3,
FM = 4,
PulseWidth = 5,
Unison = 6,
Envelope = 7,
EnvelopeSettings = 8,
}
export const enum EffectType {
reverb,
chorus,
panning,
distortion,
bitcrusher,
noteFilter,
echo,
pitchShift,
detune,
vibrato,
transition,
chord,
// If you add more, you'll also have to extend the bitfield used in Base64 which currently uses three six-bit characters.
noteRange, //no longer just a placeholder :3
ringModulation,
granular,
phaser,
octaveShift, //Studio Box port placeholder just in case
invertWave,
length,
}
export const enum EnvelopeComputeIndex {
noteVolume,
noteFilterAllFreqs,
pulseWidth,
stringSustain,
unison,
operatorFrequency0, operatorFrequency1, operatorFrequency2, operatorFrequency3, operatorFrequency4, operatorFrequency5,
operatorAmplitude0, operatorAmplitude1, operatorAmplitude2, operatorAmplitude3, operatorAmplitude4, operatorAmplitude5,
feedbackAmplitude,
pitchShift,
detune,
vibratoDepth,
//vibratoSpeed, doesn't follow normal envelope pattern; will figure out. //if you fix this you need to update the url
noteFilterFreq0, noteFilterFreq1, noteFilterFreq2, noteFilterFreq3, noteFilterFreq4, noteFilterFreq5, noteFilterFreq6, noteFilterFreq7,
noteFilterGain0, noteFilterGain1, noteFilterGain2, noteFilterGain3, noteFilterGain4, noteFilterGain5, noteFilterGain6, noteFilterGain7,
decimalOffset,
supersawDynamism,
supersawSpread,
supersawShape,
panning,
distortion,
bitcrusherQuantization,
bitcrusherFrequency,
chorus,
echoSustain,
reverb,
arpeggioSpeed,
ringModulation,
ringModulationHz,
granular,
grainAmount,
grainSize,
grainRange,
echoDelay,
//Add more here
phaserFreq,
phaserMix,
phaserFeedback,
phaserStages,
invertWave,
length,
}
export const enum LFOEnvelopeTypes {
sine,
square,
triangle,
sawtooth,
trapezoid,
steppedSaw,
steppedTri,
length,
}
export const enum RandomEnvelopeTypes {
time,
pitch,
note,
timeSmooth,
length,
}
export interface BeepBoxOption {
readonly index: number;
readonly name: string;
}
export interface Scale extends BeepBoxOption {
readonly flags: ReadonlyArray<boolean>;
readonly realName: string;
}
export interface Key extends BeepBoxOption {
readonly isWhiteKey: boolean;
readonly basePitch: number;
}
export interface Rhythm extends BeepBoxOption {
readonly stepsPerBeat: number;
readonly roundUpThresholds: number[] | null;
}
export interface ChipWave extends BeepBoxOption {
readonly expression: number;
samples: Float32Array;
isPercussion?: boolean;
isCustomSampled?: boolean;
isSampled?: boolean;
extraSampleDetune?: number;
rootKey?: number;
sampleRate?: number;
}
export interface OperatorWave extends BeepBoxOption {
samples: Float32Array;
}
export interface ChipNoise extends BeepBoxOption {
readonly expression: number;
readonly basePitch: number;
readonly pitchFilterMult: number;
readonly isSoft: boolean;
samples: Float32Array | null;
}
export interface Transition extends BeepBoxOption {
readonly isSeamless: boolean;
readonly continues: boolean;
readonly slides: boolean;
readonly slideTicks: number;
readonly includeAdjacentPatterns: boolean;
}
export interface Vibrato extends BeepBoxOption {
readonly amplitude: number;
readonly type: number;
readonly delayTicks: number;
}
export interface VibratoType extends BeepBoxOption {
readonly periodsSeconds: number[];
readonly period: number;
}
export interface Unison extends BeepBoxOption {
readonly voices: number;
readonly spread: number;
readonly offset: number;
readonly expression: number;
readonly sign: number;
}
export interface Modulator extends BeepBoxOption {
readonly name: string; // name that shows up in song editor UI
readonly pianoName: string; // short name that shows up in mod piano UI
readonly maxRawVol: number; // raw
readonly newNoteVol: number; // raw
readonly forSong: boolean; // true - setting is song scope
convertRealFactor: number; // offset that needs to be applied to get a "real" number display of value, for UI purposes
readonly associatedEffect: EffectType; // effect that should be enabled for this modulator to work properly. If unused, set to EffectType.length.
readonly promptName: string; // long-as-needed name that shows up in tip prompt
readonly promptDesc: string[]; // paragraph(s) describing how to use this mod
invertSliderIndicator?: boolean; // for whether or not you want to invert the slider indicator
readonly maxIndex: number;
}
export interface Chord extends BeepBoxOption {
readonly customInterval: boolean;
readonly arpeggiates: boolean;
readonly strumParts: number;
readonly singleTone: boolean;
}
export interface Algorithm extends BeepBoxOption {
readonly carrierCount: number;
readonly associatedCarrier: ReadonlyArray<number>;
readonly modulatedBy: ReadonlyArray<ReadonlyArray<number>>;
}
export interface OperatorFrequency extends BeepBoxOption {
readonly mult: number;
readonly hzOffset: number;
readonly amplitudeSign: number;
}
export interface Feedback extends BeepBoxOption {
readonly indices: ReadonlyArray<ReadonlyArray<number>>;
}
export interface Envelope extends BeepBoxOption {
readonly type: EnvelopeType;
readonly speed: number;
}
export interface AutomationTarget extends BeepBoxOption {
readonly computeIndex: EnvelopeComputeIndex /*| InstrumentAutomationIndex*/ | null;
readonly displayName: string;
readonly perNote: boolean; // Whether to compute envelopes on a per-note basis.
readonly interleave: boolean; // Whether to interleave this target with the next one in the menu (e.g. filter frequency and gain).
readonly isFilter: boolean; // Filters are special because the maxCount depends on other instrument settings.
//readonly range: number | null; // set if automation is allowed.
readonly maxCount: number;
readonly effect: EffectType | null;
readonly compatibleInstruments: InstrumentType[] | null;
}
export const enum SampleLoadingStatus {
loading,
loaded,
error,
}
export function getSampleLoadingStatusName(status: SampleLoadingStatus): string {
switch (status) {
case SampleLoadingStatus.loading: return "loading";
case SampleLoadingStatus.loaded: return "loaded";
case SampleLoadingStatus.error: return "error";
}
}
export class SampleLoadingState {
public statusTable: Dictionary<SampleLoadingStatus>;
public urlTable: Dictionary<string>;
public totalSamples: number;
public samplesLoaded: number;
constructor() {
this.statusTable = {};
this.urlTable = {};
this.totalSamples = 0;
this.samplesLoaded = 0;
}
}
export const sampleLoadingState: SampleLoadingState = new SampleLoadingState();
export class SampleLoadedEvent extends Event {
public readonly totalSamples: number;
public readonly samplesLoaded: number;
constructor(totalSamples: number, samplesLoaded: number) {
super("sampleloaded");
this.totalSamples = totalSamples;
this.samplesLoaded = samplesLoaded;
}
}
export interface SampleLoadEventMap {
"sampleloaded": SampleLoadedEvent;
}
export class SampleLoadEvents extends EventTarget {
constructor() {
super();
}
}
export const sampleLoadEvents: SampleLoadEvents = new SampleLoadEvents();
export async function startLoadingSample(url: string, chipWaveIndex: number, presetSettings: Dictionary<any>, rawLoopOptions: any, customSampleRate: number): Promise<void> {
// @TODO: Make parts of the code that expect everything to already be
// in memory work correctly.
// It would be easy to only instantiate `SongEditor` and company after
// everything is loaded, but if dynamic sample loading without a reload
// is deemed necessary, anything that involves chip waves has to be
// revisited so as to be able to work with a changing list of chip
// waves that may or may not be ready to be used.
const sampleLoaderAudioContext = new AudioContext({ sampleRate: customSampleRate });
let closedSampleLoaderAudioContext: boolean = false;
const chipWave = Config.chipWaves[chipWaveIndex];
const rawChipWave = Config.rawChipWaves[chipWaveIndex];
const rawRawChipWave = Config.rawRawChipWaves[chipWaveIndex];
if (OFFLINE) {
if (url.slice(0, 5) === "file:") {
const dirname = await getDirname();
const joined = await pathJoin(dirname, url.slice(5));
url = joined;
}
}
fetch(url).then((response) => {
if (!response.ok) {
// @TODO: Be specific with the error handling.
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.error;
return Promise.reject(new Error("Couldn't load sample"));
}
return response.arrayBuffer();
}).then((arrayBuffer) => {
return sampleLoaderAudioContext.decodeAudioData(arrayBuffer);
}).then((audioBuffer) => {
// @TODO: Downmix.
const samples = centerWave(Array.from(audioBuffer.getChannelData(0)));
const integratedSamples = performIntegral(samples);
chipWave.samples = integratedSamples;
rawChipWave.samples = samples;
rawRawChipWave.samples = samples;
if (rawLoopOptions["isUsingAdvancedLoopControls"]) {
presetSettings["chipWaveLoopStart"] = rawLoopOptions["chipWaveLoopStart"] != null ? rawLoopOptions["chipWaveLoopStart"] : 0;
presetSettings["chipWaveLoopEnd"] = rawLoopOptions["chipWaveLoopEnd"] != null ? rawLoopOptions["chipWaveLoopEnd"] : samples.length - 1;
presetSettings["chipWaveLoopMode"] = rawLoopOptions["chipWaveLoopMode"] != null ? rawLoopOptions["chipWaveLoopMode"] : 0;
presetSettings["chipWavePlayBackwards"] = rawLoopOptions["chipWavePlayBackwards"];
presetSettings["chipWaveStartOffset"] = rawLoopOptions["chipWaveStartOffset"] != null ? rawLoopOptions["chipWaveStartOffset"] : 0;
}
sampleLoadingState.samplesLoaded++;
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loaded;
sampleLoadEvents.dispatchEvent(new SampleLoadedEvent(
sampleLoadingState.totalSamples,
sampleLoadingState.samplesLoaded
));
if (!closedSampleLoaderAudioContext) {
closedSampleLoaderAudioContext = true;
sampleLoaderAudioContext.close();
}
}).catch((error) => {
//console.error(error);
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.error;
alert("Failed to load " + url + ":\n" + error);
if (!closedSampleLoaderAudioContext) {
closedSampleLoaderAudioContext = true;
sampleLoaderAudioContext.close();
}
});
}
export function getLocalStorageItem<T>(key: string, defaultValue: T): T | string {
let value: T | string | null = localStorage.getItem(key);
if (value == null || value === "null" || value === "undefined") {
value = defaultValue;
}
return value;
}
// @HACK: This just assumes these exist, regardless of whether they actually do
// or not.
declare global {
const OFFLINE: boolean; // for UB offline
const getDirname: () => Promise<string>; // for UB offline
const pathJoin: (...parts: string[]) => Promise<string>; // for UB offline
const kicksample: number[];
const snaresample: number[];
const pianosample: number[];
const WOWsample: number[];
const overdrivesample: number[];
const trumpetsample: number[];
const saxophonesample: number[];
const orchhitsample: number[];
const detatchedviolinsample: number[];
const synthsample: number[];
const sonic3snaresample: number[];
const comeonsample: number[];
const choirsample: number[];
const overdrivensample: number[];
const flutesample: number[];
const legatoviolinsample: number[];
const tremoloviolinsample: number[];
const amenbreaksample: number[];
const pizzicatoviolinsample: number[];
const timallengruntsample: number[];
const tubasample: number[];
const loopingcymbalsample: number[];
const kickdrumsample: number[];
const snaredrumsample: number[];
const closedhihatsample: number[];
const foothihatsample: number[];
const openhihatsample: number[];
const crashsample: number[];
const pianoC4sample: number[];
const liverpadsample: number[];
const marimbasample: number[];
const susdotwavsample: number[];
const wackyboxttssample: number[];
const peppersteak1: number[];
const peppersteak2: number[];
const vinyl: number[];
const slapbass: number[];
const hdeboverdrive: number[];
const sunsoftbass: number[];
const masculinechoir: number[];
const femininechoir: number[];
const southtololoche: number[];
const harp: number[];
const panflute: number[];
const krumhorn: number[];
const timpani: number[];
const crowdhey: number[];
const warioland4brass: number[];
const warioland4organ: number[];
const warioland4daow: number[];
const warioland4hourchime: number[];
const warioland4tick: number[];
const kirbykick: number[];
const kirbysnare: number[];
const kirbybongo: number[];
const kirbyclick: number[];
const funkkick: number[];
const funksnare: number[];
const funksnareleft: number[];
const funksnareright: number[];
const funktomhigh: number[];
const funktomlow: number[];
const funkhihatclosed: number[];
const funkhihathalfopen: number[];
const funkhihatopen: number[];
const funkhihatopentip: number[];
const funkhihatfoot: number[];
const funkcrash: number[];
const funkcrashtip: number[];
const funkride: number[];
const chronoperc1finalsample: number[];
const synthkickfmsample: number[];
const woodclicksample: number[];
const acousticsnaresample: number[];
const catpaintboxsample: number[];
const gameboypaintboxsample: number[];
const mariopaintboxsample: number[];
const drumpaintboxsample: number[];
const yoshipaintboxsample: number[];
const starpaintboxsample: number[];
const fireflowerpaintboxsample: number[];
const dogpaintbox: number[];
const oinkpaintbox: number[];
const swanpaintboxsample: number[];
const facepaintboxsample: number[];
}
function loadScript(url: string): Promise<void> {
const result: Promise<void> = new Promise((resolve, reject) => {
if (!Config.willReloadForCustomSamples) {
const script = document.createElement("script");
script.src = url;
document.head.appendChild(script);
script.addEventListener("load", (event) => {
resolve();
});
} else {
// There's not really any errors that show up if the loading for
// this script is stopped early, but it won't really do anything
// particularly useful either in that case.
}
});
return result;
}
export function loadBuiltInSamples(set: number): void {
const defaultIndex: number = 0;
const defaultIntegratedSamples: Float32Array = Config.chipWaves[defaultIndex].samples;
const defaultSamples: Float32Array = Config.rawRawChipWaves[defaultIndex].samples;
if (set == 0) {
// Create chip waves with the wrong sound.
const chipWaves = [
{ name: "paandorasbox kick", expression: 4.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 },
{ name: "paandorasbox snare", expression: 3.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 },
{ name: "paandorasbox piano1", expression: 3.0, isSampled: true, isPercussion: false, extraSampleDetune: 2 },
{ name: "paandorasbox WOW", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: 0 },
{ name: "paandorasbox overdrive", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -2 },
{ name: "paandorasbox trumpet", expression: 3.0, isSampled: true, isPercussion: false, extraSampleDetune: 1.2 },
{ name: "paandorasbox saxophone", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -5 },
{ name: "paandorasbox orchestrahit", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: 4.2 },
{ name: "paandorasbox detatched violin", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: 4.2 },
{ name: "paandorasbox synth", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -0.8 },
{ name: "paandorasbox sonic3snare", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 },
{ name: "paandorasbox come on", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: 0 },
{ name: "paandorasbox choir", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -3 },
{ name: "paandorasbox overdriveguitar", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -6.2 },
{ name: "paandorasbox flute", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -6 },
{ name: "paandorasbox legato violin", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -28 },
{ name: "paandorasbox tremolo violin", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -33 },
{ name: "paandorasbox amen break", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -55 },
{ name: "paandorasbox pizzicato violin", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -11 },
{ name: "paandorasbox tim allen grunt", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -20 },
{ name: "paandorasbox tuba", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: 44 },
{ name: "paandorasbox loopingcymbal", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -17 },
{ name: "paandorasbox standardkick", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: -7 },
{ name: "paandorasbox standardsnare", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 },
{ name: "paandorasbox closedhihat", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: 5 },
{ name: "paandorasbox foothihat", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: 4 },
{ name: "paandorasbox openhihat", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: -31 },
{ name: "paandorasbox crashcymbal", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: -43 },
{ name: "paandorasbox pianoC4", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -42.5 },
{ name: "paandorasbox liver pad", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -22.5 },
{ name: "paandorasbox marimba", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -15.5 },
{ name: "paandorasbox susdotwav", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -24.5 },
{ name: "paandorasbox wackyboxtts", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -17.5 },
{ name: "paandorasbox peppersteak_1", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -42.2 },
{ name: "paandorasbox peppersteak_2", expression: 2.0, isSampled: true, isPercussion: false, extraSampleDetune: -47 },
{ name: "paandorasbox vinyl_noise", expression: 2.0, isSampled: true, isPercussion: true, extraSampleDetune: -50 },
{ name: "paandorasbeta slap bass", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -56 },
{ name: "paandorasbeta HD EB overdrive guitar", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -60 },
{ name: "paandorasbeta sunsoft bass", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -18.5 },
{ name: "paandorasbeta masculine choir", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -50 },
{ name: "paandorasbeta feminine choir", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -60.5 },
{ name: "paandorasbeta tololoche", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -29.5 },
{ name: "paandorasbeta harp", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -54 },
{ name: "paandorasbeta pan flute", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -58 },
{ name: "paandorasbeta krumhorn", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -46 },
{ name: "paandorasbeta timpani", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -50 },
{ name: "paandorasbeta crowd hey", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -29 },
{ name: "paandorasbeta wario land 4 brass", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -68 },
{ name: "paandorasbeta wario land 4 rock organ", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -63 },
{ name: "paandorasbeta wario land 4 DAOW", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -35 },
{ name: "paandorasbeta wario land 4 hour chime", expression: 1.0, isSampled: true, isPercussion: false, extraSampleDetune: -47.5 },
{ name: "paandorasbeta wario land 4 tick", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -12.5 },
{ name: "paandorasbeta kirby kick", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -46.5 },
{ name: "paandorasbeta kirby snare", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -46.5 },
{ name: "paandorasbeta kirby bongo", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -46.5 },
{ name: "paandorasbeta kirby click", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -46.5 },
{ name: "paandorasbeta sonor kick", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -28.5 },
{ name: "paandorasbeta sonor snare", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -28.5 },
{ name: "paandorasbeta sonor snare (left hand)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -22.5 },
{ name: "paandorasbeta sonor snare (right hand)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -22.5 },
{ name: "paandorasbeta sonor high tom", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -41.5 },
{ name: "paandorasbeta sonor low tom", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -41.5 },
{ name: "paandorasbeta sonor hihat (closed)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -17 },
{ name: "paandorasbeta sonor hihat (half opened)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -21 },
{ name: "paandorasbeta sonor hihat (open)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -54.5 },
{ name: "paandorasbeta sonor hihat (open tip)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -43.5 },
{ name: "paandorasbeta sonor hihat (pedal)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -28 },
{ name: "paandorasbeta sonor crash", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -51 },
{ name: "paandorasbeta sonor crash (tip)", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -50.5 },
{ name: "paandorasbeta sonor ride", expression: 1.0, isSampled: true, isPercussion: true, extraSampleDetune: -46 }
];
sampleLoadingState.totalSamples += chipWaves.length;
// This assumes that Config.rawRawChipWaves and Config.chipWaves have
// the same number of elements.
const startIndex: number = Config.rawRawChipWaves.length;
for (const chipWave of chipWaves) {
const chipWaveIndex: number = Config.rawRawChipWaves.length;
const rawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const rawRawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const integratedChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultIntegratedSamples };
Config.rawRawChipWaves[chipWaveIndex] = rawRawChipWave;
Config.rawRawChipWaves.dictionary[chipWave.name] = rawRawChipWave;
Config.rawChipWaves[chipWaveIndex] = rawChipWave;
Config.rawChipWaves.dictionary[chipWave.name] = rawChipWave;
Config.chipWaves[chipWaveIndex] = integratedChipWave;
Config.chipWaves.dictionary[chipWave.name] = rawChipWave;
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loading;
sampleLoadingState.urlTable[chipWaveIndex] = "legacySamples";
}
loadScript("samples.js")
.then(() => loadScript("samples2.js"))
.then(() => loadScript("samples3.js"))
.then(() => loadScript("drumsamples.js"))
.then(() => loadScript("wario_samples.js"))
.then(() => loadScript("kirby_samples.js"))
.then(() => {
// Now put the right sounds in there after everything
// got loaded.
const chipWaveSamples: Float32Array[] = [
centerWave(kicksample),
centerWave(snaresample),
centerWave(pianosample),
centerWave(WOWsample),
centerWave(overdrivesample),
centerWave(trumpetsample),
centerWave(saxophonesample),
centerWave(orchhitsample),
centerWave(detatchedviolinsample),
centerWave(synthsample),
centerWave(sonic3snaresample),
centerWave(comeonsample),
centerWave(choirsample),
centerWave(overdrivensample),
centerWave(flutesample),
centerWave(legatoviolinsample),
centerWave(tremoloviolinsample),
centerWave(amenbreaksample),
centerWave(pizzicatoviolinsample),
centerWave(timallengruntsample),
centerWave(tubasample),
centerWave(loopingcymbalsample),
centerWave(kickdrumsample),
centerWave(snaredrumsample),
centerWave(closedhihatsample),
centerWave(foothihatsample),
centerWave(openhihatsample),
centerWave(crashsample),
centerWave(pianoC4sample),
centerWave(liverpadsample),
centerWave(marimbasample),
centerWave(susdotwavsample),
centerWave(wackyboxttssample),
centerWave(peppersteak1),
centerWave(peppersteak2),
centerWave(vinyl),
centerWave(slapbass),
centerWave(hdeboverdrive),
centerWave(sunsoftbass),
centerWave(masculinechoir),
centerWave(femininechoir),
centerWave(southtololoche),
centerWave(harp),
centerWave(panflute),
centerWave(krumhorn),
centerWave(timpani),
centerWave(crowdhey),
centerWave(warioland4brass),
centerWave(warioland4organ),
centerWave(warioland4daow),
centerWave(warioland4hourchime),
centerWave(warioland4tick),
centerWave(kirbykick),
centerWave(kirbysnare),
centerWave(kirbybongo),
centerWave(kirbyclick),
centerWave(funkkick),
centerWave(funksnare),
centerWave(funksnareleft),
centerWave(funksnareright),
centerWave(funktomhigh),
centerWave(funktomlow),
centerWave(funkhihatclosed),
centerWave(funkhihathalfopen),
centerWave(funkhihatopen),
centerWave(funkhihatopentip),
centerWave(funkhihatfoot),
centerWave(funkcrash),
centerWave(funkcrashtip),
centerWave(funkride)
];
let chipWaveIndexOffset: number = 0;
for (const chipWaveSample of chipWaveSamples) {
const chipWaveIndex: number = startIndex + chipWaveIndexOffset;
Config.rawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.rawRawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.chipWaves[chipWaveIndex].samples = performIntegral(chipWaveSample);
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loaded;
sampleLoadingState.samplesLoaded++;
sampleLoadEvents.dispatchEvent(new SampleLoadedEvent(
sampleLoadingState.totalSamples,
sampleLoadingState.samplesLoaded
));
chipWaveIndexOffset++;
}
});
//EditorConfig.presetCategories[EditorConfig.presetCategories.length] = {name: "Legacy Sample Presets", presets: { name: "Earthbound O. Guitar", midiProgram: 80, settings: { "type": "chip", "eqFilter": [], "effects": [], "transition": "normal", "fadeInSeconds": 0, "fadeOutTicks": -1, "chord": "arpeggio", "wave": "paandorasbox overdrive", "unison": "none", "envelopes": [] } }, index: EditorConfig.presetCategories.length,};
}
else if (set == 1) {
// Create chip waves with the wrong sound.
const chipWaves = [
{ name: "chronoperc1final", expression: 4.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 },
{ name: "synthkickfm", expression: 4.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 },
{ name: "mcwoodclick1", expression: 4.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 },
{ name: "acoustic snare", expression: 4.0, isSampled: true, isPercussion: true, extraSampleDetune: 0 }
];
sampleLoadingState.totalSamples += chipWaves.length;
// This assumes that Config.rawRawChipWaves and Config.chipWaves have
// the same number of elements.
const startIndex: number = Config.rawRawChipWaves.length;
for (const chipWave of chipWaves) {
const chipWaveIndex: number = Config.rawRawChipWaves.length;
const rawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const rawRawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const integratedChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultIntegratedSamples };
Config.rawRawChipWaves[chipWaveIndex] = rawRawChipWave;
Config.rawRawChipWaves.dictionary[chipWave.name] = rawRawChipWave;
Config.rawChipWaves[chipWaveIndex] = rawChipWave;
Config.rawChipWaves.dictionary[chipWave.name] = rawChipWave;
Config.chipWaves[chipWaveIndex] = integratedChipWave;
Config.chipWaves.dictionary[chipWave.name] = rawChipWave;
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loading;
sampleLoadingState.urlTable[chipWaveIndex] = "nintariboxSamples";
}
loadScript("nintaribox_samples.js")
.then(() => {
// Now put the right sounds in there after everything
// got loaded.
const chipWaveSamples: Float32Array[] = [
centerWave(chronoperc1finalsample),
centerWave(synthkickfmsample),
centerWave(woodclicksample),
centerWave(acousticsnaresample)
];
let chipWaveIndexOffset: number = 0;
for (const chipWaveSample of chipWaveSamples) {
const chipWaveIndex: number = startIndex + chipWaveIndexOffset;
Config.rawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.rawRawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.chipWaves[chipWaveIndex].samples = performIntegral(chipWaveSample);
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loaded;
sampleLoadingState.samplesLoaded++;
sampleLoadEvents.dispatchEvent(new SampleLoadedEvent(
sampleLoadingState.totalSamples,
sampleLoadingState.samplesLoaded
));
chipWaveIndexOffset++;
}
});
}
else if (set == 2) {
// Create chip waves with the wrong sound.
const chipWaves = [
{ name: "cat", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: -3 },
{ name: "gameboy", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: 7 },
{ name: "mario", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: 0 },
{ name: "drum", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: 4 },
{ name: "yoshi", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: -16 },
{ name: "star", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: -16 },
{ name: "fire flower", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: -1 },
{ name: "dog", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: -1 },
{ name: "oink", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: 3 },
{ name: "swan", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: 1 },
{ name: "face", expression: 1, isSampled: true, isPercussion: false, extraSampleDetune: -12 }
];
sampleLoadingState.totalSamples += chipWaves.length;
// This assumes that Config.rawRawChipWaves and Config.chipWaves have
// the same number of elements.
const startIndex: number = Config.rawRawChipWaves.length;
for (const chipWave of chipWaves) {
const chipWaveIndex: number = Config.rawRawChipWaves.length;
const rawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const rawRawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const integratedChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultIntegratedSamples };
Config.rawRawChipWaves[chipWaveIndex] = rawRawChipWave;
Config.rawRawChipWaves.dictionary[chipWave.name] = rawRawChipWave;
Config.rawChipWaves[chipWaveIndex] = rawChipWave;
Config.rawChipWaves.dictionary[chipWave.name] = rawChipWave;
Config.chipWaves[chipWaveIndex] = integratedChipWave;
Config.chipWaves.dictionary[chipWave.name] = rawChipWave;
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loading;
sampleLoadingState.urlTable[chipWaveIndex] = "marioPaintboxSamples";
}
loadScript("mario_paintbox_samples.js")
.then(() => {
// Now put the right sounds in there after everything
// got loaded.
const chipWaveSamples: Float32Array[] = [
centerWave(catpaintboxsample),
centerWave(gameboypaintboxsample),
centerWave(mariopaintboxsample),
centerWave(drumpaintboxsample),
centerWave(yoshipaintboxsample),
centerWave(starpaintboxsample),
centerWave(fireflowerpaintboxsample),
centerWave(dogpaintbox),
centerWave(oinkpaintbox),
centerWave(swanpaintboxsample),
centerWave(facepaintboxsample)
];
let chipWaveIndexOffset: number = 0;
for (const chipWaveSample of chipWaveSamples) {
const chipWaveIndex: number = startIndex + chipWaveIndexOffset;
Config.rawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.rawRawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.chipWaves[chipWaveIndex].samples = performIntegral(chipWaveSample);
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loaded;
sampleLoadingState.samplesLoaded++;
sampleLoadEvents.dispatchEvent(new SampleLoadedEvent(
sampleLoadingState.totalSamples,
sampleLoadingState.samplesLoaded
));
chipWaveIndexOffset++;
}
});
}
else {
console.log("invalid set of built-in samples");
}
}
export class Config {
// Params for post-processing compressor
public static thresholdVal: number = -10;
public static kneeVal: number = 40;
public static ratioVal: number = 12;
public static attackVal: number = 0;
public static releaseVal: number = 0.25;
public static willReloadForCustomSamples: boolean = false;
public static jsonFormat: string = "slarmoosbox";
// public static thurmboxImportUrl: string = "https://file.garden/ZMQ0Om5nmTe-x2hq/PandoraArchive%20Samples/";
public static readonly scales: DictionaryArray<Scale> = toNameMap([
// C Db D Eb E F F# G Ab A Bb B C
{ name: "Free", realName: "chromatic", flags: [true, true, true, true, true, true, true, true, true, true, true, true] }, // Free
{ name: "Major", realName: "ionian", flags: [true, false, true, false, true, true, false, true, false, true, false, true] }, // Major
{ name: "Minor", realName: "aeolian", flags: [true, false, true, true, false, true, false, true, true, false, true, false] }, // Minor
{ name: "Mixolydian", realName: "mixolydian", flags: [true, false, true, false, true, true, false, true, false, true, true, false] }, // Mixolydian
{ name: "Lydian", realName: "lydian", flags: [true, false, true, false, true, false, true, true, false, true, false, true] }, // Lydian
{ name: "Dorian", realName: "dorian", flags: [true, false, true, true, false, true, false, true, false, true, true, false] }, // Dorian
{ name: "Phrygian", realName: "phrygian", flags: [true, true, false, true, false, true, false, true, true, false, true, false] }, // Phrygian
{ name: "Locrian", realName: "locrian", flags: [true, true, false, true, false, true, true, false, true, false, true, false] }, // Locrian
{ name: "Lydian Dominant", realName: "lydian dominant", flags: [true, false, true, false, true, false, true, true, false, true, true, false] }, // Lydian Dominant
{ name: "Phrygian Dominant", realName: "phrygian dominant", flags: [true, true, false, false, true, true, false, true, true, false, true, false] }, // Phrygian Dominant
{ name: "Harmonic Major", realName: "harmonic major", flags: [true, false, true, false, true, true, false, true, true, false, false, true] }, // Harmonic Major
{ name: "Harmonic Minor", realName: "harmonic minor", flags: [true, false, true, true, false, true, false, true, true, false, false, true] }, // Harmonic Minor
{ name: "Melodic Minor", realName: "melodic minor", flags: [true, false, true, true, false, true, false, true, false, true, false, true] }, // Melodic Minor
{ name: "Blues", realName: "blues major", flags: [true, false, true, true, true,false, false, true, false, true, false, false] }, // Blues Major
{ name: "Blues Minor", realName: "blues", flags: [true, false, false, true, false, true, true, true, false, false, true, false] }, // Blues
{ name: "Altered", realName: "altered", flags: [true, true, false, true, true, false, true, false, true, false, true, false] }, // Altered
{ name: "Pentatonic Major", realName: "major pentatonic", flags: [true, false, true, false, true, false, false, true, false, true, false, false] }, // Major Pentatonic
{ name: "Pentatonic Minor", realName: "minor pentatonic", flags: [true, false, false, true, false, true, false, true, false, false, true, false] }, // Minor Pentatonic
{ name: "Whole Tone", realName: "whole tone", flags: [true, false, true, false, true, false, true, false, true, false, true, false] }, // Whole Tone
{ name: "Octatonic", realName: "octatonic", flags: [true, false, true, true, false, true, true, false, true, true, false, true] }, // Octatonic
{ name: "Hexatonic", realName: "hexatonic", flags: [true, false, false, true, true, false, false, true, true, false, false, true] }, // Hexatonic
// TODO: remove these with 2.3
// modbox
{ name: "No Dabbing (MB)", realName: "no dabbing", flags:[true, true, false, true, true, true, true, true, true, false, true, false] },
// todbox
{ name: "Jacked Toad (TB)", realName: "jacked toad", flags: [true, false, true, true, false, true, true, true, true, false, true, true] },
{ name: "Test Scale (TB)", realName: "**t", flags: [true, true, false, false, false, true, true, false, false, true, true, false] },
// JukeBox
{ name: "Test Scale (TB)", realName: "**t", flags: [true, true, false, false, false, true, true, false, false, true, true, false] },
// crashes, but not because of the lack of a root note
// { name: "Empty", realName: "empty", flags: [false, false, false, false, false, false, false, false, false, false, false, false] }, // Custom? considering allowing this one to be be completely configurable
{ name: "Custom", realName: "custom", flags: [true, false, false, true, false, false, false, false, false, true, true, false] }, // Custom? considering allowing this one to be be completely configurable
]);
public static readonly keys: DictionaryArray<Key> = toNameMap([
{ name: "C", isWhiteKey: true, basePitch: 12 }, // C0 has index 12 on the MIDI scale. C7 is 96, and C9 is 120. C10 is barely in the audible range.
{ name: "C♯", isWhiteKey: false, basePitch: 13 },
{ name: "D", isWhiteKey: true, basePitch: 14 },
{ name: "D♯", isWhiteKey: false, basePitch: 15 },
{ name: "E", isWhiteKey: true, basePitch: 16 },
{ name: "F", isWhiteKey: true, basePitch: 17 },
{ name: "F♯", isWhiteKey: false, basePitch: 18 },
{ name: "G", isWhiteKey: true, basePitch: 19 },
{ name: "G♯", isWhiteKey: false, basePitch: 20 },
{ name: "A", isWhiteKey: true, basePitch: 21 },
{ name: "A♯", isWhiteKey: false, basePitch: 22 },
{ name: "B", isWhiteKey: true, basePitch: 23 },
// { name: "C+", isWhiteKey: false, basePitch: 24 },
//taken from todbox, called "B#" for some reason lol
// { name: "G- (actually F#-)", isWhiteKey: false, basePitch: 6 },
// { name: "C-", isWhiteKey: true, basePitch: 0 },
//brucebox
//g- isn't actually g-???
// { name: "oh no (F-)", isWhiteKey: true, basePitch: 5 },
//shitbox
]);
public static readonly blackKeyNameParents: ReadonlyArray<number> = [-1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1];
public static readonly tempoMin: number = 1;
public static readonly tempoMax: number = 2000; //slarmoo 500
public static readonly octaveMin: number = -8; //slarmoo -2
public static readonly octaveMax: number = 8; //slarmoo 2
public static readonly echoDelayRange: number = 24;
public static readonly echoDelayStepTicks: number = 4;
public static readonly echoSustainRange: number = 8;
public static readonly echoShelfHz: number = 4000.0; // The cutoff freq of the shelf filter that is used to decay echoes.
public static readonly echoShelfGain: number = Math.pow(2.0, -0.5);
public static readonly reverbShelfHz: number = 8000.0; // The cutoff freq of the shelf filter that is used to decay reverb.
public static readonly reverbShelfGain: number = Math.pow(2.0, -1.5);
public static readonly reverbRange: number = 32;
public static readonly reverbDelayBufferSize: number = 16384; // TODO: Compute a buffer size based on sample rate.
public static readonly reverbDelayBufferMask: number = Config.reverbDelayBufferSize - 1; // TODO: Compute a buffer size based on sample rate.
public static readonly phaserMixRange: number = 32;
public static readonly phaserFeedbackRange: number = 32;
public static readonly phaserFreqRange: number = 32;
public static readonly phaserMinFreq: number = 8.0;
public static readonly phaserMaxFreq: number = 20000.0;
public static readonly phaserMinStages: number = 0;
public static readonly phaserMaxStages: number = 32;
public static readonly beatsPerBarMin: number = 1;
public static readonly beatsPerBarMax: number = 64;
public static readonly barCountMin: number = 1;
public static readonly barCountMax: number = 4096; //slarmoo: 1024
public static readonly instrumentCountMin: number = 1;
public static readonly layeredInstrumentCountMax: number = 10;
public static readonly patternInstrumentCountMax: number = 10;
public static readonly partsPerBeat: number = 24;
public static readonly ticksPerPart: number = 2;
public static readonly ticksPerArpeggio: number = 3;
public static readonly arpeggioPatterns: ReadonlyArray<ReadonlyArray<number>> = [[0], [0, 1], [0, 1, 2, 1], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7] ];
public static readonly rhythms: DictionaryArray<Rhythm> = toNameMap([
// ÷1, ÷2, ÷16, and ÷48 are taken from DinoBox
// { name: "÷1", stepsPerBeat: 1, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 0, 1, 1], [0, 1, 2, 1]],*/ roundUpThresholds: null},
// { name: "÷2", stepsPerBeat: 2, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 0, 1, 1], [0, 1, 2, 1]],*/ roundUpThresholds: null},
{ name: "÷3 (triplets)", stepsPerBeat: 3, /*ticksPerArpeggio: 4, arpeggioPatterns: [[0], [0, 0, 1, 1], [0, 1, 2, 1], [0, 1, 2, 3]]*/ roundUpThresholds: [/*0*/ 5, /*8*/ 12, /*16*/ 18 /*24*/] },
{ name: "÷4 (standard)", stepsPerBeat: 4, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 0, 1, 1], [0, 1, 2, 1], [0, 1, 2, 3]]*/ roundUpThresholds: [/*0*/ 3, /*6*/ 9, /*12*/ 17, /*18*/ 21 /*24*/] },
{ name: "÷6", stepsPerBeat: 6, /*ticksPerArpeggio: 4, arpeggioPatterns: [[0], [0, 1], [0, 1, 2, 1], [0, 1, 2, 3]]*/ roundUpThresholds: null },
{ name: "÷8", stepsPerBeat: 8, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 1], [0, 1, 2, 1], [0, 1, 2, 3]]*/ roundUpThresholds: null },
{ name: "÷12", stepsPerBeat: 12, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 1], [0, 1, 2, 1]]*/ roundUpThresholds: null },
// { name: "÷16", stepsPerBeat: 16, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 1], [0, 1, 2, 1]],*/ roundUpThresholds: null},
{ name: "freehand (÷24)", stepsPerBeat: 24, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 1], [0, 1, 2, 1], [0, 1, 2, 3]]*/ roundUpThresholds: null },
// { name: "absolute freedom (÷48)",stepsPerBeat: 48, /*ticksPerArpeggio: 3, arpeggioPatterns: [[0], [0, 1],[0, 1, 2, 1]],*/ roundUpThresholds: null},
]);
public static readonly instrumentTypeNames: ReadonlyArray<string> = ["chip", "FM", "noise", "spectrum", "drumset", "harmonics", "PWM", "Picked String", "supersaw", "custom chip", "mod", "FM6op"];
public static readonly instrumentTypeHasSpecialInterval: ReadonlyArray<boolean> = [true, true, false, false, false, true, false, false, false, false, false];
public static readonly chipBaseExpression: number = 0.03375; // Doubled by unison feature, but affected by expression adjustments per unison setting and wave shape. Custom chip is multiplied by 0.05 in instrumentState.updateWaves
public static readonly fmBaseExpression: number = 0.03;