forked from jummbus/jummbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSongEditor.ts
More file actions
4183 lines (3749 loc) · 241 KB
/
SongEditor.ts
File metadata and controls
4183 lines (3749 loc) · 241 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, distributed under the MIT license, see accompanying the LICENSE.md file.
//import {Layout} from "./Layout";
import { InstrumentType, EffectType, Config, effectsIncludeTransition, effectsIncludeChord, effectsIncludePitchShift, effectsIncludeDetune, effectsIncludeVibrato, effectsIncludeNoteFilter, effectsIncludeDistortion, effectsIncludeBitcrusher, effectsIncludePanning, effectsIncludeChorus, effectsIncludeEcho, effectsIncludeReverb, DropdownID } from "../synth/SynthConfig";
import { BarScrollBar } from "./BarScrollBar";
import { BeatsPerBarPrompt } from "./BeatsPerBarPrompt";
import { Change, ChangeGroup } from "./Change";
import { ChannelSettingsPrompt } from "./ChannelSettingsPrompt";
import { ColorConfig, ChannelColors } from "./ColorConfig";
import { CustomChipPrompt } from "./CustomChipPrompt";
import { CustomFilterPrompt } from "./CustomFilterPrompt";
import { EditorConfig, isMobile, prettyNumber, Preset, PresetCategory } from "./EditorConfig";
import { ExportPrompt } from "./ExportPrompt";
import "./Layout"; // Imported here for the sake of ensuring this code is transpiled early.
import { Instrument, Channel, Synth } from "../synth/synth";
import { HTML, SVG } from "imperative-html/dist/esm/elements-strict";
import { Preferences } from "./Preferences";
import { HarmonicsEditor } from "./HarmonicsEditor";
import { InputBox, Slider } from "./HTMLWrapper";
import { ImportPrompt } from "./ImportPrompt";
import { ChannelRow } from "./ChannelRow";
import { LayoutPrompt } from "./LayoutPrompt";
import { EnvelopeEditor } from "./EnvelopeEditor";
import { FadeInOutEditor } from "./FadeInOutEditor";
import { FilterEditor } from "./FilterEditor";
import { LimiterPrompt } from "./LimiterPrompt";
import { LoopEditor } from "./LoopEditor";
import { MoveNotesSidewaysPrompt } from "./MoveNotesSidewaysPrompt";
import { MuteEditor } from "./MuteEditor";
import { OctaveScrollBar } from "./OctaveScrollBar";
import { MidiInputHandler } from "./MidiInput";
import { KeyboardLayout } from "./KeyboardLayout";
import { PatternEditor } from "./PatternEditor";
import { Piano } from "./Piano";
import { Prompt } from "./Prompt";
import { SongDocument } from "./SongDocument";
import { SongDurationPrompt } from "./SongDurationPrompt";
import { SustainPrompt } from "./SustainPrompt";
import { SongRecoveryPrompt } from "./SongRecoveryPrompt";
import { RecordingSetupPrompt } from "./RecordingSetupPrompt";
import { SpectrumEditor } from "./SpectrumEditor";
import { ThemePrompt } from "./ThemePrompt";
import { TipPrompt } from "./TipPrompt";
import { ChangeTempo, ChangeChorus, ChangeEchoDelay, ChangeEchoSustain, ChangeReverb, ChangeVolume, ChangePan, ChangePatternSelection, ChangePatternsPerChannel, ChangePatternNumbers, ChangeSupersawDynamism, ChangeSupersawSpread, ChangeSupersawShape, ChangePulseWidth, ChangeFeedbackAmplitude, ChangeOperatorAmplitude, ChangeOperatorFrequency, ChangeDrumsetEnvelope, ChangePasteInstrument, ChangePreset, pickRandomPresetValue, ChangeRandomGeneratedInstrument, ChangeEQFilterType, ChangeNoteFilterType, ChangeEQFilterSimpleCut, ChangeEQFilterSimplePeak, ChangeNoteFilterSimpleCut, ChangeNoteFilterSimplePeak, ChangeScale, ChangeKey, ChangeRhythm, ChangeFeedbackType, ChangeAlgorithm, ChangeChipWave, ChangeNoiseWave, ChangeTransition, ChangeToggleEffects, ChangeVibrato, ChangeUnison, ChangeChord, ChangeSong, ChangePitchShift, ChangeDetune, ChangeDistortion, ChangeStringSustain, ChangeBitcrusherFreq, ChangeBitcrusherQuantization, ChangeAddEnvelope, ChangeEnvelopeSpeed, ChangeDiscreteEnvelope, ChangeAddChannelInstrument, ChangeRemoveChannelInstrument, ChangeCustomWave, ChangeOperatorWaveform, ChangeOperatorPulseWidth, ChangeSongTitle, ChangeVibratoDepth, ChangeVibratoSpeed, ChangeVibratoDelay, ChangeVibratoType, ChangePanDelay, ChangeArpeggioSpeed, ChangeFastTwoNoteArp, ChangeClicklessTransition, ChangeAliasing, ChangeSetPatternInstruments, ChangeHoldingModRecording } from "./changes";
import { TrackEditor } from "./TrackEditor";
const { button, div, input, select, span, optgroup, option, canvas } = HTML;
function buildOptions(menu: HTMLSelectElement, items: ReadonlyArray<string | number>): HTMLSelectElement {
for (let index: number = 0; index < items.length; index++) {
menu.appendChild(option({ value: index }, items[index]));
}
return menu;
}
// Similar to the above, but adds a non-interactive header to the list.
// @jummbus: Honestly not necessary with new HTML options interface, but not exactly necessary to change either!
function buildHeaderedOptions(header: string, menu: HTMLSelectElement, items: ReadonlyArray<string | number>): HTMLSelectElement {
menu.appendChild(option({ selected: true, disabled: true, value: header }, header));
for (const item of items) {
menu.appendChild(option({ value: item }, item));
}
return menu;
}
function buildPresetOptions(isNoise: boolean, idSet: string): HTMLSelectElement {
const menu: HTMLSelectElement = select({ id: idSet });
// Show the "spectrum" custom type in both pitched and noise channels.
//const customTypeGroup: HTMLElement = optgroup({label: EditorConfig.presetCategories[0].name});
if (isNoise) {
menu.appendChild(option({ value: InstrumentType.noise }, EditorConfig.valueToPreset(InstrumentType.noise)!.name));
menu.appendChild(option({ value: InstrumentType.spectrum }, EditorConfig.valueToPreset(InstrumentType.spectrum)!.name));
menu.appendChild(option({ value: InstrumentType.drumset }, EditorConfig.valueToPreset(InstrumentType.drumset)!.name));
} else {
menu.appendChild(option({ value: InstrumentType.chip }, EditorConfig.valueToPreset(InstrumentType.chip)!.name));
menu.appendChild(option({ value: InstrumentType.pwm }, EditorConfig.valueToPreset(InstrumentType.pwm)!.name));
menu.appendChild(option({ value: InstrumentType.supersaw}, EditorConfig.valueToPreset(InstrumentType.supersaw)!.name));
menu.appendChild(option({ value: InstrumentType.harmonics }, EditorConfig.valueToPreset(InstrumentType.harmonics)!.name));
menu.appendChild(option({ value: InstrumentType.pickedString }, EditorConfig.valueToPreset(InstrumentType.pickedString)!.name));
menu.appendChild(option({ value: InstrumentType.spectrum }, EditorConfig.valueToPreset(InstrumentType.spectrum)!.name));
menu.appendChild(option({ value: InstrumentType.fm }, EditorConfig.valueToPreset(InstrumentType.fm)!.name));
menu.appendChild(option({ value: InstrumentType.customChipWave }, EditorConfig.valueToPreset(InstrumentType.customChipWave)!.name));
}
const randomGroup: HTMLElement = optgroup({ label: "Randomize ▾" });
randomGroup.appendChild(option({ value: "randomPreset" }, "Random Preset"));
randomGroup.appendChild(option({ value: "randomGenerated" }, "Random Generated"));
menu.appendChild(randomGroup);
for (let categoryIndex: number = 1; categoryIndex < EditorConfig.presetCategories.length; categoryIndex++) {
const category: PresetCategory = EditorConfig.presetCategories[categoryIndex];
const group: HTMLElement = optgroup({ label: category.name + " ▾" });
let foundAny: boolean = false;
for (let presetIndex: number = 0; presetIndex < category.presets.length; presetIndex++) {
const preset: Preset = category.presets[presetIndex];
if ((preset.isNoise == true) == isNoise) {
group.appendChild(option({ value: (categoryIndex << 6) + presetIndex }, preset.name));
foundAny = true;
}
}
// Need to re-sort some elements for readability. Can't just do this in the menu, because indices are saved in URLs and would get broken if the ordering actually changed.
if (category.name == "String Presets" && foundAny) {
// Put violin 2 after violin 1
let moveViolin2 = group.removeChild(group.children[11]);
group.insertBefore(moveViolin2, group.children[1]);
}
if (category.name == "Flute Presets" && foundAny) {
// Put flute 2 after flute 1
let moveFlute2 = group.removeChild(group.children[11]);
group.insertBefore(moveFlute2, group.children[1]);
}
if (category.name == "Keyboard Presets" && foundAny) {
// Put grand piano 2 and 3 after grand piano 1
let moveGrandPiano2 = group.removeChild(group.children[9]);
let moveGrandPiano3 = group.removeChild(group.children[9]);
group.insertBefore(moveGrandPiano3, group.children[1]);
group.insertBefore(moveGrandPiano2, group.children[1]);
}
if (foundAny) menu.appendChild(group);
}
return menu;
}
function setSelectedValue(menu: HTMLSelectElement, value: number, isSelect2: boolean = false): void {
const stringValue = value.toString();
if (menu.value != stringValue) {
menu.value = stringValue;
// Change select2 value, if this select is a member of that class.
if (isSelect2) {
$(menu).val(value).trigger('change.select2');
}
}
}
class CustomChipCanvas {
private mouseDown: boolean;
private continuousEdit: boolean;
private lastX: number;
private lastY: number;
public newArray: Float32Array;
public renderedArray: Float32Array;
public renderedColor: string;
private _change: Change | null = null;
constructor(public readonly canvas: HTMLCanvasElement, private readonly _doc: SongDocument, private readonly _getChange: (newArray: Float32Array) => Change) {
canvas.addEventListener("mousemove", this._onMouseMove);
canvas.addEventListener("mousedown", this._onMouseDown);
canvas.addEventListener("mouseup", this._onMouseUp);
canvas.addEventListener("mouseleave", this._onMouseUp);
this.mouseDown = false;
this.continuousEdit = false;
this.lastX = 0;
this.lastY = 0;
this.newArray = new Float32Array(64);
this.renderedArray = new Float32Array(64);
this.renderedColor = "";
// Init waveform
this.redrawCanvas();
}
public redrawCanvas(): void {
const chipData: Float32Array = this._doc.song.channels[this._doc.channel].instruments[this._doc.getCurrentInstrument()].customChipWave;
const renderColor: string = ColorConfig.getComputedChannelColor(this._doc.song, this._doc.channel).primaryNote;
// Check if the data has changed from the last render.
let needsRedraw: boolean = false;
if (renderColor != this.renderedColor) {
needsRedraw = true;
} else for (let i: number = 0; i < 64; i++) {
if (chipData[i] != this.renderedArray[i]) {
needsRedraw = true;
i = 64;
}
}
if (!needsRedraw) {
return;
}
this.renderedArray.set(chipData);
var ctx = this.canvas.getContext("2d") as CanvasRenderingContext2D;
// Black BG
ctx.fillStyle = ColorConfig.getComputed("--editor-background");
ctx.fillRect(0, 0, 128, 52);
// Mid-bar
ctx.fillStyle = ColorConfig.getComputed("--ui-widget-background");
ctx.fillRect(0, 25, 128, 2);
// 25-75 bars
ctx.fillStyle = ColorConfig.getComputed("--track-editor-bg-pitch-dim");
ctx.fillRect(0, 13, 128, 1);
ctx.fillRect(0, 39, 128, 1);
// Waveform
ctx.fillStyle = renderColor;
for (let x: number = 0; x < 64; x++) {
var y: number = chipData[x] + 26;
ctx.fillRect(x * 2, y - 2, 2, 4);
this.newArray[x] = y - 26;
}
}
private _onMouseMove = (event: MouseEvent): void => {
if (this.mouseDown) {
var x = (event.clientX || event.pageX) - this.canvas.getBoundingClientRect().left;
var y = Math.floor((event.clientY || event.pageY) - this.canvas.getBoundingClientRect().top);
if (y < 2) y = 2;
if (y > 50) y = 50;
var ctx = this.canvas.getContext("2d") as CanvasRenderingContext2D;
if (this.continuousEdit == true && Math.abs(this.lastX - x) < 40) {
var lowerBound = (x < this.lastX) ? x : this.lastX;
var upperBound = (x < this.lastX) ? this.lastX : x;
for (let i = lowerBound; i <= upperBound; i += 2) {
var progress = (Math.abs(x - this.lastX) > 2.0) ? ((x > this.lastX) ?
1.0 - ((i - lowerBound) / (upperBound - lowerBound))
: ((i - lowerBound) / (upperBound - lowerBound))) : 0.0;
var j = Math.round(y + (this.lastY - y) * progress);
ctx.fillStyle = ColorConfig.getComputed("--editor-background");
ctx.fillRect(Math.floor(i / 2) * 2, 0, 2, 53);
ctx.fillStyle = ColorConfig.getComputed("--ui-widget-background");
ctx.fillRect(Math.floor(i / 2) * 2, 25, 2, 2);
ctx.fillStyle = ColorConfig.getComputed("--track-editor-bg-pitch-dim");
ctx.fillRect(Math.floor(i / 2) * 2, 13, 2, 1);
ctx.fillRect(Math.floor(i / 2) * 2, 39, 2, 1);
ctx.fillStyle = ColorConfig.getComputedChannelColor(this._doc.song, this._doc.channel).primaryNote;
ctx.fillRect(Math.floor(i / 2) * 2, j - 2, 2, 4);
// Actually update current instrument's custom waveform
this.newArray[Math.floor(i / 2)] = (j - 26);
}
}
else {
ctx.fillStyle = ColorConfig.getComputed("--editor-background");
ctx.fillRect(Math.floor(x / 2) * 2, 0, 2, 52);
ctx.fillStyle = ColorConfig.getComputed("--ui-widget-background");
ctx.fillRect(Math.floor(x / 2) * 2, 25, 2, 2);
ctx.fillStyle = ColorConfig.getComputed("--track-editor-bg-pitch-dim");
ctx.fillRect(Math.floor(x / 2) * 2, 13, 2, 1);
ctx.fillRect(Math.floor(x / 2) * 2, 39, 2, 1);
ctx.fillStyle = ColorConfig.getComputedChannelColor(this._doc.song, this._doc.channel).primaryNote;
ctx.fillRect(Math.floor(x / 2) * 2, y - 2, 2, 4);
// Actually update current instrument's custom waveform
this.newArray[Math.floor(x / 2)] = (y - 26);
}
this.continuousEdit = true;
this.lastX = x;
this.lastY = y;
// Preview - update integral used for sound synthesis based on new array, not actual stored array. When mouse is released, real update will happen.
let instrument: Instrument = this._doc.song.channels[this._doc.channel].instruments[this._doc.getCurrentInstrument()];
let sum: number = 0.0;
for (let i: number = 0; i < this.newArray.length; i++) {
sum += this.newArray[i];
}
const average: number = sum / this.newArray.length;
// Perform the integral on the wave. The chipSynth will perform the derivative to get the original wave back but with antialiasing.
let cumulative: number = 0;
let wavePrev: number = 0;
for (let i: number = 0; i < this.newArray.length; i++) {
cumulative += wavePrev;
wavePrev = this.newArray[i] - average;
instrument.customChipWaveIntegral[i] = cumulative;
}
instrument.customChipWaveIntegral[64] = 0.0;
}
}
private _onMouseDown = (event: MouseEvent): void => {
this.mouseDown = true;
// Allow single-click edit
this._onMouseMove(event);
}
private _onMouseUp = (): void => {
this.mouseDown = false;
this.continuousEdit = false;
this._whenChange();
}
private _whenChange = (): void => {
this._change = this._getChange(this.newArray);
this._doc.record(this._change!);
this._change = null;
};
}
export class SongEditor {
public prompt: Prompt | null = null;
private readonly _keyboardLayout: KeyboardLayout = new KeyboardLayout(this._doc);
private readonly _patternEditorPrev: PatternEditor = new PatternEditor(this._doc, false, -1);
private readonly _patternEditor: PatternEditor = new PatternEditor(this._doc, true, 0);
private readonly _patternEditorNext: PatternEditor = new PatternEditor(this._doc, false, 1);
private readonly _trackEditor: TrackEditor = new TrackEditor(this._doc, this);
private readonly _muteEditor: MuteEditor = new MuteEditor(this._doc, this);
private readonly _loopEditor: LoopEditor = new LoopEditor(this._doc, this._trackEditor);
private readonly _piano: Piano = new Piano(this._doc);
private readonly _octaveScrollBar: OctaveScrollBar = new OctaveScrollBar(this._doc, this._piano);
private readonly _playButton: HTMLButtonElement = button({ class: "playButton", type: "button", title: "Play (Space)" }, span("Play"));
private readonly _pauseButton: HTMLButtonElement = button({ class: "pauseButton", style: "display: none;", type: "button", title: "Pause (Space)" }, "Pause");
private readonly _recordButton: HTMLButtonElement = button({ class: "recordButton", style: "display: none;", type: "button", title: "Record (Ctrl+Space)" }, span("Record"));
private readonly _stopButton: HTMLButtonElement = button({ class: "stopButton", style: "display: none;", type: "button", title: "Stop Recording (Space)" }, "Stop Recording");
private readonly _prevBarButton: HTMLButtonElement = button({ class: "prevBarButton", type: "button", title: "Previous Bar (left bracket)" });
private readonly _nextBarButton: HTMLButtonElement = button({ class: "nextBarButton", type: "button", title: "Next Bar (right bracket)" });
private readonly _volumeSlider: Slider = new Slider(input({ title: "main volume", style: "width: 5em; flex-grow: 1; margin: 0;", type: "range", min: "0", max: "75", value: "50", step: "1" }), this._doc, null, false);
private readonly _outVolumeBarBg: SVGRectElement = SVG.rect({ "pointer-events": "none", width: "90%", height: "50%", x: "5%", y: "25%", fill: ColorConfig.uiWidgetBackground });
private readonly _outVolumeBar: SVGRectElement = SVG.rect({ "pointer-events": "none", height: "50%", width: "0%", x: "5%", y: "25%", fill: "url('#volumeGrad2')" });
private readonly _outVolumeCap: SVGRectElement = SVG.rect({ "pointer-events": "none", width: "2px", height: "50%", x: "5%", y: "25%", fill: ColorConfig.uiWidgetFocus });
private readonly _stop1: SVGStopElement = SVG.stop({ "stop-color": "lime", offset: "60%" });
private readonly _stop2: SVGStopElement = SVG.stop({ "stop-color": "orange", offset: "90%" });
private readonly _stop3: SVGStopElement = SVG.stop({ "stop-color": "red", offset: "100%" });
private readonly _gradient: SVGGradientElement = SVG.linearGradient({ id: "volumeGrad2", gradientUnits: "userSpaceOnUse" }, this._stop1, this._stop2, this._stop3);
private readonly _defs: SVGDefsElement = SVG.defs({}, this._gradient);
private readonly _volumeBarContainer: SVGSVGElement = SVG.svg({ style: `touch-action: none; overflow: visible; margin: auto; max-width: 20vw;`, width: "160px", height: "100%", preserveAspectRatio: "none", viewBox: "0 0 160 12" },
this._defs,
this._outVolumeBarBg,
this._outVolumeBar,
this._outVolumeCap,
);
private readonly _volumeBarBox: HTMLDivElement = div({ class: "playback-volume-bar", style: "height: 12px; align-self: center;" },
this._volumeBarContainer,
);
private readonly _fileMenu: HTMLSelectElement = select({ style: "width: 100%;" },
option({ selected: true, disabled: true, hidden: false }, "File"), // todo: "hidden" should be true but looks wrong on mac chrome, adds checkmark next to first visible option even though it's not selected. :(
option({ value: "new" }, "+ New Blank Song"),
option({ value: "import" }, "↑ Import Song... (" + EditorConfig.ctrlSymbol + "O)"),
option({ value: "export" }, "↓ Export Song... (" + EditorConfig.ctrlSymbol + "S)"),
option({ value: "copyUrl" }, "⎘ Copy Song URL"),
option({ value: "shareUrl" }, "⤳ Share Song URL"),
option({ value: "shortenUrl" }, "… Shorten Song URL"),
option({ value: "viewPlayer" }, "▶ View in Song Player"),
option({ value: "copyEmbed" }, "⎘ Copy HTML Embed Code"),
option({ value: "songRecovery" }, "⚠ Recover Recent Song..."),
);
private readonly _editMenu: HTMLSelectElement = select({ style: "width: 100%;" },
option({ selected: true, disabled: true, hidden: false }, "Edit"), // todo: "hidden" should be true but looks wrong on mac chrome, adds checkmark next to first visible option even though it's not selected. :(
option({ value: "undo" }, "Undo (Z)"),
option({ value: "redo" }, "Redo (Y)"),
option({ value: "copy" }, "Copy Pattern (C)"),
option({ value: "pasteNotes" }, "Paste Pattern Notes (V)"),
option({ value: "pasteNumbers" }, "Paste Pattern Numbers (" + EditorConfig.ctrlSymbol + "⇧V)"),
option({ value: "insertBars" }, "Insert Bar (⏎)"),
option({ value: "deleteBars" }, "Delete Selected Bars (⌫)"),
option({ value: "insertChannel" }, "Insert Channel (" + EditorConfig.ctrlSymbol + "⏎)"),
option({ value: "deleteChannel" }, "Delete Selected Channels (" + EditorConfig.ctrlSymbol + "⌫)"),
option({ value: "selectChannel" }, "Select Channel (⇧A)"),
option({ value: "selectAll" }, "Select All (A)"),
option({ value: "duplicatePatterns" }, "Duplicate Reused Patterns (D)"),
option({ value: "transposeUp" }, "Move Notes Up (+ or ⇧+)"),
option({ value: "transposeDown" }, "Move Notes Down (- or ⇧-)"),
option({ value: "moveNotesSideways" }, "Move All Notes Sideways... (W)"),
option({ value: "beatsPerBar" }, "Change Beats Per Bar..."),
option({ value: "barCount" }, "Change Song Length... (L)"),
option({ value: "channelSettings" }, "Channel Settings... (Q)"),
option({ value: "limiterSettings" }, "Limiter Settings... (⇧L)"),
);
private readonly _optionsMenu: HTMLSelectElement = select({ style: "width: 100%;" },
option({ selected: true, disabled: true, hidden: false }, "Preferences"), // todo: "hidden" should be true but looks wrong on mac chrome, adds checkmark next to first visible option even though it's not selected. :(
option({ value: "autoPlay" }, "Auto Play on Load"),
option({ value: "autoFollow" }, "Auto Follow Playhead"),
option({ value: "enableNotePreview" }, "Hear Added Notes"),
option({ value: "showLetters" }, "Show Piano Keys"),
option({ value: "showFifth" }, 'Highlight "Fifth" Note'),
option({ value: "notesOutsideScale" }, "Place Notes Out of Scale"),
option({ value: "setDefaultScale" }, "Set Current Scale as Default"),
option({ value: "showChannels" }, "Show All Channels"),
option({ value: "showScrollBar" }, "Show Octave Scroll Bar"),
option({ value: "alwaysFineNoteVol" }, "Always Fine Note Volume"),
option({ value: "enableChannelMuting" }, "Enable Channel Muting"),
option({ value: "displayBrowserUrl" }, "Show Song Data in URL"),
option({ value: "displayVolumeBar" }, "Show Playback Volume"),
option({ value: "layout" }, "Set Layout..."),
option({ value: "colorTheme" }, "Set Theme..."),
option({ value: "recordingSetup" }, "Note Recording..."),
);
private readonly _scaleSelect: HTMLSelectElement = buildOptions(select(), Config.scales.map(scale => scale.name));
private readonly _keySelect: HTMLSelectElement = buildOptions(select(), Config.keys.map(key => key.name).reverse());
private readonly _tempoSlider: Slider = new Slider(input({ style: "margin: 0; vertical-align: middle;", type: "range", min: "30", max: "320", value: "160", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeTempo(this._doc, oldValue, newValue), false);
private readonly _tempoStepper: HTMLInputElement = input({ style: "width: 4em; font-size: 80%; margin-left: 0.4em; vertical-align: middle;", type: "number", step: "1" });
private readonly _chorusSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.chorusRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeChorus(this._doc, oldValue, newValue), false);
private readonly _chorusRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("chorus") }, "Chorus:"), this._chorusSlider.container);
private readonly _reverbSlider: Slider = new Slider(input({ style: "margin: 0; position: sticky,", type: "range", min: "0", max: Config.reverbRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeReverb(this._doc, oldValue, newValue), false);
private readonly _reverbRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("reverb") }, "Reverb:"), this._reverbSlider.container);
private readonly _echoSustainSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.echoSustainRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeEchoSustain(this._doc, oldValue, newValue), false);
private readonly _echoSustainRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("echoSustain") }, "Echo:"), this._echoSustainSlider.container);
private readonly _echoDelaySlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.echoDelayRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeEchoDelay(this._doc, oldValue, newValue), false);
private readonly _echoDelayRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("echoDelay") }, "Echo Delay:"), this._echoDelaySlider.container);
private readonly _rhythmSelect: HTMLSelectElement = buildOptions(select(), Config.rhythms.map(rhythm => rhythm.name));
private readonly _pitchedPresetSelect: HTMLSelectElement = buildPresetOptions(false, "pitchPresetSelect");
private readonly _drumPresetSelect: HTMLSelectElement = buildPresetOptions(true, "drumPresetSelect");
private readonly _algorithmSelect: HTMLSelectElement = buildOptions(select(), Config.algorithms.map(algorithm => algorithm.name));
private readonly _algorithmSelectRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("algorithm") }, "Algorithm: "), div({ class: "selectContainer" }, this._algorithmSelect));
private readonly _instrumentButtons: HTMLButtonElement[] = [];
private readonly _instrumentAddButton: HTMLButtonElement = button({ type: "button", class: "add-instrument last-button" });
private readonly _instrumentRemoveButton: HTMLButtonElement = button({ type: "button", class: "remove-instrument" });
private readonly _instrumentsButtonBar: HTMLDivElement = div({ class: "instrument-bar" }, this._instrumentRemoveButton, this._instrumentAddButton);
private readonly _instrumentsButtonRow: HTMLDivElement = div({ class: "selectRow", style: "display: none;" }, span({ class: "tip", onclick: () => this._openPrompt("instrumentIndex") }, "Instrument:"), this._instrumentsButtonBar);
private readonly _instrumentVolumeSlider: Slider = new Slider(input({ style: "margin: 0; position: sticky;", type: "range", min: Math.floor(-Config.volumeRange / 2), max: Math.floor(Config.volumeRange / 2), value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeVolume(this._doc, oldValue, newValue), true);
private readonly _instrumentVolumeSliderInputBox: HTMLInputElement = input({ style: "width: 4em; font-size: 80%", id: "volumeSliderInputBox", type: "number", step: "1", min: Math.floor(-Config.volumeRange / 2), max: Math.floor(Config.volumeRange / 2), value: "0" });
private readonly _instrumentVolumeSliderTip: HTMLDivElement = div({ class: "selectRow", style: "height: 1em" }, span({ class: "tip", style: "font-size: smaller;", onclick: () => this._openPrompt("instrumentVolume") }, "Volume: "));
private readonly _instrumentVolumeSliderRow: HTMLDivElement = div({ class: "selectRow" }, div({},
div({ style: `color: ${ColorConfig.secondaryText};` }, span({ class: "tip" }, this._instrumentVolumeSliderTip)),
div({ style: `color: ${ColorConfig.secondaryText}; margin-top: -3px;` }, this._instrumentVolumeSliderInputBox),
), this._instrumentVolumeSlider.container);
private readonly _panSlider: Slider = new Slider(input({ style: "margin: 0; position: sticky;", type: "range", min: "0", max: Config.panMax, value: Config.panCenter, step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangePan(this._doc, oldValue, newValue), true);
private readonly _panDropdown: HTMLButtonElement = button({ style: "margin-left:0em; height:1.5em; width: 10px; padding: 0px; font-size: 8px;", onclick: () => this._toggleDropdownMenu(DropdownID.Pan) }, "▼");
private readonly _panSliderInputBox: HTMLInputElement = input({ style: "width: 4em; font-size: 80%; ", id: "panSliderInputBox", type: "number", step: "1", min: "0", max: "100", value: "0" });
private readonly _panSliderRow: HTMLDivElement = div({ class: "selectRow" }, div({},
span({ class: "tip", tabindex: "0", style: "height:1em; font-size: smaller;", onclick: () => this._openPrompt("pan") }, "Pan: "),
div({ style: "color: " + ColorConfig.secondaryText + "; margin-top: -3px;" }, this._panSliderInputBox),
), this._panDropdown, this._panSlider.container);
private readonly _panDelaySlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.modulators.dictionary["pan delay"].maxRawVol, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangePanDelay(this._doc, oldValue, newValue), false);
private readonly _panDelayRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("panDelay") }, "‣ Delay:"), this._panDelaySlider.container);
private readonly _panDropdownGroup: HTMLElement = div({ class: "editor-controls", style: "display: none;" }, this._panDelayRow);
private readonly _chipWaveSelect: HTMLSelectElement = buildOptions(select(), Config.chipWaves.map(wave => wave.name));
private readonly _chipNoiseSelect: HTMLSelectElement = buildOptions(select(), Config.chipNoises.map(wave => wave.name));
private readonly _chipWaveSelectRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("chipWave") }, "Wave: "), div({ class: "selectContainer" }, this._chipWaveSelect));
private readonly _chipNoiseSelectRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("chipNoise") }, "Noise: "), div({ class: "selectContainer" }, this._chipNoiseSelect));
private readonly _fadeInOutEditor: FadeInOutEditor = new FadeInOutEditor(this._doc);
private readonly _fadeInOutRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("fadeInOut") }, "Fade:"), this._fadeInOutEditor.container);
private readonly _transitionSelect: HTMLSelectElement = buildOptions(select(), Config.transitions.map(transition => transition.name));
private readonly _transitionDropdown: HTMLButtonElement = button({ style: "margin-left:0em; height:1.5em; width: 10px; padding: 0px; font-size: 8px;", onclick: () => this._toggleDropdownMenu(DropdownID.Transition) }, "▼");
private readonly _transitionRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("transition") }, "Transition:"), this._transitionDropdown, div({ class: "selectContainer", style: "width: 52.5%;" }, this._transitionSelect));
private readonly _clicklessTransitionBox: HTMLInputElement = input({ type: "checkbox", style: "width: 1em; padding: 0; margin-right: 4em;" });
private readonly _clicklessTransitionRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("clicklessTransition") }, "‣ Clickless:"), this._clicklessTransitionBox);
private readonly _transitionDropdownGroup: HTMLElement = div({ class: "editor-controls", style: "display: none;" }, this._clicklessTransitionRow);
private readonly _effectsSelect: HTMLSelectElement = select(option({ selected: true, disabled: true, hidden: false })); // todo: "hidden" should be true but looks wrong on mac chrome, adds checkmark next to first visible option even though it's not selected. :(
private readonly _eqFilterSimpleButton: HTMLButtonElement = button({ style: "font-size: x-small; width: 50%; height: 40%", class: "no-underline", onclick: () => this._switchEQFilterType(true) }, "simple");
private readonly _eqFilterAdvancedButton: HTMLButtonElement = button({ style: "font-size: x-small; width: 50%; height: 40%", class: "last-button no-underline", onclick: () => this._switchEQFilterType(false) }, "advanced");
private readonly _eqFilterTypeRow: HTMLElement = div({ class: "selectRow", style: "padding-top: 4px; margin-bottom: 0px;" }, span({ style: "font-size: x-small;", class: "tip", onclick: () => this._openPrompt("filterType") }, "EQ Filt.Type:"), div({ class: "instrument-bar" }, this._eqFilterSimpleButton, this._eqFilterAdvancedButton));
private readonly _eqFilterEditor: FilterEditor = new FilterEditor(this._doc);
private readonly _eqFilterZoom: HTMLButtonElement = button({ style: "margin-left:0em; padding-left:0.2em; height:1.5em; max-width: 12px;", onclick: () => this._openPrompt("customEQFilterSettings") }, "+");
private readonly _eqFilterRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("eqFilter") }, "EQ Filt:"), this._eqFilterZoom, this._eqFilterEditor.container);
private readonly _eqFilterSimpleCutSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.filterSimpleCutRange - 1, value: "6", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeEQFilterSimpleCut(this._doc, oldValue, newValue), false);
private _eqFilterSimpleCutRow: HTMLDivElement = div({ class: "selectRow", title: "Low-pass Filter Cutoff Frequency" }, span({ class: "tip", onclick: () => this._openPrompt("filterCutoff") }, "Filter Cut:"), this._eqFilterSimpleCutSlider.container);
private readonly _eqFilterSimplePeakSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.filterSimplePeakRange - 1, value: "6", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeEQFilterSimplePeak(this._doc, oldValue, newValue), false);
private _eqFilterSimplePeakRow: HTMLDivElement = div({ class: "selectRow", title: "Low-pass Filter Peak Resonance" }, span({ class: "tip", onclick: () => this._openPrompt("filterResonance") }, "Filter Peak:"), this._eqFilterSimplePeakSlider.container);
private readonly _noteFilterSimpleButton: HTMLButtonElement = button({ style: "font-size: x-small; width: 50%; height: 40%", class: "no-underline", onclick: () => this._switchNoteFilterType(true) }, "simple");
private readonly _noteFilterAdvancedButton: HTMLButtonElement = button({ style: "font-size: x-small; width: 50%; height: 40%", class: "last-button no-underline", onclick: () => this._switchNoteFilterType(false) }, "advanced");
private readonly _noteFilterTypeRow: HTMLElement = div({ class: "selectRow", style: "padding-top: 4px; margin-bottom: 0px;" }, span({ style: "font-size: x-small;", class: "tip", onclick: () => this._openPrompt("filterType") }, "Note Filt.Type:"), div({ class: "instrument-bar" }, this._noteFilterSimpleButton, this._noteFilterAdvancedButton));
private readonly _noteFilterEditor: FilterEditor = new FilterEditor(this._doc, true);
private readonly _noteFilterZoom: HTMLButtonElement = button({ style: "margin-left:0em; padding-left:0.2em; height:1.5em; max-width: 12px;", onclick: () => this._openPrompt("customNoteFilterSettings") }, "+");
private readonly _noteFilterRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("noteFilter") }, "Note Filt:"), this._noteFilterZoom, this._noteFilterEditor.container);
private readonly _supersawDynamismSlider: Slider = new Slider(input({style: "margin: 0;", type: "range", min: "0", max: Config.supersawDynamismMax, value: "0", step: "1"}), this._doc, (oldValue: number, newValue: number) => new ChangeSupersawDynamism(this._doc, oldValue, newValue), false);
private readonly _supersawDynamismRow: HTMLDivElement = div({class: "selectRow"}, span({class: "tip", onclick: ()=>this._openPrompt("supersawDynamism")}, "Dynamism:"), this._supersawDynamismSlider.container);
private readonly _supersawSpreadSlider: Slider = new Slider(input({style: "margin: 0;", type: "range", min: "0", max: Config.supersawSpreadMax, value: "0", step: "1"}), this._doc, (oldValue: number, newValue: number) => new ChangeSupersawSpread(this._doc, oldValue, newValue), false);
private readonly _supersawSpreadRow: HTMLDivElement = div({class: "selectRow"}, span({class: "tip", onclick: ()=>this._openPrompt("supersawSpread")}, "Spread:"), this._supersawSpreadSlider.container);
private readonly _supersawShapeSlider: Slider = new Slider(input({style: "margin: 0;", type: "range", min: "0", max: Config.supersawShapeMax, value: "0", step: "1"}), this._doc, (oldValue: number, newValue: number) => new ChangeSupersawShape(this._doc, oldValue, newValue), false);
private readonly _supersawShapeRow: HTMLDivElement = div({class: "selectRow"}, span({class: "tip", onclick: ()=>this._openPrompt("supersawShape"), style: "overflow: clip;"}, "Saw↔Pulse:"), this._supersawShapeSlider.container);
private readonly _noteFilterSimpleCutSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.filterSimpleCutRange - 1, value: "6", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeNoteFilterSimpleCut(this._doc, oldValue, newValue), false);
private _noteFilterSimpleCutRow: HTMLDivElement = div({ class: "selectRow", title: "Low-pass Filter Cutoff Frequency" }, span({ class: "tip", onclick: () => this._openPrompt("filterCutoff") }, "Filter Cut:"), this._noteFilterSimpleCutSlider.container);
private readonly _noteFilterSimplePeakSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.filterSimplePeakRange - 1, value: "6", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeNoteFilterSimplePeak(this._doc, oldValue, newValue), false);
private _noteFilterSimplePeakRow: HTMLDivElement = div({ class: "selectRow", title: "Low-pass Filter Peak Resonance" }, span({ class: "tip", onclick: () => this._openPrompt("filterResonance") }, "Filter Peak:"), this._noteFilterSimplePeakSlider.container);
private readonly _pulseWidthSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "1", max: Config.pulseWidthRange, value: "1", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangePulseWidth(this._doc, oldValue, newValue), false);
private readonly _pwmSliderInputBox: HTMLInputElement = input({ style: "width: 4em; font-size: 80%; ", id: "pwmSliderInputBox", type: "number", step: "1", min: "1", max: Config.pulseWidthRange, value: "1" });
private readonly _pulseWidthRow: HTMLDivElement = div({ class: "selectRow" }, div({},
span({ class: "tip", tabindex: "0", style: "height:1em; font-size: smaller;", onclick: () => this._openPrompt("pulseWidth") }, "PulseWidth:"),
div({ style: `color: ${ColorConfig.secondaryText}; margin-top: -3px;` }, this._pwmSliderInputBox)
), this._pulseWidthSlider.container);
private readonly _pitchShiftSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.pitchShiftRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangePitchShift(this._doc, oldValue, newValue), true);
private readonly _pitchShiftTonicMarkers: HTMLDivElement[] = [div({ class: "pitchShiftMarker", style: { color: ColorConfig.tonic } }), div({ class: "pitchShiftMarker", style: { color: ColorConfig.tonic, left: "50%" } }), div({ class: "pitchShiftMarker", style: { color: ColorConfig.tonic, left: "100%" } })];
private readonly _pitchShiftFifthMarkers: HTMLDivElement[] = [div({ class: "pitchShiftMarker", style: { color: ColorConfig.fifthNote, left: (100 * 7 / 24) + "%" } }), div({ class: "pitchShiftMarker", style: { color: ColorConfig.fifthNote, left: (100 * 19 / 24) + "%" } })];
private readonly _pitchShiftMarkerContainer: HTMLDivElement = div({ style: "display: flex; position: relative;" }, this._pitchShiftSlider.container, div({ class: "pitchShiftMarkerContainer" }, this._pitchShiftTonicMarkers, this._pitchShiftFifthMarkers));
private readonly _pitchShiftRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("pitchShift") }, "Pitch Shift:"), this._pitchShiftMarkerContainer);
private readonly _detuneSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: Config.detuneMin - Config.detuneCenter, max: Config.detuneMax - Config.detuneCenter, value: 0, step: "4" }), this._doc, (oldValue: number, newValue: number) => new ChangeDetune(this._doc, oldValue, newValue), true);
private readonly _detuneSliderInputBox: HTMLInputElement = input({ style: "width: 4em; font-size: 80%; ", id: "detuneSliderInputBox", type: "number", step: "1", min: Config.detuneMin - Config.detuneCenter, max: Config.detuneMax - Config.detuneCenter, value: 0 });
private readonly _detuneSliderRow: HTMLDivElement = div({ class: "selectRow" }, div({},
span({ class: "tip", style: "height:1em; font-size: smaller;", onclick: () => this._openPrompt("detune") }, "Detune: "),
div({ style: `color: ${ColorConfig.secondaryText}; margin-top: -3px;` }, this._detuneSliderInputBox),
), this._detuneSlider.container);
private readonly _distortionSlider: Slider = new Slider(input({ style: "margin: 0; position: sticky;", type: "range", min: "0", max: Config.distortionRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeDistortion(this._doc, oldValue, newValue), false);
private readonly _distortionRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("distortion") }, "Distortion:"), this._distortionSlider.container);
private readonly _aliasingBox: HTMLInputElement = input({ type: "checkbox", style: "width: 1em; padding: 0; margin-right: 4em;" });
private readonly _aliasingRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", style: "margin-left:10px;", onclick: () => this._openPrompt("aliases") }, "Aliasing:"), this._aliasingBox);
private readonly _bitcrusherQuantizationSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.bitcrusherQuantizationRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeBitcrusherQuantization(this._doc, oldValue, newValue), false);
private readonly _bitcrusherQuantizationRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("bitcrusherQuantization") }, "Bit Crush:"), this._bitcrusherQuantizationSlider.container);
private readonly _bitcrusherFreqSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.bitcrusherFreqRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeBitcrusherFreq(this._doc, oldValue, newValue), false);
private readonly _bitcrusherFreqRow: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("bitcrusherFreq") }, "Freq Crush:"), this._bitcrusherFreqSlider.container);
private readonly _stringSustainSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.stringSustainRange - 1, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeStringSustain(this._doc, oldValue, newValue), false);
private readonly _stringSustainLabel: HTMLSpanElement = span({class: "tip", onclick: ()=>this._openPrompt("stringSustain")}, "Sustain:");
private readonly _stringSustainRow: HTMLDivElement = div({class: "selectRow"}, this._stringSustainLabel, this._stringSustainSlider.container);
private readonly _unisonSelect: HTMLSelectElement = buildOptions(select(), Config.unisons.map(unison => unison.name));
private readonly _unisonSelectRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("unison") }, "Unison:"), div({ class: "selectContainer" }, this._unisonSelect));
private readonly _chordSelect: HTMLSelectElement = buildOptions(select(), Config.chords.map(chord => chord.name));
private readonly _chordDropdown: HTMLButtonElement = button({ style: "margin-left:0em; height:1.5em; width: 10px; padding: 0px; font-size: 8px;", onclick: () => this._toggleDropdownMenu(DropdownID.Chord) }, "▼");
private readonly _chordSelectRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("chords") }, "Chords:"), this._chordDropdown, div({ class: "selectContainer" }, this._chordSelect));
private readonly _arpeggioSpeedDisplay: HTMLSpanElement = span({ style: `color: ${ColorConfig.secondaryText}; font-size: smaller; text-overflow: clip;` }, "x1");
private readonly _arpeggioSpeedSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.modulators.dictionary["arp speed"].maxRawVol, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeArpeggioSpeed(this._doc, oldValue, newValue), false);
private readonly _arpeggioSpeedRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("arpeggioSpeed") }, "‣ Spd:"), this._arpeggioSpeedDisplay, this._arpeggioSpeedSlider.container);
private readonly _twoNoteArpBox: HTMLInputElement = input({ type: "checkbox", style: "width: 1em; padding: 0; margin-right: 4em;" });
private readonly _twoNoteArpRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("twoNoteArpeggio") }, "‣ Fast Two-Note:"), this._twoNoteArpBox);
private readonly _chordDropdownGroup: HTMLElement = div({ class: "editor-controls", style: "display: none;" }, this._arpeggioSpeedRow, this._twoNoteArpRow);
private readonly _vibratoSelect: HTMLSelectElement = buildOptions(select(), Config.vibratos.map(vibrato => vibrato.name));
private readonly _vibratoDropdown: HTMLButtonElement = button({ style: "margin-left:0em; height:1.5em; width: 10px; padding: 0px; font-size: 8px;", onclick: () => this._toggleDropdownMenu(DropdownID.Vibrato) }, "▼");
private readonly _vibratoSelectRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("vibrato") }, "Vibrato:"), this._vibratoDropdown, div({ class: "selectContainer", style: "width: 61.5%;" }, this._vibratoSelect));
private readonly _vibratoDepthSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.modulators.dictionary["vibrato depth"].maxRawVol, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeVibratoDepth(this._doc, oldValue, newValue), false);
private readonly _vibratoDepthRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("vibratoDepth") }, "‣ Depth:"), this._vibratoDepthSlider.container);
private readonly _vibratoSpeedDisplay: HTMLSpanElement = span({ style: `color: ${ColorConfig.secondaryText}; font-size: smaller; text-overflow: clip;` }, "x1");
private readonly _vibratoSpeedSlider: Slider = new Slider(input({ style: "margin: 0; text-overflow: clip;", type: "range", min: "0", max: Config.modulators.dictionary["vibrato speed"].maxRawVol, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeVibratoSpeed(this._doc, oldValue, newValue), false);
private readonly _vibratoSpeedRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("vibratoSpeed") }, "‣ Spd:"), this._vibratoSpeedDisplay, this._vibratoSpeedSlider.container);
private readonly _vibratoDelaySlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.modulators.dictionary["vibrato delay"].maxRawVol, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeVibratoDelay(this._doc, oldValue, newValue), false);
private readonly _vibratoDelayRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("vibratoDelay") }, "‣ Delay:"), this._vibratoDelaySlider.container);
private readonly _vibratoTypeSelect: HTMLSelectElement = buildOptions(select(), Config.vibratoTypes.map(vibrato => vibrato.name));
private readonly _vibratoTypeSelectRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("vibratoType") }, "‣ Type:"), div({ class: "selectContainer", style: "width: 61.5%;" }, this._vibratoTypeSelect));
private readonly _vibratoDropdownGroup: HTMLElement = div({ class: "editor-controls", style: `display: none;` }, this._vibratoDepthRow, this._vibratoSpeedRow, this._vibratoDelayRow, this._vibratoTypeSelectRow);
private readonly _phaseModGroup: HTMLElement = div({ class: "editor-controls" });
private readonly _feedbackTypeSelect: HTMLSelectElement = buildOptions(select(), Config.feedbacks.map(feedback => feedback.name));
private readonly _feedbackRow1: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("feedbackType") }, "Feedback:"), div({ class: "selectContainer" }, this._feedbackTypeSelect));
private readonly _spectrumEditor: SpectrumEditor = new SpectrumEditor(this._doc, null);
private readonly _spectrumRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("spectrum") }, "Spectrum:"), this._spectrumEditor.container);
private readonly _harmonicsEditor: HarmonicsEditor = new HarmonicsEditor(this._doc);
private readonly _harmonicsRow: HTMLElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("harmonics") }, "Harmonics:"), this._harmonicsEditor.container);
private readonly _envelopeEditor: EnvelopeEditor = new EnvelopeEditor(this._doc);
private readonly _discreteEnvelopeBox: HTMLInputElement = input({ type: "checkbox", style: "width: 1em; padding: 0; margin-right: 4em;" });
private readonly _discreteEnvelopeRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("discreteEnvelope") }, "‣ Discrete:"), this._discreteEnvelopeBox);
private readonly _envelopeSpeedDisplay: HTMLSpanElement = span({ style: `color: ${ColorConfig.secondaryText}; font-size: smaller; text-overflow: clip;` }, "x1");
private readonly _envelopeSpeedSlider: Slider = new Slider(input({ style: "margin: 0;", type: "range", min: "0", max: Config.modulators.dictionary["envelope speed"].maxRawVol, value: "0", step: "1" }), this._doc, (oldValue: number, newValue: number) => new ChangeEnvelopeSpeed(this._doc, oldValue, newValue), false);
private readonly _envelopeSpeedRow: HTMLElement = div({ class: "selectRow dropFader" }, span({ class: "tip", style: "margin-left:4px;", onclick: () => this._openPrompt("envelopeSpeed") }, "‣ Spd:"), this._envelopeSpeedDisplay, this._envelopeSpeedSlider.container);
private readonly _envelopeDropdownGroup: HTMLElement = div({ class: "editor-controls", style: "display: none;" }, this._discreteEnvelopeRow, this._envelopeSpeedRow);
private readonly _envelopeDropdown: HTMLButtonElement = button({ style: "margin-left:0em; margin-right: 1em; height:1.5em; width: 10px; padding: 0px; font-size: 8px;", onclick: () => this._toggleDropdownMenu(DropdownID.Envelope) }, "▼");
private readonly _drumsetGroup: HTMLElement = div({ class: "editor-controls" });
private readonly _modulatorGroup: HTMLElement = div({ class: "editor-controls" });
private readonly _modNameRows: HTMLElement[];
private readonly _modChannelBoxes: HTMLSelectElement[];
private readonly _modInstrumentBoxes: HTMLSelectElement[];
private readonly _modSetRows: HTMLElement[];
private readonly _modSetBoxes: HTMLSelectElement[];
private readonly _modFilterRows: HTMLElement[];
private readonly _modFilterBoxes: HTMLSelectElement[];
private readonly _modTargetIndicators: SVGElement[];
private readonly _instrumentCopyButton: HTMLButtonElement = button({ style: "max-width:86px; width: 86px;", class: "copyButton", title: "Copy Instrument (⇧C)" }, [
"Copy",
// Copy icon:
SVG.svg({ style: "flex-shrink: 0; position: absolute; left: 0; top: 50%; margin-top: -1em; pointer-events: none;", width: "2em", height: "2em", viewBox: "-5 -21 26 26" }, [
SVG.path({ d: "M 0 -15 L 1 -15 L 1 0 L 13 0 L 13 1 L 0 1 L 0 -15 z M 2 -1 L 2 -17 L 10 -17 L 14 -13 L 14 -1 z M 3 -2 L 13 -2 L 13 -12 L 9 -12 L 9 -16 L 3 -16 z", fill: "currentColor" }),
]),
]);
private readonly _instrumentPasteButton: HTMLButtonElement = button({ style: "max-width:86px;", class: "pasteButton", title: "Paste Instrument (⇧V)" }, [
"Paste",
// Paste icon:
SVG.svg({ style: "flex-shrink: 0; position: absolute; left: 0; top: 50%; margin-top: -1em; pointer-events: none;", width: "2em", height: "2em", viewBox: "0 0 26 26" }, [
SVG.path({ d: "M 8 18 L 6 18 L 6 5 L 17 5 L 17 7 M 9 8 L 16 8 L 20 12 L 20 22 L 9 22 z", stroke: "currentColor", fill: "none" }),
SVG.path({ d: "M 9 3 L 14 3 L 14 6 L 9 6 L 9 3 z M 16 8 L 20 12 L 16 12 L 16 8 z", fill: "currentColor", }),
]),
]);
private readonly _customWaveDrawCanvas: CustomChipCanvas = new CustomChipCanvas(canvas({ width: 128, height: 52, style: "border:2px solid " + ColorConfig.uiWidgetBackground, id: "customWaveDrawCanvas" }), this._doc, (newArray: Float32Array) => new ChangeCustomWave(this._doc, newArray));
private readonly _customWavePresetDrop: HTMLSelectElement = buildHeaderedOptions("Load Preset", select({ style: "width: 50%; height:1.5em; text-align: center; text-align-last: center;" }),
Config.chipWaves.map(wave => wave.name)
);
private readonly _customWaveZoom: HTMLButtonElement = button({ style: "margin-left:0.5em; height:1.5em; max-width: 20px;", onclick: () => this._openPrompt("customChipSettings") }, "+");
private readonly _customWaveDraw: HTMLDivElement = div({ style: "height:80px; margin-top:10px; margin-bottom:5px" }, [
div({ style: "height:54px; display:flex; justify-content:center;" }, [this._customWaveDrawCanvas.canvas]),
div({ style: "margin-top:5px; display:flex; justify-content:center;" }, [this._customWavePresetDrop, this._customWaveZoom]),
]);
private readonly _songTitleInputBox: InputBox = new InputBox(input({ style: "font-weight:bold; border:none; width: 98%; background-color:${ColorConfig.editorBackground}; color:${ColorConfig.primaryText}; text-align:center", maxlength: "30", type: "text", value: EditorConfig.versionDisplayName }), this._doc, (oldValue: string, newValue: string) => new ChangeSongTitle(this._doc, oldValue, newValue));
private readonly _feedbackAmplitudeSlider: Slider = new Slider(input({ type: "range", min: "0", max: Config.operatorAmplitudeMax, value: "0", step: "1", title: "Feedback Amplitude" }), this._doc, (oldValue: number, newValue: number) => new ChangeFeedbackAmplitude(this._doc, oldValue, newValue), false);
private readonly _feedbackRow2: HTMLDivElement = div({ class: "selectRow" }, span({ class: "tip", onclick: () => this._openPrompt("feedbackVolume") }, "Fdback Vol:"), this._feedbackAmplitudeSlider.container);
/*
* @jummbus - my very real, valid reason for cutting this button: I don't like it.
*
private readonly _customizeInstrumentButton: HTMLButtonElement = button({type: "button", style: "margin: 2px 0"},
"Customize Instrument",
);
*/
private readonly _addEnvelopeButton: HTMLButtonElement = button({ type: "button", class: "add-envelope" });
private readonly _customInstrumentSettingsGroup: HTMLDivElement = div({ class: "editor-controls" },
this._panSliderRow,
this._panDropdownGroup,
this._chipWaveSelectRow,
this._chipNoiseSelectRow,
this._customWaveDraw,
this._eqFilterTypeRow,
this._eqFilterRow,
this._eqFilterSimpleCutRow,
this._eqFilterSimplePeakRow,
this._fadeInOutRow,
this._algorithmSelectRow,
this._phaseModGroup,
this._feedbackRow1,
this._feedbackRow2,
this._spectrumRow,
this._harmonicsRow,
this._drumsetGroup,
this._supersawDynamismRow,
this._supersawSpreadRow,
this._supersawShapeRow,
this._pulseWidthRow,
this._stringSustainRow,
this._unisonSelectRow,
div({ style: `padding: 2px 0; margin-left: 2em; display: flex; align-items: center;` },
span({ style: `flex-grow: 1; text-align: center;` }, span({ class: "tip", onclick: () => this._openPrompt("effects") }, "Effects")),
div({ class: "effects-menu" }, this._effectsSelect),
),
this._transitionRow,
this._transitionDropdownGroup,
this._chordSelectRow,
this._chordDropdownGroup,
this._pitchShiftRow,
this._detuneSliderRow,
this._vibratoSelectRow,
this._vibratoDropdownGroup,
this._noteFilterTypeRow,
this._noteFilterRow,
this._noteFilterSimpleCutRow,
this._noteFilterSimplePeakRow,
this._distortionRow,
this._aliasingRow,
this._bitcrusherQuantizationRow,
this._bitcrusherFreqRow,
this._chorusRow,
this._echoSustainRow,
this._echoDelayRow,
this._reverbRow,
div({ style: `padding: 2px 0; margin-left: 2em; display: flex; align-items: center;` },
span({ style: `flex-grow: 1; text-align: center;` }, span({ class: "tip", onclick: () => this._openPrompt("envelopes") }, "Envelopes")),
this._envelopeDropdown,
this._addEnvelopeButton,
),
this._envelopeDropdownGroup,
this._envelopeEditor.container,
);
private readonly _instrumentCopyGroup: HTMLDivElement = div({ class: "editor-controls" },
div({ class: "selectRow" },
this._instrumentCopyButton,
this._instrumentPasteButton,
),
);
private readonly _instrumentSettingsTextRow: HTMLDivElement = div({ id: "instrumentSettingsText", style: `padding: 3px 0; max-width: 15em; text-align: center; color: ${ColorConfig.secondaryText};` },
"Instrument Settings"
);
private readonly _instrumentTypeSelectRow: HTMLDivElement = div({ class: "selectRow", id: "typeSelectRow" },
span({ class: "tip", onclick: () => this._openPrompt("instrumentType") }, "Type:"),
div(
div({ class: "pitchSelect" }, this._pitchedPresetSelect),
div({ class: "drumSelect" }, this._drumPresetSelect)
),
);
private readonly _instrumentSettingsGroup: HTMLDivElement = div({ class: "editor-controls" },
this._instrumentSettingsTextRow,
this._instrumentsButtonRow,
this._instrumentTypeSelectRow,
this._instrumentVolumeSliderRow,
//this._customizeInstrumentButton,
this._customInstrumentSettingsGroup,
);
private readonly _usedPatternIndicator: SVGElement = SVG.path({ d: "M -6 -6 H 6 V 6 H -6 V -6 M -2 -3 L -2 -3 L -1 -4 H 1 V 4 H -1 V -1.2 L -1.2 -1 H -2 V -3 z", fill: ColorConfig.indicatorSecondary, "fill-rule": "evenodd" });
private readonly _usedInstrumentIndicator: SVGElement = SVG.path({ d: "M -6 -0.8 H -3.8 V -6 H 0.8 V 4.4 H 2.2 V -0.8 H 6 V 0.8 H 3.8 V 6 H -0.8 V -4.4 H -2.2 V 0.8 H -6 z", fill: ColorConfig.indicatorSecondary });
private readonly _jumpToModIndicator: SVGElement = SVG.svg({ style: "width: 92%; height: 1.3em; flex-shrink: 0; position: absolute;", viewBox: "0 0 200 200" }, [
SVG.path({ d: "M90 155 l0 -45 -45 0 c-25 0 -45 -4 -45 -10 0 -5 20 -10 45 -10 l45 0 0 -45 c0 -25 5 -45 10 -45 6 0 10 20 10 45 l0 45 45 0 c25 0 45 5 45 10 0 6 -20 10 -45 10 l -45 0 0 45 c0 25 -4 45 -10 45 -5 0 -10 -20 -10 -45z" }),
SVG.path({ d: "M42 158 c-15 -15 -16 -38 -2 -38 6 0 10 7 10 15 0 8 7 15 15 15 8 0 15 5 15 10 0 14 -23 13 -38 -2z" }),
SVG.path({ d: "M120 160 c0 -5 7 -10 15 -10 8 0 15 -7 15 -15 0 -8 5 -15 10 -15 14 0 13 23 -2 38 -15 15 -38 16 -38 2z" }),
SVG.path({ d: "M32 58 c3 -23 48 -40 48 -19 0 6 -7 11 -15 11 -8 0 -15 7 -15 15 0 8 -5 15 -11 15 -6 0 -9 -10 -7 -22z" }),
SVG.path({ d: "M150 65 c0 -8 -7 -15 -15 -15 -8 0 -15 -4 -15 -10 0 -14 23 -13 38 2 15 15 16 38 2 38 -5 0 -10 -7 -10 -15z" })]);
private readonly _promptContainer: HTMLDivElement = div({ class: "promptContainer", style: "display: none;" });
private readonly _zoomInButton: HTMLButtonElement = button({ class: "zoomInButton", type: "button", title: "Zoom In" });
private readonly _zoomOutButton: HTMLButtonElement = button({ class: "zoomOutButton", type: "button", title: "Zoom Out" });
private readonly _patternEditorRow: HTMLDivElement = div({ style: "flex: 1; height: 100%; display: flex; overflow: hidden; justify-content: center;" },
this._patternEditorPrev.container,
this._patternEditor.container,
this._patternEditorNext.container,
);
private readonly _patternArea: HTMLDivElement = div({ class: "pattern-area" },
this._piano.container,
this._patternEditorRow,
this._octaveScrollBar.container,
this._zoomInButton,
this._zoomOutButton,
);
private readonly _trackContainer: HTMLDivElement = div({ class: "trackContainer" },
this._trackEditor.container,
this._loopEditor.container,
);
private readonly _trackVisibleArea: HTMLDivElement = div({ style: "position: absolute; width: 100%; height: 100%; pointer-events: none;" });
private readonly _trackAndMuteContainer: HTMLDivElement = div({ class: "trackAndMuteContainer" },
this._muteEditor.container,
this._trackContainer,
this._trackVisibleArea,
);
public readonly _barScrollBar: BarScrollBar = new BarScrollBar(this._doc);
private readonly _trackArea: HTMLDivElement = div({ class: "track-area" },
this._trackAndMuteContainer,
this._barScrollBar.container,
);
private readonly _menuArea: HTMLDivElement = div({ class: "menu-area" },
div({ class: "selectContainer menu file" },
this._fileMenu,
),
div({ class: "selectContainer menu edit" },
this._editMenu,
),
div({ class: "selectContainer menu preferences" },
this._optionsMenu,
),
);
private readonly _songSettingsArea: HTMLDivElement = div({ class: "song-settings-area" },
div({ class: "editor-controls" },
div({ class: "editor-song-settings" },
div({ style: "margin: 3px 0; position: relative; text-align: center; color: ${ColorConfig.secondaryText};" },
div({ class: "tip", style: "flex-shrink: 0; position:absolute; left: 0; top: 0; width: 12px; height: 12px", onclick: () => this._openPrompt("usedPattern") },
SVG.svg({ style: "flex-shrink: 0; position: absolute; left: 0; top: 0; pointer-events: none;", width: "12px", height: "12px", "margin-right": "0.5em", viewBox: "-6 -6 12 12" },
this._usedPatternIndicator,
),
),
div({ class: "tip", style: "flex-shrink: 0; position: absolute; left: 14px; top: 0; width: 12px; height: 12px", onclick: () => this._openPrompt("usedInstrument") },
SVG.svg({ style: "flex-shrink: 0; position: absolute; left: 0; top: 0; pointer-events: none;", width: "12px", height: "12px", "margin-right": "1em", viewBox: "-6 -6 12 12" },
this._usedInstrumentIndicator,
),
),
"Song Settings",
div({ style: "width: 100%; left: 0; top: -1px; position:absolute; overflow-x:clip;" }, this._jumpToModIndicator),
),
),
div({ class: "selectRow" },
span({ class: "tip", onclick: () => this._openPrompt("scale") }, "Scale: "),
div({ class: "selectContainer" }, this._scaleSelect),
),
div({ class: "selectRow" },
span({ class: "tip", onclick: () => this._openPrompt("key") }, "Key: "),
div({ class: "selectContainer" }, this._keySelect),
),
div({ class: "selectRow" },
span({ class: "tip", onclick: () => this._openPrompt("tempo") }, "Tempo: "),
span({ style: "display: flex;" },
this._tempoSlider.container,
this._tempoStepper,
),
),
div({ class: "selectRow" },
span({ class: "tip", onclick: () => this._openPrompt("rhythm") }, "Rhythm: "),
div({ class: "selectContainer" }, this._rhythmSelect),
),
),
);
private readonly _instrumentSettingsArea: HTMLDivElement = div({ class: "instrument-settings-area" },
this._instrumentSettingsGroup,
this._modulatorGroup);
public readonly _settingsArea: HTMLDivElement = div({ class: "settings-area noSelection" },
div({ class: "version-area" },
div({ style: `text-align: center; margin: 3px 0; color: ${ColorConfig.secondaryText};` },
this._songTitleInputBox.input,
),
),
div({ class: "play-pause-area" },
this._volumeBarBox,
div({ class: "playback-bar-controls" },
this._playButton,
this._pauseButton,
this._recordButton,
this._stopButton,
this._prevBarButton,
this._nextBarButton,
),
div({ class: "playback-volume-controls" },
span({ class: "volume-speaker" }),
this._volumeSlider.container,
),
),
this._menuArea,
this._songSettingsArea,
this._instrumentSettingsArea,
);
public readonly mainLayer: HTMLDivElement = div({ class: "beepboxEditor", tabIndex: "0" },
this._patternArea,
this._trackArea,
this._settingsArea,
this._promptContainer,
);
private _wasPlaying: boolean = false;
private _currentPromptName: string | null = null;
private _highlightedInstrumentIndex: number = -1;
private _renderedInstrumentCount: number = 0;
private _renderedIsPlaying: boolean = false;
private _renderedIsRecording: boolean = false;
private _renderedShowRecordButton: boolean = false;
private _renderedCtrlHeld: boolean = false;
private _ctrlHeld: boolean = false;
private _shiftHeld: boolean = false;
private _deactivatedInstruments: boolean = false;
private readonly _operatorRows: HTMLDivElement[] = [];
private readonly _operatorAmplitudeSliders: Slider[] = [];
private readonly _operatorFrequencySelects: HTMLSelectElement[] = [];
private readonly _operatorDropdowns: HTMLButtonElement[] = [];
private readonly _operatorWaveformSelects: HTMLSelectElement[] = [];
private readonly _operatorWaveformHints: HTMLSpanElement[] = [];
private readonly _operatorWaveformPulsewidthSliders: Slider[] = [];
private readonly _operatorDropdownRows: HTMLElement[] = []
private readonly _operatorDropdownGroups: HTMLDivElement[] = [];
private readonly _drumsetSpectrumEditors: SpectrumEditor[] = [];
private readonly _drumsetEnvelopeSelects: HTMLSelectElement[] = [];
private _showModSliders: boolean[] = [];
private _newShowModSliders: boolean[] = [];
private _modSliderValues: number[] = [];
private _hasActiveModSliders: boolean = false;
private _openPanDropdown: boolean = false;
private _openVibratoDropdown: boolean = false;
private _openEnvelopeDropdown: boolean = false;
private _openChordDropdown: boolean = false;
private _openTransitionDropdown: boolean = false;
private _openOperatorDropdowns: boolean[] = [];
private outVolumeHistoricTimer: number = 0;
private outVolumeHistoricCap: number = 0;
private lastOutVolumeCap: number = 0;
public patternUsed: boolean = false;
private _modRecTimeout: number = -1;
constructor(private _doc: SongDocument) {
this._doc.notifier.watch(this.whenUpdated);
this._doc.modRecordingHandler = () => { this.handleModRecording() };
new MidiInputHandler(this._doc);
window.addEventListener("resize", this.whenUpdated);
window.requestAnimationFrame(this.updatePlayButton);
window.requestAnimationFrame(this._animate);
if (!("share" in navigator)) {
this._fileMenu.removeChild(this._fileMenu.querySelector("[value='shareUrl']")!);
}
this._scaleSelect.appendChild(optgroup({ label: "Edit" },
option({ value: "forceScale" }, "Snap Notes To Scale"),
));
this._keySelect.appendChild(optgroup({ label: "Edit" },
option({ value: "detectKey" }, "Detect Key"),
));
this._rhythmSelect.appendChild(optgroup({ label: "Edit" },
option({ value: "forceRhythm" }, "Snap Notes To Rhythm"),
));
this._vibratoSelect.appendChild(option({ hidden: true, value: 5 }, "custom"));
this._showModSliders = new Array<boolean>(Config.modulators.length);
this._modSliderValues = new Array<number>(Config.modulators.length);
this._phaseModGroup.appendChild(div({ class: "selectRow", style: `color: ${ColorConfig.secondaryText}; height: 1em; margin-top: 0.5em;` },
div({ style: "margin-right: .1em; visibility: hidden;" }, 1 + "."),
div({ style: "width: 3em; margin-right: .3em;", class: "tip", onclick: () => this._openPrompt("operatorFrequency") }, "Freq:"),
div({ class: "tip", onclick: () => this._openPrompt("operatorVolume") }, "Volume:"),
));
for (let i: number = 0; i < Config.operatorCount; i++) {
const operatorIndex: number = i;
const operatorNumber: HTMLDivElement = div({ style: "margin-right: 0px; color: " + ColorConfig.secondaryText + ";" }, i + 1 + "");
const frequencySelect: HTMLSelectElement = buildOptions(select({ style: "width: 100%;", title: "Frequency" }), Config.operatorFrequencies.map(freq => freq.name));
const amplitudeSlider: Slider = new Slider(input({ type: "range", min: "0", max: Config.operatorAmplitudeMax, value: "0", step: "1", title: "Volume" }), this._doc, (oldValue: number, newValue: number) => new ChangeOperatorAmplitude(this._doc, operatorIndex, oldValue, newValue), false);
const waveformSelect: HTMLSelectElement = buildOptions(select({ style: "width: 100%;", title: "Waveform" }), Config.operatorWaves.map(wave => wave.name));
const waveformDropdown: HTMLButtonElement = button({ style: "margin-left:0em; margin-right: 2px; height:1.5em; width: 8px; max-width: 10px; padding: 0px; font-size: 8px;", onclick: () => this._toggleDropdownMenu(DropdownID.FM, i) }, "▼");
const waveformDropdownHint: HTMLSpanElement = span({ class: "tip", style: "margin-left: 10px;", onclick: () => this._openPrompt("operatorWaveform") }, "Wave:");
const waveformPulsewidthSlider: Slider = new Slider(input({ style: "margin-left: 10px; width: 85%;", type: "range", min: "0", max: Config.pwmOperatorWaves.length - 1, value: "0", step: "1", title: "Pulse Width" }), this._doc, (oldValue: number, newValue: number) => new ChangeOperatorPulseWidth(this._doc, operatorIndex, oldValue, newValue), true);
const waveformDropdownRow: HTMLElement = div({ class: "selectRow" }, waveformDropdownHint, waveformPulsewidthSlider.container,
div({ class: "selectContainer", style: "width: 6em; margin-left: .3em;" }, waveformSelect));
const waveformDropdownGroup: HTMLDivElement = div({ class: "operatorRow" }, waveformDropdownRow);
const row: HTMLDivElement = div({ class: "selectRow" },
operatorNumber,
waveformDropdown,
div({ class: "selectContainer", style: "width: 3em; margin-right: .3em;" }, frequencySelect),
amplitudeSlider.container,
);
this._phaseModGroup.appendChild(row);
this._operatorRows[i] = row;
this._operatorAmplitudeSliders[i] = amplitudeSlider;
this._operatorFrequencySelects[i] = frequencySelect;
this._operatorDropdowns[i] = waveformDropdown;
this._operatorWaveformHints[i] = waveformDropdownHint;
this._operatorWaveformSelects[i] = waveformSelect;
this._operatorWaveformPulsewidthSliders[i] = waveformPulsewidthSlider;
this._operatorDropdownRows[i] = waveformDropdownRow;
this._phaseModGroup.appendChild(waveformDropdownGroup);
this._operatorDropdownGroups[i] = waveformDropdownGroup;
this._openOperatorDropdowns[i] = false;
waveformSelect.addEventListener("change", () => {
this._doc.record(new ChangeOperatorWaveform(this._doc, operatorIndex, waveformSelect.selectedIndex));
});
frequencySelect.addEventListener("change", () => {
this._doc.record(new ChangeOperatorFrequency(this._doc, operatorIndex, frequencySelect.selectedIndex));
});
}
this._drumsetGroup.appendChild(
div({ class: "selectRow" },
span({ class: "tip", onclick: () => this._openPrompt("drumsetEnvelope") }, "Envelope:"),
span({ class: "tip", onclick: () => this._openPrompt("drumsetSpectrum") }, "Spectrum:"),
),
);
for (let i: number = Config.drumCount - 1; i >= 0; i--) {
const drumIndex: number = i;
const spectrumEditor: SpectrumEditor = new SpectrumEditor(this._doc, drumIndex);
spectrumEditor.container.addEventListener("mousedown", this.refocusStage);
this._drumsetSpectrumEditors[i] = spectrumEditor;
const envelopeSelect: HTMLSelectElement = buildOptions(select({ style: "width: 100%;", title: "Filter Envelope" }), Config.envelopes.map(envelope => envelope.name));
this._drumsetEnvelopeSelects[i] = envelopeSelect;
envelopeSelect.addEventListener("change", () => {
this._doc.record(new ChangeDrumsetEnvelope(this._doc, drumIndex, envelopeSelect.selectedIndex));
});
const row: HTMLDivElement = div({ class: "selectRow" },
div({ class: "selectContainer", style: "width: 5em; margin-right: .3em;" }, envelopeSelect),
this._drumsetSpectrumEditors[i].container,
);
this._drumsetGroup.appendChild(row);
}
this._modNameRows = [];
this._modChannelBoxes = [];
this._modInstrumentBoxes = [];
this._modSetRows = [];
this._modSetBoxes = [];
this._modFilterRows = [];
this._modFilterBoxes = [];
this._modTargetIndicators = [];
for (let mod: number = 0; mod < Config.modCount; mod++) {
let modChannelBox: HTMLSelectElement = select({ style: "width: 100%; color: currentColor; text-overflow:ellipsis;" });
let modInstrumentBox: HTMLSelectElement = select({ style: "width: 100%; color: currentColor;" });
let modNameRow: HTMLDivElement = div({ class: "operatorRow", style: "height: 1em; margin-bottom: 0.65em;" },
div({ class: "tip", style: "width: 10%; max-width: 5.4em;", id: "modChannelText" + mod, onclick: () => this._openPrompt("modChannel") }, "Ch:"),
div({ class: "selectContainer", style: 'width: 35%;' }, modChannelBox),
div({ class: "tip", style: "width: 1.2em; margin-left: 0.8em;", id: "modInstrumentText" + mod, onclick: () => this._openPrompt("modInstrument") }, "Ins:"),
div({ class: "selectContainer", style: "width: 10%;" }, modInstrumentBox),
);
let modSetBox: HTMLSelectElement = select();
let modFilterBox: HTMLSelectElement = select();
let modSetRow: HTMLDivElement = div({ class: "selectRow", id: "modSettingText" + mod, style: "margin-bottom: 0.9em; color: currentColor;" }, span({ class: "tip", onclick: () => this._openPrompt("modSet") }, "Setting: "), span({ class: "tip", style: "font-size:x-small;", onclick: () => this._openPrompt("modSetInfo" + mod) }, "?"), div({ class: "selectContainer" }, modSetBox));
let modFilterRow: HTMLDivElement = div({ class: "selectRow", id: "modFilterText" + mod, style: "margin-bottom: 0.9em; color: currentColor;" }, span({ class: "tip", onclick: () => this._openPrompt("modFilter" + mod) }, "Target: "), div({ class: "selectContainer" }, modFilterBox));
// @jummbus: I could template this up above and simply create from the template, especially since I also reuse it in song settings, but unsure how to do that with imperative-html :P
let modTarget: SVGElement = SVG.svg({ style: "transform: translate(0px, 1px);", width: "1.5em", height: "1em", viewBox: "0 0 200 200" }, [
SVG.path({ d: "M90 155 l0 -45 -45 0 c-25 0 -45 -4 -45 -10 0 -5 20 -10 45 -10 l45 0 0 -45 c0 -25 5 -45 10 -45 6 0 10 20 10 45 l0 45 45 0 c25 0 45 5 45 10 0 6 -20 10 -45 10 l -45 0 0 45 c0 25 -4 45 -10 45 -5 0 -10 -20 -10 -45z" }),
SVG.path({ d: "M42 158 c-15 -15 -16 -38 -2 -38 6 0 10 7 10 15 0 8 7 15 15 15 8 0 15 5 15 10 0 14 -23 13 -38 -2z" }),
SVG.path({ d: "M120 160 c0 -5 7 -10 15 -10 8 0 15 -7 15 -15 0 -8 5 -15 10 -15 14 0 13 23 -2 38 -15 15 -38 16 -38 2z" }),