-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
229 lines (229 loc) · 19 KB
/
index.html
File metadata and controls
229 lines (229 loc) · 19 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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<meta name="author" content="Jonas Köhler" />
<meta name="author" content="Anyere Bendrien" />
<meta name="dcterms.date" content="2026-03-23" />
<title>krach</title>
<link rel="stylesheet" href="reset.css" />
<link rel="stylesheet" href="index.css" />
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ color: #cccccc; background-color: #303030; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ffcfaf; } /* Alert */
code span.an { color: #7f9f7f; font-weight: bold; } /* Annotation */
code span.at { } /* Attribute */
code span.bn { color: #dca3a3; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #f0dfaf; } /* ControlFlow */
code span.ch { color: #dca3a3; } /* Char */
code span.cn { color: #dca3a3; font-weight: bold; } /* Constant */
code span.co { color: #7f9f7f; } /* Comment */
code span.cv { color: #7f9f7f; font-weight: bold; } /* CommentVar */
code span.do { color: #7f9f7f; } /* Documentation */
code span.dt { color: #dfdfbf; } /* DataType */
code span.dv { color: #dcdccc; } /* DecVal */
code span.er { color: #c3bf9f; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #c0bed1; } /* Float */
code span.fu { color: #efef8f; } /* Function */
code span.im { } /* Import */
code span.in { color: #7f9f7f; font-weight: bold; } /* Information */
code span.kw { color: #f0dfaf; } /* Keyword */
code span.op { color: #f0efd0; } /* Operator */
code span.ot { color: #efef8f; } /* Other */
code span.pp { color: #ffcfaf; font-weight: bold; } /* Preprocessor */
code span.sc { color: #dca3a3; } /* SpecialChar */
code span.ss { color: #cc9393; } /* SpecialString */
code span.st { color: #cc9393; } /* String */
code span.va { } /* Variable */
code span.vs { color: #cc9393; } /* VerbatimString */
code span.wa { color: #7f9f7f; font-weight: bold; } /* Warning */
</style>
</head>
<body>
<table class="header">
<tr>
<td colspan="2" rowspan="2" class="width-auto">
<h1 class="title">krach</h1>
<span class="subtitle">live coding audio</span>
</td>
<th>Version</th>
<td class="width-min">v1.0</td>
</tr>
<tr>
<th>Updated</th>
<td class="width-min"><time style="white-space: pre;">2026-03-23</time></td>
</tr>
<!-- <tr>
<th class="width-min">Author</th>
<td class="width-auto"><a href="https://argmin.xyzhttps://github.com/Bendrien"><cite>Jonas
KöhlerAnyere Bendrien</cite></a></td>
<th class="width-min">License</th>
<td>MIT</td>
</tr> -->
</table>
<!-- <label class="debug-toggle-label"><input type="checkbox" class="debug-toggle" /> Debug mode</label>/ -->
<nav id="TOC" role="doc-toc">
<h2 id="toc-title">Contents</h2>
<ul class="incremental">
<li><a href="#what-is-krach" id="toc-what-is-krach">What is
krach?</a></li>
<li><a href="#how-it-works" id="toc-how-it-works">How it works</a></li>
<li><a href="#operator-dsl" id="toc-operator-dsl">Operator DSL</a></li>
<li><a href="#synth-design" id="toc-synth-design">Synth design</a></li>
<li><a href="#pattern-algebra" id="toc-pattern-algebra">Pattern
algebra</a></li>
<li><a href="#architecture" id="toc-architecture">Architecture</a></li>
<li><a href="#install" id="toc-install">Install</a></li>
<li><a href="#links" id="toc-links">Links</a></li>
<li><a href="#credits" id="toc-credits">Credits</a></li>
</ul>
</nav>
<h2 id="what-is-krach">What is krach?</h2>
<p>A live coding audio system. Write synths in Python, wire them as a
graph, sequence with composable patterns, hear changes instantly.</p>
<div class="sourceCode" id="cb1"><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Define a synth — just a Python function</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> acid_bass() <span class="op">-></span> krs.Signal:</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> freq <span class="op">=</span> krs.control(<span class="st">"freq"</span>, <span class="fl">55.0</span>, <span class="fl">20.0</span>, <span class="fl">800.0</span>)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> gate <span class="op">=</span> krs.control(<span class="st">"gate"</span>, <span class="fl">0.0</span>, <span class="fl">0.0</span>, <span class="fl">1.0</span>)</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> cutoff <span class="op">=</span> krs.control(<span class="st">"cutoff"</span>, <span class="fl">800.0</span>, <span class="fl">100.0</span>, <span class="fl">4000.0</span>)</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> env <span class="op">=</span> krs.adsr(<span class="fl">0.005</span>, <span class="fl">0.15</span>, <span class="fl">0.3</span>, <span class="fl">0.08</span>, gate)</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> krs.lowpass(krs.saw(freq), cutoff) <span class="op">*</span> env <span class="op">*</span> <span class="fl">0.55</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="co"># Define an effect — takes audio input</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> reverb(inp: krs.Signal) <span class="op">-></span> krs.Signal:</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> room <span class="op">=</span> krs.control(<span class="st">"room"</span>, <span class="fl">0.7</span>, <span class="fl">0.0</span>, <span class="fl">1.0</span>)</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> krs.reverb(inp, room) <span class="op">*</span> <span class="fl">0.8</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a><span class="co"># Create nodes, route, play</span></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a>bass <span class="op">=</span> kr.node(<span class="st">"bass"</span>, acid_bass, gain<span class="op">=</span><span class="fl">0.3</span>)</span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a>verb <span class="op">=</span> kr.node(<span class="st">"verb"</span>, reverb, gain<span class="op">=</span><span class="fl">0.3</span>)</span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a>bass <span class="op">>></span> verb <span class="co"># route signal</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a>bass <span class="op">@</span> kr.seq(<span class="st">"A2"</span>, <span class="st">"D3"</span>, <span class="va">None</span>, <span class="st">"E2"</span>).over(<span class="dv">2</span>) <span class="co"># play pattern</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a>bass[<span class="st">"cutoff"</span>] <span class="op">=</span> <span class="dv">1200</span> <span class="co"># set control</span></span></code></pre></div>
<h2 id="how-it-works">How it works</h2>
<p><strong>Python</strong> defines synths and patterns.
<strong>Rust</strong> runs the engine. <strong>FAUST</strong>
JIT-compiles DSP to native audio.</p>
<pre><code>Python (define) Rust (execute) Audio
────────────── ────────────── ─────
kr.node("bass", fn) → FAUST JIT compile → CoreAudio
bass @ pattern → pattern → curves → block-rate automation
bass["cutoff"] = v → SetControl → node parameter
bass >> verb → graph rebuild + crossfade → seamless routing</code></pre>
<p>Two symbols: <code>kr</code> (the audio graph) and <code>krs</code>
(DSP primitives). That’s the entire API.</p>
<h2 id="operator-dsl">Operator DSL</h2>
<p>Everything is a node. Routing uses <code>>></code>. Patterns
use <code>@</code>. Controls use <code>[]</code>.</p>
<div class="sourceCode" id="cb3"><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>bass <span class="op">=</span> kr.node(<span class="st">"bass"</span>, acid_bass, gain<span class="op">=</span><span class="fl">0.3</span>)</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>verb <span class="op">=</span> kr.node(<span class="st">"verb"</span>, reverb, gain<span class="op">=</span><span class="fl">0.3</span>)</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>bass <span class="op">>></span> verb <span class="co"># route signal</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>bass <span class="op">>></span> (verb, <span class="fl">0.4</span>) <span class="co"># route with send level</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>bass <span class="op">@</span> kr.seq(<span class="st">"A2"</span>, <span class="st">"D3"</span>).over(<span class="dv">2</span>) <span class="co"># play pattern</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a>bass <span class="op">@</span> <span class="st">"A2 D3 ~ E2"</span> <span class="co"># mini-notation shorthand</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>bass <span class="op">@</span> <span class="va">None</span> <span class="co"># hush</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a>bass[<span class="st">"cutoff"</span>] <span class="op">=</span> <span class="dv">1200</span> <span class="co"># set control</span></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="cf">with</span> kr.transition(bars<span class="op">=</span><span class="dv">8</span>): <span class="co"># all changes fade over 8 bars</span></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a> bass[<span class="st">"gain"</span>] <span class="op">=</span> <span class="fl">0.8</span></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a> kr.tempo <span class="op">=</span> <span class="dv">140</span></span></code></pre></div>
<h2 id="synth-design">Synth design</h2>
<p>Write DSP functions in Python. They transpile to FAUST and
JIT-compile via LLVM. Hot reload on save. Auto-smoothing on all non-gate
parameters.</p>
<div class="sourceCode" id="cb4"><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> kick() <span class="op">-></span> krs.Signal:</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> gate <span class="op">=</span> krs.control(<span class="st">"gate"</span>, <span class="fl">0.0</span>, <span class="fl">0.0</span>, <span class="fl">1.0</span>)</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> env <span class="op">=</span> krs.adsr(<span class="fl">0.001</span>, <span class="fl">0.25</span>, <span class="fl">0.0</span>, <span class="fl">0.05</span>, gate)</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> krs.sine_osc(<span class="fl">55.0</span> <span class="op">+</span> env <span class="op">*</span> <span class="fl">200.0</span>) <span class="op">*</span> env <span class="op">*</span> <span class="fl">0.9</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a>kr.node(<span class="st">"kick"</span>, kick, gain<span class="op">=</span><span class="fl">0.8</span>)</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a>kr.play(<span class="st">"kick"</span>, kr.hit() <span class="op">*</span> <span class="dv">4</span>)</span></code></pre></div>
<h2 id="pattern-algebra">Pattern algebra</h2>
<p>TidalCycles-inspired composable patterns. Every operation returns a
pattern.</p>
<div class="sourceCode" id="cb5"><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>a <span class="op">+</span> b <span class="co"># sequence</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>a <span class="op">|</span> b <span class="co"># layer (simultaneous)</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>p <span class="op">*</span> <span class="dv">4</span> <span class="co"># repeat</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>p.over(<span class="dv">2</span>) <span class="co"># stretch to 2 cycles</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a>p.swing(<span class="fl">0.67</span>) <span class="co"># swing feel</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a>p.mask(<span class="st">"1 1 0 1"</span>) <span class="co"># suppress events</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a>p.sometimes(<span class="fl">0.3</span>, reverse) <span class="co"># probabilistic transform</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a>p.every(<span class="dv">4</span>, reverse) <span class="co"># transform every 4th cycle</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a>p.spread(<span class="dv">3</span>, <span class="dv">8</span>) <span class="co"># euclidean rhythm</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a>kr.struct(rhythm, melody) <span class="co"># impose rhythm onto melody</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a>kr.cat(a, b, c) <span class="co"># play each for 1 cycle, loop</span></span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a>kr.p(<span class="st">"x . x . x . . x"</span>) <span class="co"># mini-notation</span></span></code></pre></div>
<h2 id="architecture">Architecture</h2>
<p>Single-process Rust binary. Patterns compile to block-rate automation
curves (~172 updates/sec). Lock-free audio thread. FAUST hot-reload.</p>
<pre><code>noise/
├── audio-engine/ Rust — graph runtime, crossfade, automation
├── audio-faust/ Rust — FAUST LLVM JIT, hot reload
├── pattern-engine/ Rust — pattern sequencer, rational time, curve compiler
├── krach-engine/ Rust — unified binary (one process, one socket)
├── krach/ Python — live coding REPL, IR, DSP transpiler, patterns
└── krach-mcp/ Python — MCP server (25 tools for Claude Code to drive krach)</code></pre>
<h2 id="install">Install</h2>
<div class="sourceCode" id="cb7"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Prerequisites: macOS, Rust, Python 3.13+, uv, FAUST + LLVM</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">brew</span> install faust llvm</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">LLVM_SYS_181_PREFIX</span><span class="op">=</span><span class="va">$(</span><span class="ex">brew</span> <span class="at">--prefix</span> llvm<span class="va">)</span></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> clone https://github.com/krachio/noise.git <span class="kw">&&</span> <span class="bu">cd</span> noise</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="ex">cargo</span> build <span class="at">--release</span> <span class="at">-p</span> krach-engine</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> krach <span class="kw">&&</span> <span class="ex">uv</span> sync <span class="kw">&&</span> <span class="bu">cd</span> ..</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="ex">./bin/krach</span></span></code></pre></div>
<h2 id="links">Links</h2>
<p><a href="https://krach.io/noise/docs/">Documentation</a> · <a
href="https://github.com/krachio/noise">GitHub</a> · <a
href="https://krach.io/noise/try/">Try it</a> · <a
href="https://github.com/krachio/noise/blob/main/LICENSE">GPL-2.0-or-later</a></p>
<h2 id="credits">Credits</h2>
<p>Design: <a
href="https://github.com/owickstrom/the-monospace-web">the-monospace-web</a></p>
<div class="debug-grid"></div>
<script src="index.js"></script>
</body>
</html>