-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2667 lines (2407 loc) · 90.8 KB
/
Copy pathindex.html
File metadata and controls
2667 lines (2407 loc) · 90.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<title>hum</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg: #16181a;
--fg: #ffffff;
--fg2: #7b8496;
--error: #ff6e5e;
--blue: #5ea1ff;
--green: #5eff6c;
--cyan: #5ef1ff;
--magenta: #ff5ef1;
--pink: #ff5ea0;
--orange: #ffbd5e;
--purple: #bd5eff;
--font: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}
html, body {
height: 100%;
background: var(--bg);
color: var(--fg);
font-family: var(--font);
overflow: hidden;
}
#app {
height: 100%;
display: flex;
flex-direction: column;
}
#editor-wrap {
position: relative;
flex: 1;
overflow: hidden;
}
#highlight {
position: absolute;
inset: 0;
/* Bottom padding leaves clearance for the fixed translucent footer
so the last lines of code don't sit under it. */
padding: 32px 32px 120px;
/* Honour iOS safe-area insets when present (notch, side bezel). */
padding-top: max(32px, env(safe-area-inset-top));
padding-left: max(32px, env(safe-area-inset-left));
padding-right: max(32px, env(safe-area-inset-right));
font-family: var(--font);
font-size: 14px;
line-height: 1.7;
white-space: pre;
overflow: auto;
pointer-events: none;
color: var(--fg);
tab-size: 2;
}
#highlight .cm { color: var(--fg2); }
#highlight .kw { color: var(--magenta); }
#highlight .wf { color: var(--cyan); }
#highlight .nm { color: var(--fg); opacity: 0.5; }
#highlight .nt { color: var(--green); }
#highlight .tr { color: var(--pink); }
#highlight .rs { color: var(--fg2); opacity: 0.3; }
#highlight .bl { color: var(--fg2); opacity: 0.3; }
#highlight .co { color: var(--purple); }
#highlight .fx { color: var(--blue); }
#highlight .nu { color: var(--orange); }
#highlight .md { color: var(--purple); opacity: 0.7; }
#highlight .er { text-decoration: underline wavy var(--error); }
/* Highlight the whole .pt wrapper so a token like `f2*8` renders as one
continuous cyan box instead of one box per inner span. The :has() rule
suppresses the background on rests (no inverse-video for silence). */
#highlight .pt.playing { background: var(--cyan); border-radius: 2px; }
#highlight .pt.playing .nt,
#highlight .pt.playing .tr,
#highlight .pt.playing .md,
#highlight .pt.playing .bl { color: var(--bg); opacity: 1; }
#highlight .pt.playing:has(.rs) { background: none; }
#highlight .pt.playing .rs { opacity: 0.7; }
#editor {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
background: transparent;
color: transparent;
font-family: var(--font);
font-size: 14px;
line-height: 1.7;
padding: 32px 32px 120px;
/* Match #highlight's safe-area-aware padding so the layers stay aligned. */
padding-top: max(32px, env(safe-area-inset-top));
padding-left: max(32px, env(safe-area-inset-left));
padding-right: max(32px, env(safe-area-inset-right));
border: none;
outline: none;
resize: none;
tab-size: 2;
white-space: pre;
overflow: auto;
caret-color: var(--fg);
z-index: 1;
}
#editor::placeholder {
color: var(--fg2);
}
#footer {
/* Floating translucent footer: code scrolls behind the gradient fade so
the editor reads continuously while the footer stays pinned. */
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 2;
background: linear-gradient(to bottom,
rgba(22, 24, 26, 0) 0%,
rgba(22, 24, 26, 0.4) 25%,
rgba(22, 24, 26, 0.7) 50%,
rgba(22, 24, 26, 0.9) 75%,
rgba(22, 24, 26, 0.95) 100%);
padding-top: 40px;
/* Bottom inset keeps the home indicator from overlapping controls. */
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
}
#canvas {
display: block;
width: 100%;
height: 48px;
}
#info-bar {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px 12px;
padding: 6px 16px;
font-size: 11px;
color: var(--fg2);
user-select: none;
}
#controls {
display: flex;
align-items: center;
gap: 12px;
padding: 6px 16px;
font-size: 11px;
color: var(--fg2);
user-select: none;
}
#spacer2 { flex: 1; }
#controls button,
#controls a {
background: none;
border: none;
color: var(--fg2);
font-family: var(--font);
font-size: 11px;
cursor: pointer;
padding: 2px 0;
letter-spacing: 0.5px;
text-decoration: none;
}
#controls button:hover,
#controls a:hover { color: var(--fg); }
#preset-picker {
background: none;
border: none;
color: var(--fg2);
font-family: var(--font);
font-size: 11px;
letter-spacing: 0.5px;
cursor: pointer;
padding: 2px 0;
appearance: none;
-webkit-appearance: none;
}
#preset-picker:hover { color: var(--fg); }
/* The picker's focus ring would persist after selection in some browsers
(Chrome retains focus on the <select> across change events even after a
blur(). The picker is a pop-and-go affordance so a sticky focus
indicator on it has no meaning — drop both rings. */
#preset-picker:focus,
#preset-picker:focus-visible { outline: none; box-shadow: none; }
#preset-picker option { background: var(--bg); color: var(--fg); }
#play-btn.playing { color: var(--cyan); }
#step-bar {
display: flex;
align-items: center;
gap: 2px;
}
.step-dot {
width: 4px;
height: 4px;
flex-shrink: 0;
border-radius: 1px;
background: #2a2d32;
transition: background 0.08s;
}
.step-dot.beat {
background: var(--fg2);
}
.step-dot.active {
background: var(--cyan);
}
#spacer { flex: 1; }
#channel-info {
font-size: 11px;
color: var(--fg2);
white-space: nowrap;
flex-shrink: 0;
}
#meters {
display: flex;
gap: 3px;
align-items: flex-end;
height: 16px;
}
.meter {
width: 3px;
height: 100%;
background: linear-gradient(to top, #2a2d32 0%, #2a2d32 100%);
border-radius: 1px;
position: relative;
overflow: hidden;
}
.meter::after {
content: '';
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: var(--lvl, 0%);
background: var(--cyan);
transition: height 0.05s linear;
}
.meter.clip::after {
background: var(--error);
}
/* ── Mobile / touch ─────────────────────────────────────────────────
Activated on coarse-pointer, no-hover devices (phones + tablets).
Desktop browsers — including the Playwright suite's Chromium —
never match these queries, so existing tests stay unaffected. */
#mobile-toolbar { display: none; }
@media (hover: none) and (pointer: coarse) {
/* iOS auto-zooms <input>/<textarea> when font-size < 16px on focus.
Bumping to 16px keeps zoom from re-flowing the editor mid-tap. */
#editor, #highlight {
font-size: 16px;
padding-bottom: 56px;
}
/* Larger tap targets on the controls row. */
#controls { padding: 8px 16px; gap: 16px; }
#controls button,
#controls a {
font-size: 13px;
padding: 10px 4px;
min-height: 36px;
display: inline-flex;
align-items: center;
}
#info-bar { padding: 8px 16px; font-size: 13px; }
#channel-info { font-size: 13px; }
.step-dot { width: 6px; height: 6px; }
/* Pattern-token input toolbar — common tokens that are awkward to
reach on mobile keyboards. Inserts at the caret on tap. */
#mobile-toolbar {
display: flex;
overflow-x: auto;
gap: 6px;
padding: 8px 12px;
background: var(--bg);
border-top: 1px solid #1e2124;
-webkit-overflow-scrolling: touch;
}
#mobile-toolbar button {
flex-shrink: 0;
min-width: 44px;
height: 36px;
background: #22252a;
border: none;
border-radius: 6px;
color: var(--fg);
font-family: var(--font);
font-size: 16px;
cursor: pointer;
user-select: none;
-webkit-user-select: none;
}
#mobile-toolbar button:active { background: #32363c; }
}
</style>
</head>
<body>
<!-- PRESETS:START -->
<script type="text/hum" data-preset="dust-and-iron">
bpm 108
-- dust and iron
whistle tri
. . . . e5 . d5 . | b4 . . . . . . .
. . . . e5 . g5 . | f#5 . . . e5 . d5 .
. . . . b4 . d5 . | e5 . . . . . . .
. . d5 . b4 . a4 . | b4 . . . . . . .
: vol .5
twang sqr
. . . . b3 . a3 . | g3 . . . . . . .
. . . . b3 . d4 . | d4 . . . b3 . a3 .
. . . . g3 . a3 . | b3 . . . . . . .
. . a3 . g3 . f#3 . | g3 . . . . . . .
: vol .15
bass saw
e2 . . . e2 . e3 . | e2 . . . e2 . . . -- Em
e2 . . . e2 . e3 . | e2 . . . e2 . . .
g2 . . . g2 . g3 . | g2 . . . g2 . . . -- G
b1 . . . d2 . e2 . | e2 . . . . . . . -- B→Em
: lpf 250
gallop sin
e3 . e4 . e3 . e4 . -- Em
e3 . e4 . e3 . e4 .
g3 . b3 . g3 . b3 . -- G
b2 . d3 . b2 . e3 . -- B→Em
: vol .08 lpf 800
drone sin
b2 b2 b2 b2 b2 b2 b2 b2 -- Em (5th)
b2 b2 b2 b2 b2 b2 b2 b2
d3 d3 d3 d3 d3 d3 d3 d3 -- G (5th)
b2 b2 d3 d3 b2 b2 a2 a2 -- B→Em turnaround (matches bass)
: vol .06 lpf 400
kick noise
x . . . . . x . | . . x . . . . .
x . . . . . x . | . . x . . . . .
x . . . . . x . | . . x . . . . .
x . . x . . x . | x . x . . . . .
: lpf 50 decay .06
snr noise
. . . . x . . . | . . . . . . x .
. . . . x . . . | . . . . . . x .
. . . . x . . . | . . . . . . x .
. . . . x . . x | . . . . x . x .
: lpf 3k hpf 800 decay .04
dust noise
. x . . . x . . | . . . x . . . x
: vol .03 hpf 6k decay .015
</script>
<script type="text/hum" data-preset="flux">
bpm 200
-- flux (fast feature platter — every waveform, every effect)
-- 200 bpm with 8th-note steps = 16th-note feel. All five waveforms,
-- all four effects, sharps + flats, triggers on pitched channels,
-- a 16-bar arrangement with build / drop / return.
lead sin
e5 . g5 . a5 . b5 . | c6 . b5 . a5 . g5 . -- A: lead enters
e5 . g5 . a5 . c6 . | d6 . c6 . a5 . g5 .
e5 . g5 . a5 . b5 . | c6 . b5 . a5 . g5 .
e5 . g5 . a5 . c6 . | d6 . . . . . . .
: vol .35 hpf 200
stab sqr
. . . . a4 . . . | . . . . a4 . . . -- A: rhythmic stab
. . . . a4 . . . | . . . . a4 . . a4
. . . . a4 . . . | . . . . a4 . . .
. . . . a4 . . . | . . . . a4 a4 a4 a4
: vol .12 lpf 3k
bass saw
a2 . . a2 . . a3 . | g2 . . g2 . . g3 .
f2 . . f2 . . f3 . | e2 . . e2 . . e3 .
a2 . . a2 . . a3 . | g2 . . g2 . . g3 .
f2 . . f2 . . f3 . | e2 . . e2 e2 e2 e2
: lpf 320
trill tri
. . a4 b4 c5 . b4 a4 | g4 . a4 . b4 . . .
. . a4 b4 c5 . d5 . | e5 . d5 . c5 . b4 .
. . a4 b4 c5 . b4 a4 | g4 . a4 . b4 . . .
. . . . . . . . | . . . . . . . .
: vol .15 lpf 4k
pluck sin
a3 . e4 . a3 . e4 . | a3 . e4 . a3 . e4 .
g3 . d4 . g3 . d4 . | g3 . d4 . g3 . d4 .
f3 . c4 . f3 . c4 . | f3 . c4 . f3 . c4 .
e3 . b3 . e3 . b3 . | e3 . b3 . e3 . b3 .
: vol .14 decay .08
-- triggered envelope on pitched channels — the source plays at its
-- last frequency for each `x`, useful for percussive accents.
acc sqr
. . . . . . . x | . . . . . . . x
. . . . . . . x | . . . . . . . x
. . . . . . . x | . . . . . . . x
. . . . . . . x | . . . . . . . .
: vol .08 hpf 2k decay .03
kick noise
x . . . x . . . | x . . . x . . .
x . . . x . . . | x . . . x . . x
x . . . x . . . | x . . . x . . .
x . . . x . . . | x . x . x x x x
: lpf 60 decay .05
hat noise
. x . x . x . x | . x . x . x . x
. x . x . x . x | . x . x . x x x
. x . x . x . x | . x . x . x . x
. x . x . x . x | x x x x x x x x
: hpf 9k decay .015
</script>
<script type="text/hum" data-preset="glass">
bpm 96
-- glass
lead tri
. . f#4 . a4 . c#5 . | d5 . . . c#5 . a4 . | . . d4 . f#4 . a4 . | b4 . . . a4 . . . | . . b4 . d5 . f#5 . | e5 . . . d5 . b4 . | . . c#5 . e5 . . . | d5 . c#5 . a4 . . . -- A: verse
. . f#4 . a4 . d5 . | e5 . . . d5 . a4 . | . . d4 . f#4 . b4 . | c#5 . . . b4 . . . | . . f#4 . a4 . c#5 . | d5 . . . . . . . | . . . . . . . . | . . . . . . . . -- A' + B: open
. . a4 . d5 . f#5 . | g5 . . . f#5 . d5 . | . . f#5 . e5 . d5 . | c#5 . . . a4 . . . | . . b4 . d5 . f#5 . | e5 . . . d5 . b4 . | . . c#5 . e5 . . . | d5 . . . . . . . -- C: climax + A: return
: vol .5
arp sin
d3 f#3 a3 c#4 a3 f#3 a3 c#4 | d3 f#3 a3 c#4 a3 f#3 a3 c#4 | b2 d3 f#3 a3 f#3 d3 f#3 a3 | b2 d3 f#3 a3 f#3 d3 f#3 a3 -- Dmaj7 Bm7
d3 f#3 a3 c#4 a3 f#3 a3 c#4 | d3 f#3 a3 c#4 a3 f#3 a3 c#4 | b2 d3 f#3 a3 f#3 d3 f#3 a3 | b2 d3 f#3 a3 f#3 d3 f#3 a3 -- Dmaj7 Bm7 (rep)
d4 f#4 a4 c#5 a4 f#4 a4 c#5 | d4 f#4 a4 c#5 a4 f#4 a4 c#5 | c#5 a4 f#4 d4 c#4 a3 f#3 d3 | c#5 a4 f#4 d4 c#4 a3 f#3 d3 -- D oct up + cascade fall
g3 b3 d4 f#4 d4 b3 d4 f#4 | g3 b3 d4 f#4 d4 b3 d4 f#4 | g3 b3 d4 g4 d4 b3 g3 b3 | g3 b3 d4 g4 d4 b3 g3 b3 -- Gmaj7 Gmaj7-var
e3 g#3 b3 e4 b3 g#3 b3 e4 | e3 g#3 b3 e4 b3 g#3 b3 e4 | a3 c#4 e4 a4 e4 c#4 e4 a4 | a3 c#4 e4 a4 e4 c#4 e4 a4 -- E A
g3 b3 d4 f#4 d4 b3 d4 f#4 | g3 b3 d4 f#4 d4 b3 d4 f#4 | a3 c#4 e4 a4 e4 c#4 a3 e3 | a3 c#4 e4 a4 e4 c#4 a3 e3 -- Gmaj7 A (fall)
: vol .12 lpf 2k
pad sin d3*16 b2*16 d3*16 b2*16 d3*16 d3*16 g3*16 g3*16 e3*16 a3*16 g3*16 a3*16 : vol .08 lpf 600
bass saw
d2 . . d2 . . d3 . | d2 . . d2 . . d3 . | b1 . . b1 . . b2 . | b1 . . b1 . . b2 . | d2 . . d2 . . d3 . | d2 . . d2 . . d3 . | b1 . . b1 . . b2 . | b1 . . b1 . . b2 . -- D B D B
d2 . . d2 . . d3 . | d2 . . d2 . . d3 . | d2 . . d2 . . d3 . | d2 . . d2 . . d3 . | g2 . . g2 . . g3 . | g2 . . g2 . . g3 . | g2 . . . . . . . | . . . . . . . . -- A' B
e2 . . e2 . . e3 . | a2 . . a2 . . a3 . | a2 . . a2 . . a3 . | a2 . . a2 . . a3 . | g2 . . g2 . . g3 . | g2 . . g2 . . g3 . | a2 . . a2 . . a3 . | a2 . . a2 . . e2 . -- C
: lpf 200
kick noise
x . . . . . x . | . . . . x . . . | x . . . . . x . | . . . . x . . . | x . . . . . x . | . . . . x . . . | x . . . . . x . | . . . . x . . . -- A
x . . . . . x . | . . . . x . . . | x . . . . . x . | . . . . x . . . | x . . . . . . . | . . . . . . . . | . . . . . . . . | . . . . . . . . -- A' B
x . . . . . x . | x . . . . . x . | x . . . . . x . | . . x . . . x . | x . . . . . x . | . . . . x . . . | x . . . . . x . | . . . . . . . . -- C
: lpf 50 decay .06
hat noise
. . x . . . x . | . . x . . . x . | . . x . . . x . | . . x . . . x . | . . x . . . x . | . . x . . . x . | . . x . . . x . | . . x . . x x . -- A
. . x . . . x . | . . x . . x x . | . . x . . . . . | . . . . . . . . | . . . . . . . . | . . . . . . . . | . . . . . . . . | . . . . . . . . -- A' B
. . x . . x . . | . . x . . x . . | . . x . . x . . | . x x . . . x . | . . x . . . x . | . . x . . . x . | . . x . . . x . | . . . . . . . . -- C
: hpf 8k decay .03
</script>
<script type="text/hum" data-preset="micro-cell">
bpm 100
-- micro-cell (polyrhythm showcase: prime-length channels)
-- Each channel has a coprime length so the loop point is the LCM of
-- all of them. Watch the playhead — every channel scrolls at its own
-- rate and the texture never quite repeats.
-- 7 steps: pulse against an 8-step kick → drifts +1 step per loop
pulse sin
c4 . . e4 . g4 .
: vol .14 lpf 2k
-- 11 steps: counter-melody using underscore rests for variety
counter tri
e4 _ . a4 _ . c5 _ . _ e4
: vol .08
-- 5 steps: triggered hat at a different cycle
tick noise
. x . _ x
: hpf 8k decay .02
-- 13 steps: bass slowly cycles
bass saw
c2 . . . g1 . c3 . . . . g1 .
: lpf 240
-- 8 steps: the only "metric" pattern, anchors the rhythm
kick noise
x . . . x . . .
: lpf 55 decay .05
</script>
<script type="text/hum" data-preset="neon-drift">
bpm 138
-- neon drift
lead tri
. . e4 g4 a4 . g4 e4 | d4 . . . e4 . . . -- A: verse
. . c4 d4 e4 . g4 a4 | b4 . a4 . g4 . . .
. . e4 g4 a4 . c5 b4 | a4 . g4 . e4 . d4 .
c4 . d4 . e4 . . . | . . . . . . . .
. . e4 g4 a4 . g4 e4 | d4 . . . e4 . . . -- A: repeat
. . c4 d4 e4 . g4 a4 | b4 . a4 . g4 . . .
. . e4 g4 a4 . c5 b4 | a4 . g4 . e4 . d4 .
c4 . d4 . e4 . . . | . . . . . . . .
. . a4 . c5 . d5 . | e5 . . . d5 . c5 . -- B: lift
. . c5 d5 e5 . g5 . | a5 . . . g5 . e5 .
. . d5 . c5 . a4 . | g4 . . . a4 . . .
. . g4 a4 b4 . a4 . | g4 . . . . . . .
. . e4 g4 a4 . g4 e4 | d4 . . . e4 . . . -- A: return
. . c4 d4 e4 . g4 a4 | b4 . a4 . g4 . . .
. . e4 g4 a4 . c5 b4 | a4 . g4 . e4 . d4 .
. . . . . . . . | . . . . . . . . -- breathe
: vol .55
harm sqr
. . c4 e4 e4 . e4 c4 | b3 . . . c4 . . . -- A
. . a3 b3 c4 . e4 e4 | g4 . e4 . e4 . . .
. . c4 e4 e4 . a4 g4 | e4 . e4 . c4 . b3 .
a3 . b3 . c4 . . . | . . . . . . . .
. . c4 e4 e4 . e4 c4 | b3 . . . c4 . . . -- A
. . a3 b3 c4 . e4 e4 | g4 . e4 . e4 . . .
. . c4 e4 e4 . a4 g4 | e4 . e4 . c4 . b3 .
a3 . b3 . c4 . . . | . . . . . . . .
. . e4 . a4 . b4 . | c5 . . . b4 . a4 . -- B
. . a4 b4 c5 . e5 . | e5 . . . e5 . c5 .
. . b4 . a4 . e4 . | e4 . . . e4 . . .
. . e4 e4 g4 . e4 . | e4 . . . . . . .
. . c4 e4 e4 . e4 c4 | b3 . . . c4 . . . -- A
. . a3 b3 c4 . e4 e4 | g4 . e4 . e4 . . .
. . c4 e4 e4 . a4 g4 | e4 . e4 . c4 . b3 .
. . . . . . . . | . . . . . . . .
: vol .15
bass saw
a2 . . a2 . . a3 . | g2 . . g2 . . g3 . -- Am G
f2 . . f2 . . f3 . | e2 . . e2 . . e3 . -- F Em
a2 . . a2 . . a3 . | g2 . . g2 . . g3 .
f2 . . f2 . . f3 e3 | d3 . e3 . . . . .
a2 . . a2 . . a3 . | g2 . . g2 . . g3 . -- repeat
f2 . . f2 . . f3 . | e2 . . e2 . . e3 .
a2 . . a2 . . a3 . | g2 . . g2 . . g3 .
f2 . . f2 . . f3 e3 | d3 . e3 . . . . .
f2 . . f2 . . f3 . | c2 . . c2 . . c3 . -- B: F C
d2 . . d2 . . d3 . | e2 . . e2 . . e3 . -- Dm E
f2 . . f2 . . f3 . | g2 . . g2 . . g3 . -- F G
a2 . . a2 . . a3 . | a2 . . a2 . . e2 . -- Am
a2 . . a2 . . a3 . | g2 . . g2 . . g3 . -- A: return
f2 . . f2 . . f3 . | e2 . . e2 . . e3 .
a2 . . a2 . . a3 . | g2 . . g2 . . g3 .
f2 . . f2 . . f3 . | e2 . . e2 . e2 e3 .
: lpf 320
arp sin
a3 c4 e4 a4 c4 e4 a4 e4 -- Am
g3 b3 d4 g4 b3 d4 g4 d4 -- G
f3 a3 c4 f4 a3 c4 f4 c4 -- F
e3 g3 b3 e4 g3 b3 e4 b3 -- Em
a3 c4 e4 a4 c4 e4 a4 e4
g3 b3 d4 g4 b3 d4 g4 d4
f3 a3 c4 f4 a3 c4 f4 c4
e3 g3 b3 e4 b3 g3 e3 g3
f3 a3 c4 f4 a3 c4 f4 c4 -- B
c3 e3 g3 c4 e3 g3 c4 g3 -- C
d3 f3 a3 d4 f3 a3 d4 a3 -- Dm
e3 g#3 b3 e4 g#3 b3 e4 b3 -- E
f3 a3 c4 f4 a3 c4 f4 c4 -- F
g3 b3 d4 g4 b3 d4 g4 d4 -- G
a3 c4 e4 a4 c4 e4 a4 e4 -- Am
a3 c4 e4 a4 e4 c4 a3 e3 -- Am (fall)
: vol .1
pad sin
a3 a3 a3 a3 a3 a3 a3 a3
g3 g3 g3 g3 g3 g3 g3 g3
f3 f3 f3 f3 f3 f3 f3 f3
e3 e3 e3 e3 e3 e3 e3 e3
a3 a3 a3 a3 e4 e4 e4 e4 -- A repeat: open the 5th overhead
g3 g3 g3 g3 d4 d4 d4 d4
f3 f3 f3 f3 c4 c4 c4 c4
e3 e3 e3 e3 b3 b3 b3 b3
f3 f3 f3 f3 f3 f3 f3 f3 -- B
c3 c3 c3 c3 c3 c3 c3 c3
d3 d3 d3 d3 d3 d3 d3 d3
e3 e3 e3 e3 e3 e3 e3 e3
f3 f3 f3 f3 f3 f3 f3 f3
g3 g3 g3 g3 g3 g3 g3 g3
a3 a3 a3 a3 a3 a3 a3 a3
a3 a3 a3 a3 e3 e3 e3 e3
: vol .06
kick noise
x . . . x . . . | x . . . x . . . -- A
x . . . x . . . | x . . . x . . .
x . . . x . . . | x . . . x . . .
x . . . x . . . | x . . x . . x .
x . . . x . . . | x . . . x . . . -- A
x . . . x . . . | x . . . x . . .
x . . . x . . . | x . . . x . . .
x . . . x . . . | x . . x . . x .
x . . . . . x . | x . . . . . x . -- B: half time
x . . . . . x . | x . . . . . x .
x . . . . . x . | x . . . . . x .
x . . . x . x . | x . x . x . x . -- build
x . . . x . . . | x . . . x . . . -- A
x . . . x . . . | x . . . x . . .
x . . . x . . . | x . . . x . . .
. . . . . . . . | . . . . . . . . -- drop out
: lpf 55 decay .05
snr noise
. . . . x . . . | . . . . x . . . -- A
. . . . x . . . | . . . . x . . x
. . . . x . . . | . . . . x . . .
. . . . x . . . | . . x . x . x .
. . . . x . . . | . . . . x . . . -- A
. . . . x . . . | . . . . x . . x
. . . . x . . . | . . . . x . . .
. . . . x . . . | . . x . x . x .
. . . . . . . . | . . . . x . . . -- B: sparse
. . . . . . . . | . . . . x . . .
. . . . . . . . | . . . . x . . .
. . x . x . x . | x . x . x . x . -- build
. . . . x . . . | . . . . x . . . -- A
. . . . x . . . | . . . . x . . x
. . . . x . . . | . . . . x . . .
. . . . . . . . | . . . . . . . . -- drop out
: lpf 4k hpf 1k decay .04
hat noise
. x . x . x . x | . x . x . x . x -- A
. x . x . x . x | . x . x . x x x
. x . x . x . x | . x . x . x . x
. x . x . x . x | x x . x x x x .
. x . x . x . x | . x . x . x . x -- A
. x . x . x . x | . x . x . x x x
. x . x . x . x | . x . x . x . x
. x . x . x . x | x x . x x x x .
. . x . . . x . | . . x . . . x . -- B: half time hat
. . x . . . x . | . . x . . . x .
. . x . . . x . | . . x . . . x .
x x x x x x x x | x x x x x x x x -- fill
. x . x . x . x | . x . x . x . x -- A
. x . x . x . x | . x . x . x x x
. x . x . x . x | . x . x . x . x
. . . . . . . . | . . . . . . . . -- drop out
: hpf 9k decay .015
</script>
<script type="text/hum" data-preset="phosphene">
bpm 88
-- phosphene
lead tri
. . . e4 . g4 a4 . | b4 . . . a4 . g4 . -- verse
. . e4 . g4 . b4 . | d5 . . . b4 . . .
. . . c5 . b4 a4 . | g4 . . . e4 . . . -- answer
. e4 g4 . a4 . . . | . . . . . . . .
. . . e4 . g4 a4 . | b4 . d5 . e5 . d5 . -- lift
. . c5 . b4 . a4 . | g4 . . . . . . .
. . . e5 . d5 b4 . | a4 . g4 . e4 . . . -- resolve
. . . . . . . . | . . . . . . . .
: vol .45
harm sqr
. . . c4 . e4 e4 . | g4 . . . e4 . e4 .
. . c4 . e4 . g4 . | b4 . . . g4 . . .
. . . a3 . g4 e4 . | e4 . . . c4 . . .
. c4 e4 . e4 . . . | . . . . . . . .
. . . c4 . e4 e4 . | g4 . b4 . c5 . b4 .
. . a4 . g4 . e4 . | e4 . . . . . . .
. . . c5 . b4 g4 . | e4 . e4 . c4 . . .
. . . . . . . . | . . . . . . . .
: vol .12
bass saw
e2 . . e2 . . e3 . | e2 . . e2 . . e3 . -- Em
c2 . . c2 . . c3 . | c2 . . c2 . . c3 . -- C
a1 . . a1 . . a2 . | a1 . . a1 . . a2 . -- Am
d2 . . d2 . . d3 . | d2 . . d2 . . e2 . -- D
e2 . . e2 . . e3 . | e2 . . e2 . . e3 .
c2 . . c2 . . c3 . | c2 . . c2 . . c3 .
a1 . . a1 . . a2 . | a1 . . a1 . . a2 .
b1 . . b1 . . b2 . | d2 . . d2 . . e2 . -- B→D→E turnaround
: lpf 220
arp sin
e3 g3 b3 e4 b3 g3 b3 e4 -- Em
c3 e3 g3 c4 g3 e3 g3 c4 -- C
a2 c3 e3 a3 e3 c3 e3 a3 -- Am
d3 f#3 a3 d4 a3 f#3 a3 d4 -- D
e3 g3 b3 e4 b3 g3 b3 e4
c3 e3 g3 c4 g3 e3 g3 c4
a2 c3 e3 a3 e3 c3 e3 a3
b2 d3 f#3 b3 d3 f#3 b3 d3 -- Bm
: vol .1 lpf 1.5k
pad sin
b3 b3 b3 b3 b3 b3 b3 b3
g3 g3 g3 g3 g3 g3 g3 g3
e3 e3 e3 e3 e3 e3 e3 e3
f#3 f#3 f#3 f#3 f#3 f#3 f#3 f#3
b3 b3 b3 b3 b3 b3 b3 b3
g3 g3 g3 g3 g3 g3 g3 g3
e3 e3 e3 e3 e3 e3 e3 e3
f#3 f#3 f#3 f#3 d3 d3 d3 d3
: vol .06 lpf 700
kick noise
x . . . . . x . | . . . . x . . .
x . . . . . x . | . . . . x . . .
x . . . . . x . | . . . . x . . .
x . . . . . x . | . . x . x . . .
: lpf 45 decay .06
hat noise
. . x . . x . . | . . x . . . x .
. . x . . x . . | . . x . . . x .
. . x . . x . . | . . x . . . x .
. . x . . x x . | . x x . . x . .
: hpf 7k decay .025
snr noise
. . . . . . . . | . . . . x . . .
. . . . . . . . | . . . . x . . .
. . . . . . . . | . . . . x . . .
. . . . . . . . | . . . . x . x .
: lpf 3k hpf 1k decay .04
</script>
<script type="text/hum" data-preset="phrase">
bpm 92
-- phrase (per-step modifiers: hold, accent, ghost)
-- Same notes a verse-and-answer would have, but the dynamics live
-- inside each channel instead of being faked across multiple. Watch
-- for `*N` (hold), `!` (accent), `?` (ghost) on the lead and bass.
lead tri
c5*4 e5! d5 c5 . -- A: held tonic, accented landing, decay
b4? a4? g4! a4 b4 c5*2 . -- ghost lead-in, then a held second
c5*4 e5! d5 c5 .
b4? a4? g4! c5*4 . -- close on a held tonic
: vol .5
bass saw
c3*4 g2 c2! . . -- bass holds under the lead's held tonic
a2? . f2? . g2!*2 . . -- ghost steps then an accented sustain
c3*4 g2 c2! . .
a2? . f2? . c3*4 -- mirror the lead's final hold
: lpf 350
pad sin
c4*8 -- one note across the whole bar
a3*8
c4*8
c4*8
: vol .08 lpf 700
kick noise
x . . . x! . . . -- accented backbeat
x . . . x! . . .
x . . . x! . . .
x . . . x! . . x
: lpf 50 decay .06
hat noise
. . x? . . . x . -- ghost the offbeat, normal on the &
: hpf 8k decay .02
</script>
<script type="text/hum" data-preset="slow-erosion">
bpm 52
-- slow erosion
earth sin -- 7 steps
a1 a1 a1 a1 a1 g1 g1
: vol .14 lpf 120
tide sin -- 11 steps
e2 e2 e2 e2 e2 e2 d2 d2 d2 d2 d2
: vol .1 lpf 300
moss tri -- 9 steps
a2 a2 a2 c3 c3 c3 e3 e3 e3
: vol .07 lpf 600
fog sin -- 16 steps
e3 e3 e3 e3 e3 e3 e3 e3
g3 g3 g3 g3 g3 g3 g3 g3
: vol .06 lpf 700
haze tri -- 19 steps
. . . . a3 . . . . .
. . . . . e3 . . .
: vol .15
stone sin -- 17 steps
. . . . . . . b4 .
. . . . . . . .
: vol .12
rain noise -- 23 steps
. . . . . . . . . . .
x . . . . . . . . . . .
: vol .02 hpf 4k decay .06
breath noise -- 29 steps
. . . . . . . . . . . . . . .
. . . . . . x . . . . . . .
: vol .015 hpf 1k lpf 3k decay .2
</script>
<script type="text/hum" data-preset="tidal-memory">
bpm 64
-- tidal memory
deep sin -- 7 steps
c#2 c#2 c#2 c#2 c#2 c#2 b1
: vol .15 lpf 150
root sin -- 8 steps
e2 e2 e2 e2 g#2 g#2 g#2 g#2
: vol .12 lpf 400
fifth sin -- 9 steps
b3 b3 b3 b3 b3 g#3 g#3 g#3 g#3
: vol .1 lpf 500
pad tri -- 16 steps
e3 e3 e3 e3 e3 e3 e3 e3
g#3 g#3 g#3 g#3 g#3 g#3 g#3 g#3
: vol .08 lpf 800
voice tri -- 13 steps
. . e4 . . . b4 . . g#4 . . .
: vol .25
bell sin -- 11 steps
. . . . g#5 . . . . . e5
: vol .15
air noise -- 15 steps
. . . . . . . . x . . . . . .
: vol .03 hpf 3k decay .08
</script>
<script type="text/hum" data-preset="tidepool">
bpm 72
-- tidepool (held chords + soft dynamics)
-- before phase 2 the pad below would have been 32 lines of `a3 a3 a3 ...`;
-- now each chord is one token. ghost on the lead's pickups makes them
-- breathe; accent on the kick's downbeat plants the pulse.
pad sin
a3*8 f3*8 c4*8 g3*8 -- Am F C G — one held tone per bar
: vol .14 lpf 700
low tri
a2*8 f2*8 c3*8 g2*8 -- octave below the pad
: vol .1 lpf 500
bass saw
a1*4 . a2 . . -- root held half a bar, then a fill
f1*4 . f2 . .
c2*4 . c3 . .
g1*4 . g2 . .
: lpf 240
lead tri
. . a4 c5 e5 . d5 c5
. a4? c5? d5? e5! d5 c5 b4 -- ghost climb into an accented apex
. . c5 e5 g5 . f5 e5
. c5? e5? f5? g5! f5 e5 d5
: vol .35
kick noise
x! . . . x . . . -- accent the downbeat so the held pad sits over it
x! . . . x . . .
x! . . . x . . .
x! . . . x . . x!
: lpf 55 decay .07
hat noise
. x? . x . x? . x -- ghost the offbeats; the ands stay normal
: hpf 8k decay .02
</script>
<!-- PRESETS:END -->
<div id="app">
<div id="editor-wrap">
<div id="highlight"></div>
<textarea id="editor" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off"
placeholder="bpm 120 bass saw c2 . e2 . g2 . c2 e2 : lpf 400"></textarea>
</div>
<div id="footer">
<div id="mobile-toolbar">
<button data-insert=". " aria-label="rest">.</button>
<button data-insert="x " aria-label="trigger">x</button>
<button data-insert="| " aria-label="bar line">|</button>
<button data-insert=" : " aria-label="effects separator">:</button>
<button data-insert="#" aria-label="sharp">#</button>
<button data-insert="bpm " aria-label="bpm">bpm</button>
</div>
<canvas id="canvas"></canvas>
<div id="info-bar">
<div id="step-bar"></div>
<div id="spacer"></div>
<div id="meters"></div>
<div id="channel-info"></div>
</div>
<div id="controls">
<button id="play-btn">play</button>
<div id="spacer2"></div>
<select id="preset-picker" aria-label="load demo">
<option value="" selected>presets</option>
</select>
<button id="load-btn">load</button>
<button id="save-btn">save</button>
<a id="tutorial-link" href="tutorial.html" target="_blank" rel="noopener">tutorial</a>
</div>
</div>
</div>
<script>
// ── Constants & Note Table ──────────────────────────────────────────
const NOTE_NAMES = ['c','c#','d','d#','e','f','f#','g','g#','a','a#','b'];
const FLAT_MAP = { 'db':'c#','eb':'d#','fb':'e','gb':'f#','ab':'g#','bb':'a#','cb':'b' };
const WAVEFORM_MAP = { sin:'sine', tri:'triangle', sqr:'square', saw:'sawtooth' };
const WAVEFORMS = ['sin','tri','sqr','saw','noise'];
const MAX_CHANNELS = 8;
const DEFAULT_BPM = 120;
const SCHEDULE_AHEAD = 0.15;
const TICK_MS = 25;
// Web Worker for timer — immune to background tab throttling
const timerWorkerBlob = new Blob([`
let id = null;
onmessage = function(e) {
if (e.data.cmd === 'start') {
if (id !== null) clearInterval(id);
id = setInterval(function() { postMessage('tick'); }, e.data.interval);
} else if (e.data.cmd === 'stop') {
if (id !== null) { clearInterval(id); id = null; }
}
};
`], { type: 'text/javascript' });
const timerWorker = new Worker(URL.createObjectURL(timerWorkerBlob));
// Generate note frequencies: A4 = 440Hz
const NOTE_FREQ = {};
for (let oct = 0; oct <= 8; oct++) {
for (let i = 0; i < 12; i++) {
const midi = oct * 12 + i + 12; // C0 = MIDI 12
const freq = 440 * Math.pow(2, (midi - 69) / 12);
NOTE_FREQ[NOTE_NAMES[i] + oct] = freq;
}
}
// Add flat aliases
for (let oct = 0; oct <= 8; oct++) {
for (const [flat, sharp] of Object.entries(FLAT_MAP)) {
const sharpOct = (flat === 'cb') ? oct - 1 : oct;
if (sharpOct >= 0 && sharpOct <= 8) {
NOTE_FREQ[flat + oct] = NOTE_FREQ[sharp + sharpOct];
}
}
}
// ── Parser ──────────────────────────────────────────────────────────
// Pattern step shape — one factory per kind so future kinds extend in one
// place instead of forking the parser. Every step has a `type` discriminator
// that the scheduler dispatches on; payload fields are kind-specific.
const Step = {
rest: () => ({ type: 'rest' }),
trigger: (vel = 1) => ({ type: 'trigger', vel }),
note: (freq, name, vel = 1, hold = 1) => ({ type: 'note', freq, name, vel, hold }),
// Polyphonic step: N simultaneous frequencies on a pitched channel. Voices
// 0..N-1 of the channel's voice pool play one note each, summed into the
// shared envelope so accent/hold/decay apply to the chord as a whole.
chord: (freqs, names, vel = 1, hold = 1) => ({ type: 'chord', freqs, names, vel, hold }),