forked from simonholliday/subsequence
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
1878 lines (1656 loc) · 104 KB
/
index.html
File metadata and controls
1878 lines (1656 loc) · 104 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">
<title>POMSKI — Tutorial</title>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--bg: #1c1c1e;
--bg-panel: #252528;
--bg-input: #1a1a1c;
--bg-hover: #2e2e32;
--bg-code: #161618;
--border: #3a3a3e;
--border-dim: #2a2a2e;
--pink: #ff5c8a;
--pink-dim: #7a1a35;
--purple: #9d6fff;
--teal: #3fc8a0;
--orange: #ff9940;
--blue: #5ea8ff;
--red: #ff4f4f;
--green: #4cdb8c;
--yellow: #ffd060;
--text: #e2e2e8;
--text-dim: #888896;
--text-dark: #4a4a56;
--mono: 'JetBrains Mono', monospace;
--sans: 'Inter', sans-serif;
--r: 6px;
--content-width: 860px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
background: var(--bg);
color: var(--text);
font-family: var(--sans);
font-size: 14px;
line-height: 1.7;
}
/* ── NAV ── */
nav {
position: sticky;
top: 0;
z-index: 100;
background: var(--bg-panel);
border-bottom: 1px solid var(--border-dim);
display: flex;
align-items: center;
gap: 0;
padding: 0 24px;
height: 44px;
overflow-x: auto;
scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }
.nav-logo {
font-family: var(--mono);
font-size: 13px;
font-weight: 600;
color: var(--pink);
letter-spacing: 1px;
margin-right: 20px;
white-space: nowrap;
flex-shrink: 0;
}
nav a {
color: var(--text-dim);
text-decoration: none;
font-family: var(--mono);
font-size: 10px;
letter-spacing: 1px;
text-transform: uppercase;
padding: 0 12px;
height: 44px;
display: flex;
align-items: center;
border-bottom: 2px solid transparent;
transition: color .15s, border-color .15s;
white-space: nowrap;
flex-shrink: 0;
}
nav a:hover { color: var(--text); border-color: var(--border); }
nav a.active { color: var(--pink); border-color: var(--pink); }
/* ── LAYOUT ── */
.container {
max-width: var(--content-width);
margin: 0 auto;
padding: 0 24px 120px;
}
/* ── HERO ── */
.hero {
padding: 80px 0 60px;
border-bottom: 1px solid var(--border-dim);
margin-bottom: 64px;
}
.hero-tag {
font-family: var(--mono);
font-size: 10px;
letter-spacing: 3px;
text-transform: uppercase;
color: var(--teal);
margin-bottom: 16px;
}
.hero h1 {
font-family: var(--mono);
font-size: 48px;
font-weight: 600;
color: var(--pink);
line-height: 1.1;
letter-spacing: -1px;
margin-bottom: 16px;
}
.hero-sub {
font-size: 18px;
font-weight: 300;
color: var(--text-dim);
max-width: 580px;
line-height: 1.6;
}
/* ── SECTIONS ── */
.section {
padding: 64px 0;
border-bottom: 1px solid var(--border-dim);
}
.section:last-child { border-bottom: none; }
.section-tag {
font-family: var(--mono);
font-size: 9px;
letter-spacing: 3px;
text-transform: uppercase;
color: var(--text-dark);
margin-bottom: 10px;
}
h2 {
font-family: var(--mono);
font-size: 26px;
font-weight: 500;
color: var(--text);
margin-bottom: 24px;
line-height: 1.2;
}
h3 {
font-family: var(--mono);
font-size: 15px;
font-weight: 500;
color: var(--teal);
margin: 36px 0 12px;
}
h3:first-child { margin-top: 0; }
h4 {
font-family: var(--mono);
font-size: 12px;
font-weight: 500;
color: var(--purple);
margin: 24px 0 8px;
text-transform: uppercase;
letter-spacing: 1px;
}
p { margin-bottom: 16px; color: var(--text); }
p:last-child { margin-bottom: 0; }
strong { color: var(--text); font-weight: 500; }
em { color: var(--text-dim); font-style: italic; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol {
padding-left: 24px;
margin-bottom: 16px;
}
li { margin-bottom: 6px; color: var(--text); }
li:last-child { margin-bottom: 0; }
/* ── CALLOUT BOXES ── */
.callout {
border-left: 3px solid var(--teal);
background: rgba(63, 200, 160, 0.06);
padding: 14px 18px;
border-radius: 0 var(--r) var(--r) 0;
margin: 24px 0;
}
.callout.warn {
border-color: var(--orange);
background: rgba(255, 153, 64, 0.06);
}
.callout.info {
border-color: var(--purple);
background: rgba(157, 111, 255, 0.06);
}
.callout.tip {
border-color: var(--pink);
background: rgba(255, 92, 138, 0.06);
}
.callout-title {
font-family: var(--mono);
font-size: 9px;
letter-spacing: 2px;
text-transform: uppercase;
margin-bottom: 6px;
color: var(--teal);
}
.callout.warn .callout-title { color: var(--orange); }
.callout.info .callout-title { color: var(--purple); }
.callout.tip .callout-title { color: var(--pink); }
.callout p { margin: 0; font-size: 13px; }
/* ── CODE ── */
code {
font-family: var(--mono);
font-size: 12px;
background: var(--bg-code);
color: var(--orange);
padding: 2px 6px;
border-radius: 3px;
border: 1px solid var(--border-dim);
}
.code-block {
position: relative;
margin: 20px 0;
}
.code-label {
font-family: var(--mono);
font-size: 9px;
letter-spacing: 2px;
text-transform: uppercase;
color: var(--text-dark);
background: var(--bg-code);
border: 1px solid var(--border);
border-bottom: none;
padding: 6px 14px;
border-radius: var(--r) var(--r) 0 0;
display: inline-block;
}
pre {
background: var(--bg-code);
border: 1px solid var(--border);
border-radius: var(--r);
padding: 20px 22px;
overflow-x: auto;
font-family: var(--mono);
font-size: 12.5px;
line-height: 1.7;
tab-size: 4;
}
.code-label + pre {
border-radius: 0 var(--r) var(--r) var(--r);
}
pre .kw { color: var(--purple); }
pre .fn { color: var(--blue); }
pre .str { color: var(--green); }
pre .num { color: var(--orange); }
pre .cm { color: var(--text-dark); font-style: italic; }
pre .dec { color: var(--pink); }
pre .sig { color: var(--teal); }
pre .var { color: var(--text); }
/* copy button */
.code-block { position: relative; }
.copy-btn {
position: absolute;
top: 8px;
right: 8px;
background: var(--bg-hover);
border: 1px solid var(--border);
border-radius: 4px;
color: var(--text-dark);
font-family: var(--mono);
font-size: 9px;
letter-spacing: 1px;
padding: 3px 8px;
cursor: pointer;
text-transform: uppercase;
transition: color .1s, border-color .1s;
z-index: 1;
}
.copy-btn:hover { color: var(--text); border-color: var(--border); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }
/* ── METHOD TABLE ── */
.method-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
font-size: 13px;
}
.method-table th {
font-family: var(--mono);
font-size: 9px;
letter-spacing: 2px;
text-transform: uppercase;
color: var(--text-dark);
text-align: left;
padding: 8px 12px;
border-bottom: 1px solid var(--border);
}
.method-table td {
padding: 10px 12px;
border-bottom: 1px solid var(--border-dim);
vertical-align: top;
}
.method-table tr:last-child td { border-bottom: none; }
.method-table tr:hover td { background: rgba(255,255,255,0.02); }
.method-table .m-name {
font-family: var(--mono);
font-size: 12px;
color: var(--blue);
white-space: nowrap;
}
.method-table .m-desc { color: var(--text-dim); line-height: 1.5; }
/* ── STEP GUIDE ── */
.step {
display: flex;
gap: 20px;
margin-bottom: 40px;
}
.step-num {
font-family: var(--mono);
font-size: 11px;
font-weight: 600;
color: var(--bg);
background: var(--pink);
width: 28px;
height: 28px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-top: 2px;
}
.step-body h3 { margin-top: 0; }
.step-body { flex: 1; }
/* ── PYTHON PRIMER CARDS ── */
.concept-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin: 20px 0;
}
@media (max-width: 640px) { .concept-grid { grid-template-columns: 1fr; } }
.concept-card {
background: var(--bg-panel);
border: 1px solid var(--border);
border-radius: var(--r);
padding: 16px;
}
.concept-card h4 { margin: 0 0 8px; }
.concept-card pre {
margin: 8px 0 0;
border: none;
background: var(--bg-code);
padding: 12px;
font-size: 11.5px;
}
/* ── SCALE TABLE ── */
.scale-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin: 16px 0;
}
@media (max-width: 640px) { .scale-grid { grid-template-columns: 1fr 1fr; } }
.scale-pill {
font-family: var(--mono);
font-size: 11px;
color: var(--teal);
background: rgba(63, 200, 160, 0.08);
border: 1px solid rgba(63, 200, 160, 0.2);
padding: 6px 10px;
border-radius: 4px;
text-align: center;
}
/* ── FOOTER ── */
footer {
border-top: 1px solid var(--border-dim);
padding: 40px 0;
margin-top: 80px;
color: var(--text-dark);
font-family: var(--mono);
font-size: 10px;
letter-spacing: 1px;
text-align: center;
}
</style>
</head>
<body>
<nav>
<span class="nav-logo">POMSKI</span>
<a href="#why">Why</a>
<a href="#setup">Setup</a>
<a href="#python">Python</a>
<a href="#model">Model</a>
<a href="#first">First Pattern</a>
<a href="#api">API</a>
<a href="#building">Building a Track</a>
<a href="#evolving">Evolution</a>
<a href="#signals">Signals</a>
<a href="#algorithmic">Algorithmic</a>
<a href="#live">Ableton</a>
<a href="#performance">Performance</a>
<a href="#apifeeds">API Feeds</a>
<a href="#music21">music21</a>
</nav>
<div class="container">
<!-- HERO -->
<div class="hero">
<div class="hero-tag">Complete Tutorial</div>
<h1>Live-Code<br>Your Music.</h1>
<p class="hero-sub">
POMSKI is a Python-based live-coding environment for real-time MIDI composition.
Write and rewrite patterns while the music plays — no stopping, no rendering, no waiting.
<br>Windows users: Get the POMSKI setup installer here: <a href="https://thinkinsound.itch.io/pomski">Itch.IO</a>
<br>Mac users: You can build from source by cloning the package from <a href="https://github.com/ThinkInSound/POMSKI"> here</a>.
</p>
</div>
<!-- ─────────────────────────── WHY ─────────────────────────── -->
<section class="section" id="why">
<div class="section-tag">01 — Philosophy</div>
<h2>Why live-code music?</h2>
<p>
Most music software asks you to <strong>build first, then listen</strong>. You place notes on a grid,
render an audio file, press play, realise something is wrong, go back to the grid.
The feedback loop is slow, and the act of composition is disconnected from the act of listening.
</p>
<p>
POMSKI inverts this. You write a few lines of Python, press <code>Shift+Enter</code>, and the change
takes effect on the <em>very next bar</em> — while everything else keeps playing. The music is always
running. You are always inside it.
</p>
<h3>The live-coding philosophy</h3>
<p>
Live coding is a practice borrowed from computer science performance art (the Algorave scene, SuperCollider,
TidalCycles). Its central insight is that <strong>code is notation</strong> — a precise, expressive
language for describing musical pattern. Unlike a piano roll, code can describe not just a specific
sequence of notes but the <em>rules that generate</em> a sequence: mathematical systems, probability,
chaos, feedback loops.
</p>
<div class="callout info">
<div class="callout-title">The key shift</div>
<p>In a DAW you compose a <em>performance</em>. In POMSKI you <em>perform</em> a composition.
The score and the concert are the same event.</p>
</div>
<h3>What POMSKI adds to this</h3>
<ul>
<li><strong>MIDI-native</strong> — POMSKI speaks directly to your instruments and DAW via MIDI. No audio engine to worry about.</li>
<li><strong>Browser UI</strong> — a visual dashboard at <code>http://localhost:8080</code> lets you see patterns, mute channels, monitor signals, and run REPL commands without touching the terminal.</li>
<li><strong>Ableton Live bridge</strong> — two-way communication with Live. Trigger clips, read track volumes, fire scenes — all from code.</li>
<li><strong>Designed for performers</strong> — every hot-swap takes effect on the next bar boundary. Nothing clicks, stutters, or loses sync.</li>
</ul>
<h3>Who is this for?</h3>
<ul>
<li>Producers who want to break out of the static session view and improvise structurally</li>
<li>Electronic musicians tired of loop-based thinking who want generative variation without Max/MSP complexity</li>
<li>Composers exploring algorithmic systems (cellular automata, chaos theory, Euclidean rhythms) without a PhD in DSP</li>
<li>Performers who want a live tool that is completely transparent — every sound is a line of readable code</li>
</ul>
<div class="callout tip">
<div class="callout-title">You do not need to be a programmer</div>
<p>You need to understand about 8 Python concepts. All of them are explained in the
<a href="#python">Python Primer</a> section. If you can write a grocery list, you can write a POMSKI pattern.</p>
</div>
</section>
<!-- ─────────────────────────── SETUP ─────────────────────────── -->
<section class="section" id="setup">
<div class="section-tag">02 — Getting Started</div>
<h2>Setup & first run</h2>
<h3>Prerequisites</h3>
<ul>
<li>Python 3.10 or newer</li>
<li>A MIDI output device or virtual MIDI port (e.g. <strong>loopMIDI</strong> on Windows, <strong>IAC Driver</strong> on macOS)</li>
<li>A DAW or synthesizer listening on that MIDI port</li>
<li>Optional: <a href="https://github.com/ideoforms/AbletonOSC" target="_blank">AbletonOSC</a> for the Ableton Live bridge</li>
</ul>
<div class="callout warn">
<div class="callout-title">LoopBe internal MIDI (Windows)</div>
<p>If using LoopBe as your virtual MIDI port, its feedback protection will silently mute output if
it detects a loop. Check the LoopBe tray icon if MIDI goes silent unexpectedly.</p>
</div>
<h3>Running the template</h3>
<div class="code-block">
<div class="code-label">Terminal</div>
<pre><span class="cm"># From the project directory:</span>
<span class="var">python</span> examples/pomski_template.py</pre>
</div>
<p>You will see startup messages. Then open your browser to <strong>http://localhost:8080</strong>.</p>
<h3>The web UI layout</h3>
<ul>
<li><strong>Top bar</strong> — BPM (drag to change), bar counter, beat, current key and chord, TAP tempo button</li>
<li><strong>Editor panel (left)</strong> — write and send code to the live REPL. <code>Shift+Enter</code> sends the current block. <code>Ctrl+Shift+Enter</code> sends the whole editor. <code>Ctrl+↑/↓</code> scrolls command history.</li>
<li><strong>Log panel (below editor)</strong> — shows sent commands, REPL results, and errors</li>
<li><strong>Patterns tab</strong> — visual grid of all 16 active pattern slots. Click the × to clear a slot.</li>
<li><strong>Signals tab</strong> — live scrolling graphs of all active modulators (LFOs, Perlin noise, etc.)</li>
<li><strong>Refs tab</strong> — copy-ready code examples for every algorithmic method</li>
<li><strong>Prefs tab</strong> — MIDI device selection, record button, theme toggle</li>
</ul>
<div class="callout">
<div class="callout-title">Quick test</div>
<p>Copy this into the editor and press <code>Shift+Enter</code>. You should hear a metronome-like kick on MIDI channel 1.</p>
</div>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">0</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">60</span>, <span class="var">beat</span>=<span class="num">0</span>)</pre>
</div>
</section>
<!-- ─────────────────────────── PYTHON PRIMER ─────────────────────────── -->
<section class="section" id="python">
<div class="section-tag">03 — Python Primer</div>
<h2>Python for musicians</h2>
<p>
You need exactly eight Python concepts to use POMSKI. Nothing else is required.
</p>
<div class="concept-grid">
<div class="concept-card">
<h4>Variables</h4>
<p style="font-size:12px;color:var(--text-dim)">Store a value and reuse it by name.</p>
<pre><span class="var">root</span> = <span class="num">60</span> <span class="cm"># middle C</span>
<span class="var">speed</span> = <span class="num">0.25</span> <span class="cm"># quarter note</span>
<span class="var">scale</span> = <span class="str">"dorian"</span></pre>
</div>
<div class="concept-card">
<h4>Functions (def)</h4>
<p style="font-size:12px;color:var(--text-dim)">A named block of code that runs when called.</p>
<pre><span class="kw">def</span> <span class="fn">greet</span>():
<span class="fn">print</span>(<span class="str">"hello"</span>)
<span class="fn">greet</span>() <span class="cm"># runs it</span></pre>
</div>
<div class="concept-card">
<h4>The @ Decorator</h4>
<p style="font-size:12px;color:var(--text-dim)">Wraps a function with extra behaviour. This is how POMSKI registers patterns.</p>
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">0</span>)
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
... <span class="cm"># your pattern here</span></pre>
</div>
<div class="concept-card">
<h4>For Loops</h4>
<p style="font-size:12px;color:var(--text-dim)">Repeat an action a set number of times.</p>
<pre><span class="kw">for</span> <span class="var">i</span> <span class="kw">in</span> <span class="fn">range</span>(<span class="num">4</span>):
<span class="cm"># runs 4 times: i=0,1,2,3</span>
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">60</span>, <span class="var">beat</span>=<span class="var">i</span>)</pre>
</div>
<div class="concept-card">
<h4>Lists</h4>
<p style="font-size:12px;color:var(--text-dim)">An ordered collection of values. Access items by index (starting at 0).</p>
<pre><span class="var">notes</span> = [<span class="num">60</span>, <span class="num">63</span>, <span class="num">67</span>, <span class="num">70</span>]
<span class="var">notes</span>[<span class="num">0</span>] <span class="cm"># → 60 (first)</span>
<span class="var">notes</span>[<span class="num">2</span>] <span class="cm"># → 67 (third)</span></pre>
</div>
<div class="concept-card">
<h4>Modulo %</h4>
<p style="font-size:12px;color:var(--text-dim)">Returns the remainder after division. Essential for cycling through lists.</p>
<pre><span class="num">7</span> % <span class="num">4</span> <span class="cm"># → 3</span>
<span class="num">8</span> % <span class="num">4</span> <span class="cm"># → 0 (wraps back)</span>
<span class="cm"># Cycle through a list:</span>
<span class="var">notes</span>[<span class="var">p</span>.<span class="var">cycle</span> % <span class="fn">len</span>(<span class="var">notes</span>)]</pre>
</div>
<div class="concept-card">
<h4>Conditionals (if)</h4>
<p style="font-size:12px;color:var(--text-dim)">Run code only when a condition is true.</p>
<pre><span class="kw">if</span> <span class="var">p</span>.<span class="var">cycle</span> % <span class="num">4</span> == <span class="num">0</span>:
<span class="cm"># runs every 4 loops</span>
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">72</span>, <span class="var">beat</span>=<span class="num">0</span>)</pre>
</div>
<div class="concept-card">
<h4>Enumerate</h4>
<p style="font-size:12px;color:var(--text-dim)">Loop through a list and get both the index and the value.</p>
<pre><span class="var">pitches</span> = [<span class="num">60</span>, <span class="num">64</span>, <span class="num">67</span>]
<span class="kw">for</span> <span class="var">i</span>, <span class="var">pitch</span> <span class="kw">in</span> <span class="fn">enumerate</span>(<span class="var">pitches</span>):
<span class="var">p</span>.<span class="fn">note</span>(<span class="var">pitch</span>, <span class="var">beat</span>=<span class="var">i</span>)</pre>
</div>
</div>
<h3>The p object</h3>
<p>
Inside every pattern function, <code>p</code> is your <strong>pattern builder</strong>. It is passed in automatically —
you never create it yourself. Every method you call on it (<code>p.note()</code>, <code>p.euclidean()</code>, etc.)
adds events to the current loop cycle of that pattern.
</p>
<p>
<code>p</code> has a few useful read-only attributes:
</p>
<table class="method-table">
<tr><th>Attribute</th><th>Type</th><th>Description</th></tr>
<tr><td class="m-name">p.cycle</td><td><code>int</code></td><td class="m-desc">How many times this pattern has looped since it was defined. Starts at 0. Use it for evolving patterns over time.</td></tr>
<tr><td class="m-name">p.bar</td><td><code>int</code></td><td class="m-desc">The global bar number at the time this pattern fired.</td></tr>
<tr><td class="m-name">p.rng</td><td><code>Random</code></td><td class="m-desc">A seeded random number generator. Use <code>p.rng.random()</code>, <code>p.rng.choice(list)</code>, <code>p.rng.randint(a,b)</code>. Reproducible — same seed every time the pattern restarts.</td></tr>
<tr><td class="m-name">p.section</td><td><code>SectionInfo</code></td><td class="m-desc">Current form section (name, bar within section, total bars). <code>None</code> if no form is defined.</td></tr>
<tr><td class="m-name">p.data</td><td><code>dict</code></td><td class="m-desc">Direct reference to <code>composition.data</code>. Use it to read Live values, signals, or cross-pattern state.</td></tr>
</table>
<div class="callout warn">
<div class="callout-title">p.cycle is an integer, not a function</div>
<p><code>p.cycle</code> is a number. Do <strong>not</strong> write <code>p.cycle([60, 63])</code> —
that will throw a TypeError. To cycle through a list, write <code>my_list[p.cycle % len(my_list)]</code>.</p>
</div>
<h3>MIDI pitch numbers</h3>
<p>
POMSKI uses raw MIDI pitch numbers (0–127). Middle C is 60. Each semitone is +1 or −1.
An octave is 12 semitones. Common reference points:
</p>
<table class="method-table">
<tr><th>Note</th><th>MIDI#</th><th>Note</th><th>MIDI#</th><th>Note</th><th>MIDI#</th></tr>
<tr><td class="m-name">C3</td><td>48</td><td class="m-name">C4 (middle C)</td><td>60</td><td class="m-name">C5</td><td>72</td></tr>
<tr><td class="m-name">D3</td><td>50</td><td class="m-name">D4</td><td>62</td><td class="m-name">G4</td><td>67</td></tr>
<tr><td class="m-name">E3</td><td>52</td><td class="m-name">E4</td><td>64</td><td class="m-name">A4</td><td>69</td></tr>
<tr><td class="m-name">F3</td><td>53</td><td class="m-name">F4</td><td>65</td><td class="m-name">Bb4</td><td>70</td></tr>
</table>
</section>
<!-- ─────────────────────────── MODEL ─────────────────────────── -->
<section class="section" id="model">
<div class="section-tag">04 — Core Model</div>
<h2>How POMSKI works</h2>
<h3>The composition object</h3>
<p>
Everything lives inside a <code>composition</code>. It holds the clock, the key, the harmony, and all
the running patterns. You start it at the bottom of your script with <code>composition.play()</code>,
which blocks forever and runs the event loop.
</p>
<div class="code-block">
<pre><span class="var">composition</span> = <span class="var">subsequence</span>.<span class="fn">Composition</span>(<span class="var">key</span>=<span class="str">"C"</span>, <span class="var">bpm</span>=<span class="num">120</span>)
<span class="var">composition</span>.<span class="fn">harmony</span>(<span class="var">style</span>=<span class="str">"functional_major"</span>, <span class="var">cycle_beats</span>=<span class="num">4</span>)
<span class="var">composition</span>.<span class="fn">web_ui</span>() <span class="cm"># start the browser dashboard</span>
<span class="var">composition</span>.<span class="fn">live</span>() <span class="cm"># start the REPL server on port 5555</span>
<span class="var">composition</span>.<span class="fn">play</span>() <span class="cm"># always last — starts the clock</span></pre>
</div>
<h3>Pattern slots</h3>
<p>
The template defines 16 slots — <code>ch1</code> through <code>ch16</code> — one per MIDI channel.
Each slot is a silent placeholder. To make a slot play, you <strong>redefine it by name</strong>
from the browser editor. The scheduler detects the same function name and swaps the new pattern
in at the next bar boundary without interrupting playback.
</p>
<h3>Channels</h3>
<p>
POMSKI channels are <strong>0-indexed</strong>. MIDI channel 1 = <code>channel=0</code>,
channel 10 (drums) = <code>channel=9</code>. This is a common source of confusion — the template
assigns slots in order, so <code>ch1</code> is <code>channel=0</code>, <code>ch10</code> is
<code>channel=9</code>.
</p>
<div class="callout">
<div class="callout-title">Auto-assign</div>
<p>If you use a <em>new</em> function name (one not already in the 16 slots), POMSKI automatically
steals the first empty slot and puts your pattern there. You can use any name you like.</p>
</div>
<h3>Pattern length</h3>
<p>
<code>length</code> is in beats. <code>length=4</code> is one 4/4 bar.
<code>length=8</code> is two bars. <code>length=0.5</code> is a half-bar (2 beats).
Patterns of different lengths run simultaneously and loop independently — a 3-beat and a 4-beat
pattern will phase against each other like a polyrhythm.
</p>
<h3>The hot-swap mechanism</h3>
<p>
When you send a redefined pattern from the browser, the live server executes the decorator.
If a pattern with that name is already running, POMSKI replaces its builder function on the
existing slot at the next bar boundary. The channel, MIDI routing, and sync all remain intact.
Nothing restarts. Nothing skips.
</p>
</section>
<!-- ─────────────────────────── FIRST PATTERN ─────────────────────────── -->
<section class="section" id="first">
<div class="section-tag">05 — First Steps</div>
<h2>Your first pattern</h2>
<h3>A single note</h3>
<p>The simplest possible pattern. One note on beat 0, looping every 4 beats.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">0</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">60</span>, <span class="var">beat</span>=<span class="num">0</span>)</pre>
</div>
<div class="callout tip">
<div class="callout-title">pat — shorter decorator</div>
<p>
<code>pat</code> is pre-loaded as an alias for <code>composition.pattern</code>.
The channel is the first positional argument and <code>length</code> defaults to 4,
so <code>@pat(0)</code> is equivalent to <code>@composition.pattern(channel=0, length=4)</code>.
</p>
<pre style="margin-top:8px;background:var(--bg-code);padding:12px;font-size:11.5px;"><span class="dec">@pat</span>(<span class="num">0</span>) <span class="cm"># channel 0, length 4</span>
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">60</span>, <span class="var">beat</span>=<span class="num">0</span>)
<span class="dec">@pat</span>(<span class="num">0</span>, <span class="num">8</span>) <span class="cm"># channel 0, length 8 beats</span>
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">60</span>, <span class="var">beat</span>=<span class="num">0</span>)</pre>
</div>
<h3>Adding notes</h3>
<p>Beat positions are in beats from the start of the pattern. Beat 0 = the downbeat.
Beat 0.5 = the "and" of beat 1. Beat 1 = beat 2 of the bar.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">0</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">60</span>, <span class="var">beat</span>=<span class="num">0</span>, <span class="var">velocity</span>=<span class="num">100</span>, <span class="var">duration</span>=<span class="num">0.4</span>)
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">64</span>, <span class="var">beat</span>=<span class="num">1</span>, <span class="var">velocity</span>=<span class="num">80</span>, <span class="var">duration</span>=<span class="num">0.4</span>)
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">67</span>, <span class="var">beat</span>=<span class="num">2</span>, <span class="var">velocity</span>=<span class="num">80</span>, <span class="var">duration</span>=<span class="num">0.4</span>)
<span class="var">p</span>.<span class="fn">note</span>(<span class="num">60</span>, <span class="var">beat</span>=<span class="num">3</span>, <span class="var">velocity</span>=<span class="num">60</span>, <span class="var">duration</span>=<span class="num">0.4</span>)</pre>
</div>
<h3>A drum pattern</h3>
<p>Drums go on <code>channel=9</code> (MIDI channel 10). Use <code>drum_note_map=gm_drums.GM_DRUM_MAP</code>
to use drum names instead of numbers.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">9</span>, <span class="var">length</span>=<span class="num">4</span>, <span class="var">drum_note_map</span>=<span class="var">gm_drums</span>.<span class="var">GM_DRUM_MAP</span>)
<span class="kw">def</span> <span class="fn">ch10</span>(<span class="var">p</span>):
<span class="cm"># hit_steps places hits at 16th-note grid positions (0–15)</span>
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"kick_1"</span>, [<span class="num">0</span>, <span class="num">3</span>, <span class="num">8</span>, <span class="num">12</span>], <span class="var">velocity</span>=<span class="num">110</span>)
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"snare_1"</span>, [<span class="num">4</span>, <span class="num">12</span>], <span class="var">velocity</span>=<span class="num">100</span>)
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"hi_hat_closed"</span>, <span class="fn">range</span>(<span class="num">16</span>), <span class="var">velocity</span>=<span class="num">70</span>)
<span class="var">p</span>.<span class="fn">velocity_shape</span>(<span class="var">low</span>=<span class="num">55</span>, <span class="var">high</span>=<span class="num">90</span>) <span class="cm"># humanise velocity</span></pre>
</div>
<h3>The seq() shorthand</h3>
<p>Write a melody in Sonic Pi style — space-separated pitch numbers with <code>_</code> for rests.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">1</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch2</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">seq</span>(<span class="str">"60 _ 63 _ 65 67 _ 63"</span>, <span class="var">velocity</span>=<span class="num">80</span>)
<span class="cm"># plays: C4, rest, Eb4, rest, F4, G4, rest, Eb4</span>
<span class="cm"># each token is one eighth note (length/8 = 0.5 beats)</span></pre>
</div>
<h3>Clearing a pattern</h3>
<p>To silence a slot without stopping playback, click the × button on that slot in the
Patterns tab, or send a blank definition:</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">0</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="kw">pass</span> <span class="cm"># empty body = silence</span></pre>
</div>
</section>
<!-- ─────────────────────────── API ─────────────────────────── -->
<section class="section" id="api">
<div class="section-tag">06 — API Reference</div>
<h2>The p. method reference</h2>
<h3>Placing notes</h3>
<table class="method-table">
<tr><th>Method</th><th>Description</th></tr>
<tr>
<td class="m-name">p.note(pitch, beat, velocity, duration)</td>
<td class="m-desc">Place a single note. <code>pitch</code>: MIDI 0–127. <code>beat</code>: position in beats from start of pattern. <code>velocity</code>: 0–127 (default 100). <code>duration</code>: length in beats (default 0.5).</td>
</tr>
<tr>
<td class="m-name">p.hit_steps(pitch, steps, velocity)</td>
<td class="m-desc">Place hits at 16th-note grid positions. <code>steps</code> is a list of indices 0–15. With <code>drum_note_map</code>, <code>pitch</code> can be a drum name string like <code>"kick_1"</code>.</td>
</tr>
<tr>
<td class="m-name">p.sequence(steps, pitches, velocities, durations)</td>
<td class="m-desc">Pair a list of grid positions with a list of pitches. Positions are 16th-note indices; pitch list cycles if shorter than steps list. Parameters are <code>velocities</code> and <code>durations</code> (plural) — pass a single int/float or a list.</td>
</tr>
<tr>
<td class="m-name">p.seq(notation, velocity)</td>
<td class="m-desc">Sonic Pi style: space-separated numbers, <code>_</code> for rests. All tokens are equal duration (pattern length / token count). Example: <code>"60 _ 62 64"</code>. Note: <code>p.seq()</code> has no <code>duration</code> parameter — note length is set automatically.</td>
</tr>
</table>
<h3>Rhythmic tools</h3>
<table class="method-table">
<tr><th>Method</th><th>Description</th></tr>
<tr>
<td class="m-name">p.euclidean(pitch, pulses, velocity, duration)</td>
<td class="m-desc">Distribute <code>pulses</code> hits as evenly as possible across the pattern's grid (Björklund algorithm). The grid size is derived automatically from the pattern's <code>length</code>. Classic for polyrhythmic layering.</td>
</tr>
<tr>
<td class="m-name">p.bresenham(pitch, pulses, velocity, duration)</td>
<td class="m-desc">Alternate even distribution using the Bresenham line algorithm — creates slightly different accent patterns than Euclidean. Grid size is derived automatically from pattern length.</td>
</tr>
<tr>
<td class="m-name">p.hit_steps() with range()</td>
<td class="m-desc">For quick straight 8ths or 16ths: <code>range(0, 16, 2)</code> = every other step (8th notes). <code>range(16)</code> = all 16 steps.</td>
</tr>
</table>
<h3>Modifiers — call these after placing notes</h3>
<table class="method-table">
<tr><th>Method</th><th>Description</th></tr>
<tr>
<td class="m-name">p.randomize(timing, velocity)</td>
<td class="m-desc">Add human-feel micro-timing and velocity variation. <code>timing=0.02</code> means ±2% of a beat. <code>velocity=0.05</code> means ±5% velocity.</td>
</tr>
<tr>
<td class="m-name">p.dropout(probability)</td>
<td class="m-desc">Randomly remove notes. <code>p.dropout(0.2)</code> = 20% chance each note is silenced on this cycle. Adds natural variation without changing the underlying pattern.</td>
</tr>
<tr>
<td class="m-name">p.quantize(key, mode)</td>
<td class="m-desc">Snap all notes to the nearest pitch in a scale. Key is a note name (<code>"C"</code>, <code>"F#"</code>, <code>"Bb"</code>). Mode is a scale name (<code>"ionian"</code>, <code>"dorian"</code>, <code>"minor"</code>, <code>"harmonic_minor"</code>, etc.).</td>
</tr>
<tr>
<td class="m-name">p.quantize_m21(key, scale_name)</td>
<td class="m-desc">Like <code>p.quantize()</code> but unlocks Music21's full scale library. Use for ragas, octatonic, whole-tone, and other exotic scales. Requires <code>pip install music21</code>.</td>
</tr>
<tr>
<td class="m-name">p.transpose(semitones)</td>
<td class="m-desc">Shift all notes up or down by a fixed number of semitones. Combine with <code>p.cycle</code> for automatic transposition.</td>
</tr>
<tr>
<td class="m-name">p.shift(steps)</td>
<td class="m-desc">Move all notes forward or backward in time by <code>steps</code> 16th-note positions. Useful for polyrhythmic offset against other patterns.</td>
</tr>
<tr>
<td class="m-name">p.reverse()</td>
<td class="m-desc">Flip the pattern backwards in time.</td>
</tr>
<tr>
<td class="m-name">p.velocity_shape(low, high)</td>
<td class="m-desc">Re-scale all velocities to fit within a <code>low–high</code> range, preserving relative dynamics. Great for humanising step-sequenced drum patterns.</td>
</tr>
<tr>
<td class="m-name">p.thin(pitch, strategy, amount)</td>
<td class="m-desc">Remove notes for a specific pitch or drum name based on rhythmic position. <code>amount=0.5</code> removes roughly half; <code>amount=1.0</code> removes all qualifying notes. Strategies: <code>"strength"</code> (default — weakest positions drop first), <code>"sixteenths"</code>, <code>"offbeat"</code>, <code>"e_and_a"</code>, <code>"downbeat"</code>, <code>"upbeat"</code>, <code>"uniform"</code>. Unlike <code>p.dropout()</code>, targets one instrument and respects rhythmic position.</td>
</tr>
</table>
<h3>Loading from files</h3>
<table class="method-table">
<tr><th>Method</th><th>Description</th></tr>
<tr>
<td class="m-name">p.from_midi(filepath, track, channel, pitch_offset, velocity, duration)</td>
<td class="m-desc">Read notes from a <code>.mid</code> file and place them in the pattern. Timing is normalised to beat 0 and wrapped to pattern length. <code>track</code> is the zero-based track index. <code>pitch_offset</code> transposes all loaded notes.</td>
</tr>
</table>
</section>
<!-- ─────────────────────────── BUILDING A TRACK ─────────────────────────── -->
<section class="section" id="building">
<div class="section-tag">07 — Walkthrough</div>
<h2>Building a track from scratch</h2>
<p>Here is a complete step-by-step process for building a live track in POMSKI, starting from silence.
Each step is sent as a separate block from the editor — the previous patterns keep playing while you add new ones.</p>
<div class="step">
<div class="step-num">1</div>
<div class="step-body">
<h3>Lay the drums</h3>
<p>Start with rhythm. Keep it simple — kick and hi-hat first. Add the snare in a moment.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">9</span>, <span class="var">length</span>=<span class="num">4</span>, <span class="var">drum_note_map</span>=<span class="var">gm_drums</span>.<span class="var">GM_DRUM_MAP</span>)
<span class="kw">def</span> <span class="fn">ch10</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"kick_1"</span>, [<span class="num">0</span>, <span class="num">8</span>], <span class="var">velocity</span>=<span class="num">110</span>)
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"hi_hat_closed"</span>, <span class="fn">range</span>(<span class="num">16</span>), <span class="var">velocity</span>=<span class="num">65</span>)
<span class="var">p</span>.<span class="fn">velocity_shape</span>(<span class="var">low</span>=<span class="num">50</span>, <span class="var">high</span>=<span class="num">80</span>)</pre>
</div>
</div>
</div>
<div class="step">
<div class="step-num">2</div>
<div class="step-body">
<h3>Add a bass line</h3>
<p>A repeating root note with a rhythmic pattern. Low octave, short duration for punch.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">1</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch2</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="num">36</span>, [<span class="num">0</span>, <span class="num">3</span>, <span class="num">8</span>, <span class="num">11</span>, <span class="num">14</span>], <span class="var">velocity</span>=<span class="num">100</span>) <span class="cm"># C2</span></pre>
</div>
</div>
</div>
<div class="step">
<div class="step-num">3</div>
<div class="step-body">
<h3>Layer a melody</h3>
<p>A simple ascending figure using <code>p.seq()</code>. The <code>_</code> rests give it breathing room.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">0</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">seq</span>(<span class="str">"60 _ 63 65 _ 67 _ 65"</span>, <span class="var">velocity</span>=<span class="num">80</span>)
<span class="var">p</span>.<span class="fn">randomize</span>(<span class="var">timing</span>=<span class="num">0.01</span>, <span class="var">velocity</span>=<span class="num">0.04</span>)</pre>
</div>
</div>
</div>
<div class="step">
<div class="step-num">4</div>
<div class="step-body">
<h3>Evolve the drums</h3>
<p>Redefine ch10 with more elements. The existing kick and hi-hat keep playing until the bar ends, then this replaces them.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">9</span>, <span class="var">length</span>=<span class="num">4</span>, <span class="var">drum_note_map</span>=<span class="var">gm_drums</span>.<span class="var">GM_DRUM_MAP</span>)
<span class="kw">def</span> <span class="fn">ch10</span>(<span class="var">p</span>):
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"kick_1"</span>, [<span class="num">0</span>, <span class="num">3</span>, <span class="num">8</span>, <span class="num">12</span>], <span class="var">velocity</span>=<span class="num">110</span>)
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"snare_1"</span>, [<span class="num">4</span>, <span class="num">12</span>], <span class="var">velocity</span>=<span class="num">100</span>)
<span class="var">p</span>.<span class="fn">hit_steps</span>(<span class="str">"hi_hat_closed"</span>, <span class="fn">range</span>(<span class="num">16</span>), <span class="var">velocity</span>=<span class="num">70</span>)
<span class="var">p</span>.<span class="fn">velocity_shape</span>(<span class="var">low</span>=<span class="num">55</span>, <span class="var">high</span>=<span class="num">90</span>)</pre>
</div>
</div>
</div>
<div class="step">
<div class="step-num">5</div>
<div class="step-body">
<h3>Add variation with p.cycle</h3>
<p>Make the melody change every 4 loops — play one phrase for 4 bars, then another.</p>
<div class="code-block">
<pre><span class="dec">@composition.pattern</span>(<span class="var">channel</span>=<span class="num">0</span>, <span class="var">length</span>=<span class="num">4</span>)
<span class="kw">def</span> <span class="fn">ch1</span>(<span class="var">p</span>):
<span class="var">phrases</span> = [
<span class="str">"60 _ 63 65 _ 67 _ 65"</span>,
<span class="str">"67 _ 65 63 _ 60 _ 63"</span>,
<span class="str">"65 67 _ 70 _ 67 65 _"</span>,
]
<span class="var">phrase</span> = <span class="var">phrases</span>[(<span class="var">p</span>.<span class="var">cycle</span> // <span class="num">4</span>) % <span class="fn">len</span>(<span class="var">phrases</span>)]
<span class="var">p</span>.<span class="fn">seq</span>(<span class="var">phrase</span>, <span class="var">velocity</span>=<span class="num">80</span>)
<span class="var">p</span>.<span class="fn">randomize</span>(<span class="var">timing</span>=<span class="num">0.01</span>)</pre>
</div>
</div>
</div>
<div class="step">
<div class="step-num">6</div>
<div class="step-body">
<h3>Mute and unmute for arrangement</h3>
<p>Use the Patterns tab mute buttons, or type these into the Quick Command box at the bottom of the log panel:</p>
<div class="code-block">
<pre><span class="var">composition</span>.<span class="fn">mute</span>(<span class="str">"ch10"</span>) <span class="cm"># silence drums</span>
<span class="var">composition</span>.<span class="fn">unmute</span>(<span class="str">"ch10"</span>) <span class="cm"># bring them back</span></pre>
</div>
</div>
</div>
</section>
<!-- ─────────────────────────── EVOLVING ─────────────────────────── -->
<section class="section" id="evolving">