File size: 67,575 Bytes
b1ad943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{"schema": 1, "id": "teacher:concept:ugen-graph", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is a UGen graph in SuperCollider?"}, {"role": "assistant", "content": "A UGen graph is the directed acyclic graph of unit generators that a SynthDef describes: sources (SinOsc, WhiteNoise) feed processors (LPF, EnvGen, Pan2) and end at an output such as Out.ar. The language builds the graph; the server instantiates it once per Synth. A signal path is drawn by passing one UGen's output as another's input, and because UGens are multi-channel by default, the same expression can build a stereo or 8-channel graph depending on the arrays inside it."}]}
{"schema": 1, "id": "teacher:concept:ar-kr-ir", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between .ar, .kr and .ir?"}, {"role": "assistant", "content": "The rate method decides how often a UGen is evaluated. `.ar` runs at the audio rate, once per sample, and produces an audio signal. `.kr` runs at the control rate, once per block of 64 samples by default, so it is cheaper and is used for parameters that do not need sample accuracy. `.ir` is evaluated once when the Synth is created and then never again, for constants such as SampleRate.ir or a size. Using .kr where you need audio-rate modulation gives stepped, zipper-noise-like control; using .ar where .kr would do costs CPU."}]}
{"schema": 1, "id": "teacher:concept:mul-add", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Why does every UGen have mul and add arguments?"}, {"role": "assistant", "content": "They are a convenience applied to the UGen's output: the result is `ugens_result * mul + add`. So `SinOsc.ar(440, 0, 0.2)` is the same as `SinOsc.ar(440) * 0.2`, and `SinOsc.ar(440, 0, 0.5, 1800)` is usable directly as a frequency. They exist because multiplying and offsetting is so common that folding it into the UGen saves a node in the graph and a line in the source."}]}
{"schema": 1, "id": "teacher:concept:doneaction", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What does doneAction do?"}, {"role": "assistant", "content": "It tells the server what to do to the enclosing Synth when the UGen finishes. The one that matters most is `doneAction: 2`, which frees the Synth: that is how a percussive sound cleans itself up instead of leaking silent nodes. `doneAction: 0` does nothing, so the Synth keeps running. EnvGen, Line, XLine, LinePan and friends all accept it, which is why `EnvGen.kr(Env.perc(0.01, 1), doneAction: 2)` is the standard envelope idiom."}]}
{"schema": 1, "id": "teacher:concept:synth-vs-synthdef", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between a Synth and a SynthDef?"}, {"role": "assistant", "content": "A SynthDef is a definition: a compiled UGen graph with named controls, registered on the server once. A Synth is one running instance of that definition. You create the definition with `SynthDef(\\bell, { |freq = 440| ... }).add` and then instances with `Synth(\\bell, [\\freq, 660])`. Defining the same SynthDef twice replaces it for future instances; already running Synths keep the old graph until they are freed."}]}
{"schema": 1, "id": "teacher:concept:buses", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between an audio bus and a control bus?"}, {"role": "assistant", "content": "Both are numbered channels on the server used to move signal between nodes. An audio bus carries audio-rate signal and holds one or more audio channels; a control bus carries one value per block, like a parameter. You write with Out.ar / Out.kr and read with In.ar / In.kr, or with `.asMap` / `\\param, bus.asMap` to drive a Synth's control from a bus. Buses are how effects are chained: a synth writes to a private bus, the effect reads it and writes to Out.ar(0, …)."}]}
{"schema": 1, "id": "teacher:concept:node-tree", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the node tree and what is a Group for?"}, {"role": "assistant", "content": "Everything running on the server is a node: Synths and Groups, arranged in a tree under the root group. Order matters, because audio flows through buses from earlier to later nodes in the same branch. A Group is a container that lets you address many nodes at once, which is what you want for an effect chain — put the instruments in one group, the effect in another, and `freeAll` or a volume change hits the whole group instead of a list of node ids."}]}
{"schema": 1, "id": "teacher:concept:waitforboot", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Why does everyone wrap code in s.waitForBoot?"}, {"role": "assistant", "content": "Because the server boots asynchronously, and a SynthDef added before it is up never reaches it. `s.waitForBoot { ... }` runs the block once the server has finished booting; inside a Routine you can also use `s.boot; s.sync;` for the same effect. If you see 'SynthDef not found' on code that clearly looks right, this is usually why."}]}
{"schema": 1, "id": "teacher:concept:env-and-envgen", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between Env and EnvGen?"}, {"role": "assistant", "content": "Env is a language-side description: a list of levels, times and a curve, e.g. `Env.perc(0.01, 1)` or `Env.adsr(0.01, 0.1, 0.5, 0.8)`. EnvGen is the UGen that plays it on the server: `EnvGen.kr(env, gate, doneAction: 2)`. The same Env can be played by many EnvGens, and Env also has language-side uses such as `.asStream` inside Patterns and `.plot`."}]}
{"schema": 1, "id": "teacher:concept:buffer-vs-soundfile", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is a Buffer, and how is it different from a SoundFile?"}, {"role": "assistant", "content": "A Buffer is server-side memory: an array of samples (or a wavetable) living on scsynth, addressed by an integer bufnum. A SoundFile is a language-side object for reading or writing a file on disk. `Buffer.read(s, path)` loads a sound file into server memory and gives you a Buffer; `SoundFile.openRead(path)` just reads metadata such as duration and sample rate without loading audio. PlayBuf, GrainBuf and BufRd all take a Buffer, never a SoundFile."}]}
{"schema": 1, "id": "teacher:concept:ndef", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is Ndef used for?"}, {"role": "assistant", "content": "Ndef is the JITLib node proxy: a named placeholder for a running signal chain that you can redefine while it plays. `Ndef(\\drone, { SinOsc.ar(55) * 0.1 }).play` starts it, and calling Ndef(\\drone, { ... }) again crossfades to the new definition without restarting the sound. It also supports chaining, `Ndef(\\drone)[1] = \\filter -> { |in| LPF.ar(in, 800) }`, which is the idiomatic way to build and modify a live patch."}]}
{"schema": 1, "id": "teacher:concept:patterns-vs-synthdefs", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "When should I use a Pattern instead of writing Synth code by hand?"}, {"role": "assistant", "content": "Use a Pattern when what you want to express is a sequence over time — notes, durations, amplitudes, parameters — rather than a signal. A Pbind describes events, and `.play` turns each event into a Synth (by default of the \\default instrument, or of \\instrument if you name one). Hand-written Synth code is for the sound itself; Patterns are for what plays when. The two compose: a SynthDef named \\bell is triggered from `Pbind(\\instrument, \\bell, ...)`."}]}
{"schema": 1, "id": "teacher:concept:clocks", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between TempoClock and SystemClock?"}, {"role": "assistant", "content": "SystemClock runs in real time and is what `.wait` uses by default. TempoClock runs in beats and has a tempo, so it can be changed while things are playing and Patterns scheduled on it follow. `TempoClock.default` is the clock Patterns use unless told otherwise, which is why `TempoClock.default.tempo = 2` changes the speed of everything you already have running."}]}
{"schema": 1, "id": "teacher:concept:env-vars", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between ~foo and a local variable?"}, {"role": "assistant", "content": "`var foo` is a local: it exists only inside the function or file block that declares it. `~foo` is an environment variable: it lives in the current Environment, survives between executions of the same block, and is visible to everything running in that environment. That is why `~buf = Buffer.read(s, path)` works in one cell and `PlayBuf.ar(1, ~buf)` works in the next, while a `var` would be gone."}]}
{"schema": 1, "id": "teacher:concept:multichannel", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How does multi-channel expansion work?"}, {"role": "assistant", "content": "If any argument of a UGen is an Array, the UGen is built once per element and the results are returned as an Array. So `SinOsc.ar([220, 330, 440])` is three oscillators, and `SinOsc.ar(220 * [1, 1.5])` is two. This is not a special stereo feature: it is uniform expansion, which is why `Splay.ar(SinOsc.ar([220,330,440]) * 0.1)` gives you a spread stereo field from three mono sources."}]}
{"schema": 1, "id": "teacher:concept:block-size", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What are the server's default sample rate and block size?"}, {"role": "assistant", "content": "44100 Hz and 64 samples per block by default, so the control rate is 44100/64 = 689.06 Hz. You can read them from the language with `s.sampleRate` and `s.options.blockSize`, or from inside a Synth with `SampleRate.ir` and `ControlRate.ir`. A `.kr` signal therefore updates about 689 times a second, which is why it is smooth enough for filters and envelopes but not for audio-rate FM."}]}
{"schema": 1, "id": "teacher:concept:play", "family": "T1", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What happens when I call .play on a function?"}, {"role": "assistant", "content": "`.play` on a Function builds a SynthDef from the function body, adds it to the server under an anonymous name, and starts one Synth of it. You get back the Synth, so `x = { SinOsc.ar(440) * 0.1 }.play; x.free;` stops it. It is the fastest way to hear something, but it is not how you write a piece: nothing is named, nothing can be reused, and the definition is lost when the Synth is freed."}]}
{"schema": 1, "id": "teacher:api:bpf-rq", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is rq in BPF.ar?"}, {"role": "assistant", "content": "rq is the reciprocal of Q, so it is a bandwidth control, not a Q control. Small rq means a narrow, resonant band; large rq means a wide, gentle one. The signature is `BPF.ar(in, freq, rq, mul, add)`. A common idiom is `rq = 0.3` for a broad sweep and `rq = 0.02` for a whistle. The same rq convention applies to RLPF and RHPF."}]}
{"schema": 1, "id": "teacher:api:grainbuf", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What are the arguments of GrainBuf.ar?"}, {"role": "assistant", "content": "`GrainBuf.ar(numChannels, trigger, dur, sndbuf, rate, pos, interp, pan, envbufnum, maxGrains, mul, add)`. The ones you always pass are numChannels (1 or 2), trigger (a UGen that fires grains, e.g. Impulse.kr(20)), dur (grain length in seconds), sndbuf (an integer buffer number, or `~buf`), rate (playback rate per grain), and pos (read position 0..1 into the buffer). Raise maxGrains if the server complains about too many grains rather than lowering density."}]}
{"schema": 1, "id": "teacher:api:envgen", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What are the arguments of EnvGen?"}, {"role": "assistant", "content": "`EnvGen.ar(envelope, gate, levelScale, levelBias, timeScale, doneAction)` — or the .kr form. Envelope is an Env; gate is the signal that holds the envelope open (a number for a one-shot, a trigger or gate control for a sustained sound); levelScale and levelBias scale and offset the output; timeScale stretches durations. Use `doneAction: 2` on a one-shot so the Synth frees itself."}]}
{"schema": 1, "id": "teacher:api:env-perc", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is Env.perc and what does it take?"}, {"role": "assistant", "content": "`Env.perc(attackTime, releaseTime, level, curve)` — an attack to `level` (default 1) then a decay to zero, with curve defaulting to -4 (an exponential-ish decay). `Env.perc(0.01, 1)` is the default percussive envelope, and it is a complete Env, not a generator: pair it with EnvGen to hear it."}]}
{"schema": 1, "id": "teacher:api:playbuf", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What are the arguments of PlayBuf.ar?"}, {"role": "assistant", "content": "`PlayBuf.ar(numChannels, bufnum, rate, trigger, startPos, loop)`. numChannels must match what is in the buffer, or you get a channel mismatch; bufnum is the Buffer's integer number; rate is playback speed where 1 is normal and negative plays backwards; trigger restarts playback on each trigger in loop mode; startPos is in frames; loop is 0 or 1. `PlayBuf.ar(1, ~buf, BufRateScale.kr(~buf), loop: 1)` is the standard pitch-correct form."}]}
{"schema": 1, "id": "teacher:api:pbind-keys", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Which keys does a Pbind understand?"}, {"role": "assistant", "content": "The ones you use constantly are \\instrument (a SynthDef name), \\dur (seconds), \\degree (scale degree), \\midinote, \\freq, \\amp, \\legato (note length as a fraction of \\dur), and \\scale plus \\root for the scale used by \\degree. Everything else is passed to the Synth as an argument, so a SynthDef with `|cutoff = 800|` can be driven by `\\cutoff, Pwhite(400, 4000)`."}]}
{"schema": 1, "id": "teacher:api:degree-midinote-freq", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between \\degree, \\midinote and \\freq in a Pbind?"}, {"role": "assistant", "content": "`\\freq` is the frequency in Hz and is used as-is. `\\midinote` is a MIDI note number, converted to frequency by the default instrument. `\\degree` is a scale degree, quantised to the scale in \\scale (default major) rooted at \\root; degrees can be negative or fractional. If you set both, the more specific conversion wins, so set exactly one."}]}
{"schema": 1, "id": "teacher:api:splay", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What does Splay.ar do?"}, {"role": "assistant", "content": "`Splay.ar(inArray, spread, level, center, levelComp)` takes an array of mono signals and distributes them across the stereo field, so `Splay.ar(SinOsc.ar([220, 330, 440]) * 0.1)` is a three-source stereo chord rather than three separate synths. spread (0..1) controls how far the voices fan out and center shifts the middle. It is the shorthand for 'make this array stereo'."}]}
{"schema": 1, "id": "teacher:api:lag", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What does Lag do?"}, {"role": "assistant", "content": "`Lag.ar(in, lagTime)` and `Lag.kr(in, lagTime)` smooth a signal with an exponential lag towards its target, which removes the clicks and zipper noise a stepped control would produce. Lag.kr on a mouse or MIDI input is the standard way to make a parameter feel analogue: `Lag.kr(MouseX.kr(200, 4000), 0.2)`. Lag2 and Lag3 are the second- and third-order versions, smoother and slower."}]}
{"schema": 1, "id": "teacher:api:line-xline", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the difference between Line and XLine?"}, {"role": "assistant", "content": "Both are ramps: `Line.kr(start, end, dur, mul, add, doneAction)` moves linearly, `XLine.kr(...)` moves exponentially in a fixed ratio per unit time. Use Line for amplitude and XLine for frequency or any parameter you hear logarithmically — a linear frequency sweep sounds like it rushes at the top and crawls at the bottom. Both take doneAction, so both can end a Synth."}]}
{"schema": 1, "id": "teacher:api:pan2", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What are the arguments of Pan2?"}, {"role": "assistant", "content": "`Pan2.ar(in, pos, level)` — in is the mono signal, pos is -1 (left) to 1 (right) with 0 in the middle, and level scales the output. It is equal-power, so a centred signal is -3 dB per channel rather than half amplitude. `Pan2.ar(sig, SinOsc.kr(0.1))` is the simplest autopan."}]}
{"schema": 1, "id": "teacher:api:freeverb", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I add reverb with FreeVerb?"}, {"role": "assistant", "content": "`FreeVerb.ar(in, mix, room, damp)` — mix 0..1 is dry/wet, room 0..1 is the size (0.5 is a small room, 0.9 is a hall), damp 0..1 rolls off the high end of the tail. Put it after your sound: `FreeVerb.ar(SinOsc.ar(440) * 0.1, 0.4, 0.8, 0.5)`. For a send-style reverb, write the dry signal to Out.ar(0, …) and the same signal through FreeVerb to a second bus."}]}
{"schema": 1, "id": "teacher:api:combn", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I make a delay line?"}, {"role": "assistant", "content": "`CombN.ar(in, maxdelaytime, delaytime, decaytime)` is a feedback delay: maxdelaytime is the buffer size, delaytime the actual delay (and it can modulate), decaytime how long the repeats take to die. For a clean single echo use `DelayN.ar(in, maxdelaytime, delaytime)`, which has no feedback. Both replace the `in` with the delayed signal, so mix with the dry: `dry + CombN.ar(dry, 0.5, 0.3, 2) * 0.4`."}]}
{"schema": 1, "id": "teacher:api:poll-scope", "family": "T5", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I see what a signal is doing?"}, {"role": "assistant", "content": "`.poll` prints values to the post window — `SinOsc.kr(1).poll` prints once per control block, and `.poll(10)` limits it to every 10th. `s.scope` opens an oscilloscope on the main output, and `.scope` on a UGen shows just that signal. For a numeric snapshot of many signals at once, `s.meter` shows the output levels, and `\".dump\".postln` style probes are common while debugging."}]}
{"schema": 1, "id": "teacher:task:bell", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a bell in SuperCollider."}, {"role": "assistant", "content": "A bell is a set of inharmonic partials with a long percussive decay. The ratios below are the\nclassic bell ones; the envelope frees the Synth when it ends.\n\n```supercollider\n(\nSynthDef(\\bell, { |out = 0, freq = 440, amp = 0.2, dur = 3|\n    var partials = [1, 2.76, 5.4, 8.93];\n    var amps = [1, 0.5, 0.3, 0.15];\n    var sig = SinOsc.ar(freq * partials) * amps;\n    var env = EnvGen.kr(Env.perc(0.001, dur, 1, -6), doneAction: 2);\n    Out.ar(out, Pan2.ar(Mix(sig) * env * amp, 0));\n}).add;\n);\nSynth(\\bell, [\\freq, 660, \\dur, 4]);\n```"}]}
{"schema": 1, "id": "teacher:task:kick", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a kick drum in SuperCollider."}, {"role": "assistant", "content": "A pitch-swept sine with a fast decay: the frequency envelope is what makes it read as a kick.\n\n```supercollider\n(\nSynthDef(\\kick, { |out = 0, amp = 0.8|\n    var pitch = EnvGen.kr(Env([150, 50, 40], [0.03, 0.15], -4));\n    var env = EnvGen.kr(Env.perc(0.001, 0.35, 1, -6), doneAction: 2);\n    Out.ar(out, Pan2.ar(SinOsc.ar(pitch) * env * amp));\n}).add;\n);\nSynth(\\kick);\n```"}]}
{"schema": 1, "id": "teacher:task:snare", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a snare drum in SuperCollider."}, {"role": "assistant", "content": "Two ingredients: a short tonal body and band-passed noise for the rattle.\n\n```supercollider\n(\nSynthDef(\\snare, { |out = 0, amp = 0.6|\n    var env = EnvGen.kr(Env.perc(0.001, 0.18, 1, -6), doneAction: 2);\n    var body = SinOsc.ar(180) * 0.4;\n    var rattle = BPF.ar(WhiteNoise.ar, 1800, 0.4) * 3;\n    Out.ar(out, Pan2.ar((body + rattle) * env * amp));\n}).add;\n);\nSynth(\\snare);\n```"}]}
{"schema": 1, "id": "teacher:task:hat", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a closed hi-hat in SuperCollider."}, {"role": "assistant", "content": "High-passed noise with a very short envelope — the filter is what makes it a hat rather than a hiss.\n\n```supercollider\n(\nSynthDef(\\hat, { |out = 0, amp = 0.3, dur = 0.06|\n    var env = EnvGen.kr(Env.perc(0.001, dur, 1, -6), doneAction: 2);\n    Out.ar(out, Pan2.ar(HPF.ar(WhiteNoise.ar, 7000) * env * amp));\n}).add;\n);\nSynth(\\hat, [\\dur, 0.04]);\n```"}]}
{"schema": 1, "id": "teacher:task:pluck", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a plucked string in SuperCollider."}, {"role": "assistant", "content": "Pluck is a Karplus-Strong string: a noise burst into a tuned delay with feedback. The delay time is\nthe reciprocal of the frequency.\n\n```supercollider\n(\nSynthDef(\\pluck, { |out = 0, freq = 220, amp = 0.5, dur = 3|\n    var period = freq.reciprocal;\n    var sig = Pluck.ar(WhiteNoise.ar(0.2), Impulse.kr(0), period, period, dur, 0.5);\n    Out.ar(out, Pan2.ar(sig * amp, 0));\n}).add;\n);\nSynth(\\pluck, [\\freq, 330, \\dur, 4]);\n```"}]}
{"schema": 1, "id": "teacher:task:fm-bell", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write an FM bell in SuperCollider."}, {"role": "assistant", "content": "PMOsc is phase modulation: a non-integer modulator ratio gives the inharmonic clang.\n\n```supercollider\n(\nSynthDef(\\fmBell, { |out = 0, freq = 440, amp = 0.2, dur = 4|\n    var index = EnvGen.kr(Env([8, 0.2], [dur], -4));\n    var sig = PMOsc.ar(freq, freq * 1.4, index, 0, 1);\n    var env = EnvGen.kr(Env.perc(0.002, dur, 1, -5), doneAction: 2);\n    Out.ar(out, Pan2.ar(sig * env * amp, 0));\n}).add;\n);\nSynth(\\fmBell, [\\freq, 550]);\n```"}]}
{"schema": 1, "id": "teacher:task:additive-bell", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I make an additive bell with Klank?"}, {"role": "assistant", "content": "Klank is a bank of resonant filters excited by a short impulse: you describe the partials as\nfrequencies, amplitudes and decay times.\n\n```supercollider\n(\nSynthDef(\\klank, { |out = 0, freq = 440, amp = 0.3|\n    var ratios = [1, 2.2, 3.7, 5.1, 7.3];\n    var decays = [4, 2.6, 1.8, 1.2, 0.8];\n    var sig = Klank.ar(`[ratios * freq, nil, decays], Impulse.ar(0, 0, 0.2), 1, 0, 0.3);\n    Out.ar(out, Pan2.ar(sig * amp, 0));\n}).add;\n);\nSynth(\\klank);\n```"}]}
{"schema": 1, "id": "teacher:task:granular", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a granular texture in SuperCollider."}, {"role": "assistant", "content": "Read a sound file into a buffer, then trigger grains from it. Grain density is the Impulse rate and\ngrain length is dur; keep the density times the length under maxGrains or raise it.\n\n```supercollider\n(\ns.waitForBoot {\n    ~buf = Buffer.read(s, Platform.resourceDir +/+ \"sounds/a11wlk01.wav\");\n    SynthDef(\\grain, { |out = 0, amp = 0.4, density = 30, dur = 0.08|\n        var trig = Impulse.kr(density);\n        var sig = GrainBuf.ar(2, trig, dur, ~buf, 1, LFNoise0.kr(2).range(0, 1), 2, 0, -1, 512);\n        Out.ar(out, sig * amp);\n    }).add;\n    s.sync;\n    Synth(\\grain);\n};\n)\n```"}]}
{"schema": 1, "id": "teacher:task:filter-sweep", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a filter sweep over a saw."}, {"role": "assistant", "content": "An LFO on the cutoff of a resonant low-pass; XLine or an LFO both work, the LFO is the loopable one.\n\n```supercollider\n{ LPF.ar(Saw.ar([60, 60.2]), SinOsc.kr(0.2).exprange(150, 4000), 0.4) * 0.2 }.play;\n```\n\n`.exprange` is the exponential mapping you want for frequency; a linear `.range` sweep sounds uneven."}]}
{"schema": 1, "id": "teacher:task:delay-send", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I set up a delay send in SuperCollider?"}, {"role": "assistant", "content": "One synth writes dry to the master and also to a private bus; a second synth reads that bus, delays\nit, and writes the wet signal to the master.\n\n```supercollider\n(\n~delayBus = Bus.audio(s, 2);\nSynthDef(\\src, { |out = 0, send = 0, freq = 440|\n    var sig = SinOsc.ar(freq) * 0.15;\n    Out.ar(out, sig);\n    Out.ar(send, sig);\n}).add;\nSynthDef(\\dly, { |in = 0, out = 0, time = 0.3|\n    var dry = In.ar(in, 2);\n    var wet = CombN.ar(dry, 0.6, time, 3);\n    Out.ar(out, wet * 0.6);\n}).add;\n);\nSynth(\\dly, [\\in, ~delayBus, \\time, 0.375]);\nSynth(\\src, [\\send, ~delayBus]);\n```"}]}
{"schema": 1, "id": "teacher:task:reverb-send", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I add a reverb send to a whole group?"}, {"role": "assistant", "content": "Same shape as the delay: a private stereo bus, one effect reading it, instruments writing both dry\nand wet.\n\n```supercollider\n(\n~verbBus = Bus.audio(s, 2);\nSynthDef(\\verb, { |in = 0, out = 0, room = 0.85, mix = 0.5|\n    Out.ar(out, FreeVerb.ar(In.ar(in, 2), mix, room, 0.5) * 0.7);\n}).add;\nSynthDef(\\blip, { |out = 0, send = 0, freq = 440, amp = 0.1|\n    var env = EnvGen.kr(Env.perc(0.002, 0.4), doneAction: 2);\n    var sig = SinOsc.ar(freq) * env * amp;\n    Out.ar(out, sig);\n    Out.ar(send, sig);\n}).add;\n);\nSynth(\\verb, [\\in, ~verbBus]);\nPbind(\\instrument, \\blip, \\send, ~verbBus, \\degree, Pseq([0, 4, 7, 11], inf), \\dur, 0.25).play;\n```"}]}
{"schema": 1, "id": "teacher:task:euclidean", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I get a Euclidean-style rhythm in SuperCollider?"}, {"role": "assistant", "content": "Describe the pattern as a list of hits and rests; `Rest` gives the gap without starting a Synth.\n\n```supercollider\n(\nPbind(\n    \\instrument, \\hat,\n    \\dur, 0.125,\n    \\amp, Pseq([0.3, 0, 0, 0.3, 0, 0.3, 0, 0], inf).collect { |x| x + 0.001 }\n).play;\n)\n```\n\nFor real Euclidean generation use `Pseq([1,0,0,1,0,1,0,0], inf)` on a duration multiplier and wrap rests\nwith `Rest`, or compute the pattern with `bjorklund`-style logic in a Function and `Pseq` the result."}]}
{"schema": 1, "id": "teacher:task:pentatonic", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a random pentatonic melody that plays by itself."}, {"role": "assistant", "content": "Pick degrees from a pentatonic scale; `\\scale` and `\\root` define the pitch space, and `\\degree`\npicks within it.\n\n```supercollider\n(\nPbind(\n    \\instrument, \\default,\n    \\scale, Scale.minorPentatonic,\n    \\root, 3,\n    \\degree, Pwhite(0, 9, inf),\n    \\octave, 5,\n    \\dur, Pwhite(0.12, 0.28, inf),\n    \\amp, 0.2,\n    \\legato, 0.8\n).play;\n)\n```"}]}
{"schema": 1, "id": "teacher:task:chords", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a chord progression with Pbind."}, {"role": "assistant", "content": "Put an array of degrees in the pattern, use \\strum to spread the chord, and the default instrument\nplays all notes of each event.\n\n```supercollider\n(\nPbind(\n    \\scale, Scale.minor,\n    \\root, 2,\n    \\degree, Pseq([[0, 4, 7], [-3, 0, 4], [-5, -1, 2], [0, 4, 7]], inf),\n    \\dur, 1.5,\n    \\strum, 0.02,\n    \\amp, 0.12,\n    \\legato, 0.9\n).play;\n)\n```"}]}
{"schema": 1, "id": "teacher:task:drone-ndef", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Build a slowly evolving drone with Ndef."}, {"role": "assistant", "content": "Ndef gives you a named patch you can redefine while it plays; the filter is a separate node in the\nchain so you can change it on its own.\n\n```supercollider\n(\nNdef(\\drone, { |freq = 55, amp = 0.12|\n    var detune = [0, 0.07, -0.11];\n    var sig = Mix(Saw.ar(freq * (1 + detune))) * amp;\n    LPF.ar(sig, 400);\n}).play;\n\nNdef(\\drone)[1] = \\filter -> { |in| RLPF.ar(in, LFNoise1.kr(0.1).exprange(200, 1800), 0.3) };\n)\n```\n\nRedefining Ndef(\\drone, { ... }) later crossfades to the new definition; Ndef(\\drone).stop stops it."}]}
{"schema": 1, "id": "teacher:task:tdef", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I structure a live-coding performance in one file?"}, {"role": "assistant", "content": "One Tdef per musical layer, each with its own loop, so you can start and stop layers while the set\nruns.\n\n```supercollider\n(\nTdef(\\kick, {\n    loop {\n        Synth(\\kick);\n        0.5.wait;\n    }\n}).play;\n\nTdef(\\hats, {\n    loop {\n        Synth(\\hat, [\\amp, 0.15]);\n        (1/8).wait;\n    }\n}).play;\n)\n```\n`Tdef(\\kick).stop` stops one layer, `Tdef(\\kick).reset` restarts it at the next cycle, and\n`CmdPeriod.run` stops everything."}]}
{"schema": 1, "id": "teacher:task:sample", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I play a sample from disk?"}, {"role": "assistant", "content": "Load it into a Buffer on the server, then play the buffer. `BufRateScale` keeps the pitch right when\nthe file's sample rate differs from the server's.\n\n```supercollider\n(\ns.waitForBoot {\n    ~buf = Buffer.read(s, \"C:/sounds/break.wav\");\n    SynthDef(\\player, { |out = 0, buf = 0, amp = 0.6, rate = 1|\n        var sig = PlayBuf.ar(2, buf, BufRateScale.kr(buf) * rate, loop: 1);\n        Out.ar(out, sig * amp);\n    }).add;\n    s.sync;\n    ~player = Synth(\\player, [\\buf, ~buf]);\n};\n)\n```\nUse `numChannels` 1 for a mono file; a mismatch is silent or wrong-sounding rather than an error."}]}
{"schema": 1, "id": "teacher:task:distortion", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I distort a signal?"}, {"role": "assistant", "content": "Drive it into a nonlinearity, then tame the level: `tanh` is soft clipping, `.distort` is harder,\nand a low-pass after the drive keeps it from getting fizzy.\n\n```supercollider\n(\n{\n    var sig = SinOsc.ar(110) * 0.3;\n    var driven = (sig * 12).tanh;\n    LPF.ar(driven, 5000) * 0.4\n}.play;\n)\n```\n\nMore drive means more harmonics; because they are generated, the output is louder as well as brighter, so\nscale the result down after the nonlinearity."}]}
{"schema": 1, "id": "teacher:task:pan-pattern", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I pan notes around the stereo field in a pattern?"}, {"role": "assistant", "content": "Put `\\pan` in the Pbind: the default instrument understands it and passes it to Pan2.\n\n```supercollider\n(\nPbind(\n    \\scale, Scale.minorPentatonic,\n    \\degree, Pseq([0, 2, 4, 7, 9, 7, 4, 2], inf),\n    \\dur, 0.2,\n    \\pan, Pseq([-1, -0.5, 0, 0.5, 1, 0.5, 0, -0.5], inf),\n    \\amp, 0.15\n).play;\n)\n```\n\nTo pan an arbitrary synth, add a `pan = 0` argument to the SynthDef and wrap the output in\n`Pan2.ar(sig, pan)`."}]}
{"schema": 1, "id": "teacher:task:pad", "family": "T2", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Write a warm pad in SuperCollider."}, {"role": "assistant", "content": "Detuned saws through a slow filter envelope and a long release: the detune is what makes it wide.\n\n```supercollider\n(\nSynthDef(\\pad, { |out = 0, freq = 220, amp = 0.15, gate = 1|\n    var detune = [-0.06, -0.02, 0.02, 0.06];\n    var sig = Mix(Saw.ar(freq * (1 + detune))) * 0.25;\n    var env = EnvGen.kr(Env.adsr(1.2, 0.5, 0.7, 3), gate, doneAction: 2);\n    var cutoff = SinOsc.kr(0.05).exprange(300, 2000);\n    sig = RLPF.ar(sig, cutoff, 0.4);\n    Out.ar(out, Splay.ar([sig, DelayN.ar(sig, 0.02, 0.012)]) * env * amp);\n}).add;\n);\n~pad = Synth(\\pad, [\\freq, 165]);\n~pad.set(\\gate, 0);\n```\n`gate` is what makes a sustained sound controllable: `\\gate, 0` releases it and `doneAction: 2` then\nfrees the Synth."}]}
{"schema": 1, "id": "teacher:debug:synthdef-not-found", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get 'FAILURE IN SERVER /s_new SynthDef not found'. What is wrong?"}, {"role": "assistant", "content": "The server does not know that SynthDef. Three usual causes, in order of likelihood:\n\n1. **The SynthDef was added before the server booted.** `SynthDef(...).add` is asynchronous; wrap the work\n   in `s.waitForBoot { ... }` or put `s.sync` after `.add`.\n2. **The name does not match.** `SynthDef(\\bell, ...)` is played by `Synth(\\bell)`, not `\\Bell` — symbols\n   are case-sensitive.\n3. **`.add` was never called.** Writing `SynthDef(\\bell, { ... })` without `.add` builds the definition in\n   the language and sends nothing.\n\nCheck with `SynthDescLib.global.dict.keys` — if the name is not there, it never reached the server."}]}
{"schema": 1, "id": "teacher:debug:silent-synth", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "My Synth runs but I hear nothing. How do I debug it?"}, {"role": "assistant", "content": "Check in this order, because each step eliminates a whole class of causes:\n\n1. **Is anything coming out of the bus you write to?** `Out.ar(0, sig)` for the master. A typo like\n   `Out.ar(2, ...)` is silence.\n2. **Is the amplitude non-zero?** Multiply chain of `mul`/`add`, `amp`, and `env` all have to be positive;\n   an envelope with `level: 0` or a gate that never opens is silent.\n3. **Did the Synth free itself immediately?** `doneAction: 2` on an EnvGen whose envelope is already\n   finished at creation kills the node instantly. `s.plotTree` shows whether the node exists at all.\n4. **Is the envelope actually moving?** `env.poll` inside the SynthDef prints it per block.\n5. **Is the filter closed?** A `LPF.ar(sig, 50)` on a 440 Hz sine leaves almost nothing.\n\nThe fastest single tool is `s.plotTree`: if the Synth is not in the tree, the problem is lifecycle; if it\nis, the problem is signal."}]}
{"schema": 1, "id": "teacher:debug:node-not-found", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get 'Node not found' when I call .set on a Synth after a while."}, {"role": "assistant", "content": "The Synth was freed and the language still holds a reference. That happens whenever the SynthDef used `doneAction: 2` and the envelope finished, or when something called `freeAll`/`CmdPeriod`. Guard it with `if (x.notNil and: { x.isPlaying }) { x.set(\\freq, 300) }`, or store the node in a variable that you clear when it ends. For sustained sounds the right pattern is a `gate` argument with `doneAction: 2` on the EnvGen, so the node lives until you release it."}]}
{"schema": 1, "id": "teacher:debug:buffer-no-data", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get 'Buffer UGen: no buffer data'. What does it mean?"}, {"role": "assistant", "content": "The UGen got a bufnum that the server has no data for. `Buffer.read` is asynchronous: the Buffer object exists immediately but the samples arrive later, so a Synth created straight after `Buffer.read` reads nothing. Wait for it — `s.sync` after the read, or `Buffer.read(s, path, action: { |b| ... })` and create the Synth in the action. The other cause is a nil or wrong buffer: `PlayBuf.ar(1, ~buf)` where ~buf was never assigned passes 0, which is 'no buffer'."}]}
{"schema": 1, "id": "teacher:debug:ar-not-understood", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get \"Message 'ar' not understood\". Why?"}, {"role": "assistant", "content": "You called a rate method on something that is not a UGen. `Env.ar(...)` and `Buffer.ar(...)` are the classic cases: Env is a language-side description and is played by `EnvGen.ar(env, ...)`; a Buffer is server memory and is played by `PlayBuf.ar` or `BufRd.ar`. The UGen is the thing with a rate method — if it is a description or a container, there is another UGen that consumes it."}]}
{"schema": 1, "id": "teacher:debug:missing-semicolon", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get 'syntax error, unexpected NAME' on a block that looks fine."}, {"role": "assistant", "content": "Almost always a missing semicolon between two statements — SuperCollider does not insert them.\n\n```supercollider\n// broken: two statements, no separator\n{ var sig = SinOsc.ar(440) sig = sig * 0.1; sig }.play\n```\n\n```supercollider\n// fixed\n{ var sig = SinOsc.ar(440); sig = sig * 0.1; sig }.play\n```\nThe error points at the second statement, not at the missing semicolon before it, which is why it looks\nfine. If it is not a semicolon, count the brackets: `.ar(` open, `)` closed."}]}
{"schema": 1, "id": "teacher:debug:gate-stuck", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "My sustained synth never stops, even when I set the gate to 0."}, {"role": "assistant", "content": "A sustained EnvGen only releases when the gate goes from positive to non-positive *after* the envelope has started, and the Synth only disappears if that EnvGen has `doneAction: 2`. Check three things: the SynthDef actually takes a `gate = 1` argument, the Env is a sustained shape (Env.adsr or Env.asr, not Env.perc), and you call `x.set(\\gate, 0)` on the Synth object. Setting the gate on a different Synth, or on a Group, does nothing."}]}
{"schema": 1, "id": "teacher:debug:index-out-of-range", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get 'index out of range' when playing a buffer."}, {"role": "assistant", "content": "A read position is past the end of the buffer. `PlayBuf` with a `startPos` in frames beyond `~buf.numFrames`, or a `BufRd`/`GrainBuf` whose phase goes above 1, produces this. For GrainBuf, pos is normalised 0..1, so pass `LFNoise1.kr(1).range(0, 1)` rather than a frame count; for PlayBuf, cap the position at `~buf.numFrames - 1`. If you just loaded the file, check `~buf.numFrames` — a failed read gives 0 frames and every position is out of range."}]}
{"schema": 1, "id": "teacher:debug:file-not-found", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Buffer.read fails and I get a path error. What should the path look like?"}, {"role": "assistant", "content": "On Windows use forward slashes or escaped backslashes inside the string: `Buffer.read(s, \"C:/sounds/kick.wav\")`. A single backslash starts an escape sequence, which is why `\"C:\\sounds\\kick.wav\"` fails. Also check the extension is real (`.wav`, `.aiff`, `.flac`) and that the file is not on a network path — the server reads it, not the language, and it may resolve differently. For sounds that ship with SuperCollider, `Platform.resourceDir +/+ \"sounds/a11wlk01.wav\"` is the portable form."}]}
{"schema": 1, "id": "teacher:debug:too-many-grains", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "GrainBuf complains about too many grains."}, {"role": "assistant", "content": "The number of simultaneous grains is `density × dur` in seconds, and it exceeds maxGrains (512 by default). Either lower the trigger rate, shorten the grains, or raise the limit: `GrainBuf.ar(2, trig, dur, buf, 1, pos, 2, 0, -1, 1024)` — the 1024 is maxGrains. Raising it costs server CPU per grain, so prefer halving the density if the sound does not need it."}]}
{"schema": 1, "id": "teacher:debug:server-not-running", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get 'server not running' or nothing happens at all."}, {"role": "assistant", "content": "The server is not booted. In the IDE press Ctrl+B, or evaluate `s.boot`. If code depends on a SynthDef being there, put it inside `s.waitForBoot { ... }`. When a script runs headless you can do `s.boot; s.sync;` and continue. `s.serverRunning` tells you the truth; if it is false, look at the post window for the boot error (usually an audio device problem)."}]}
{"schema": 1, "id": "teacher:debug:nil-does-not-understand", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I get 'Message not understood' on a nil variable."}, {"role": "assistant", "content": "`~buffer` (or any variable) was never assigned, or it was assigned in a different environment. Environment variables are per-environment: a `~buf` set in one server-side file block is not visible in another. Check with `~buf.postln` before using it. The other common cause is an assignment that failed silently, e.g. `~buf = Buffer.read(...)` where the file was missing — the error is posted but ~buf stays nil."}]}
{"schema": 1, "id": "teacher:debug:redefined-synthdef", "family": "T3", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "I edited a SynthDef and the running sound did not change."}, {"role": "assistant", "content": "Redefining a SynthDef only affects Synths created after the new definition reaches the server; existing instances keep the graph they were built with. Free and recreate them: `~s.free; ~s = Synth(\\name)`. In JITLib, Ndef is the tool designed for this — redefining `Ndef(\\name, { ... })` crossfades to the new graph while it plays."}]}
{"schema": 1, "id": "teacher:explain:perc-sine", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this SuperCollider code:\n```supercollider\n{ SinOsc.ar(440) * EnvGen.kr(Env.perc(0.01, 1), doneAction: 2) }.play;\n```"}, {"role": "assistant", "content": "It plays a 440 Hz sine with a percussive envelope, and the Synth frees itself when the envelope\nends.\n\n- `SinOsc.ar(440)` is an audio-rate sine at 440 Hz.\n- `Env.perc(0.01, 1)` is a 10 ms attack to full level then a 1 s decay to zero.\n- `EnvGen.kr(...)` plays that envelope at control rate and multiplies the sine, so the sound fades out.\n- `doneAction: 2` frees the Synth at the end of the envelope, so it does not accumulate silent nodes.\n- `.play` on the function builds an anonymous SynthDef and starts one Synth of it."}]}
{"schema": 1, "id": "teacher:explain:pbind-basic", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\nPbind(\\degree, Pseq([0, 2, 4, 7], inf), \\dur, 0.25).play;\n```"}, {"role": "assistant", "content": "It plays a four-note major arpeggio in a loop, one note every 250 ms.\n\n`Pbind` builds an event stream: each event is the current value of every key. `Pseq([0, 2, 4, 7], inf)`\ncycles the degrees forever, and `\\dur, 0.25` sets the time between events in beats on the default\nTempoClock. With no `\\instrument`, the `\\default` SynthDef is used, which converts `\\degree` to a\nfrequency through the current scale (major, rooted at C by default). `.play` schedules it on the clock\nand returns an EventStreamPlayer."}]}
{"schema": 1, "id": "teacher:explain:filter-lfo", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\n{ LPF.ar(Saw.ar(100), SinOsc.kr(0.5).exprange(200, 2000)) * 0.2 }.play;\n```"}, {"role": "assistant", "content": "A sawtooth through a low-pass filter whose cutoff is swept slowly up and down — a classic filter\nsweep.\n\n- `Saw.ar(100)` is a 100 Hz sawtooth, rich in harmonics.\n- `SinOsc.kr(0.5)` is a control-rate sine at 0.5 Hz, so one full cycle takes 2 seconds.\n- `.exprange(200, 2000)` maps that -1..1 sine exponentially onto 200..2000 Hz — exponential is the right\n  mapping for frequency, because we hear pitch logarithmically.\n- `LPF.ar(sig, cutoff)` removes harmonics above the cutoff; as it opens and closes you hear the tone\n  brighten and darken.\n- `* 0.2` keeps the output from clipping."}]}
{"schema": 1, "id": "teacher:explain:routine-loop", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\nRoutine({ loop { Synth(\\kick); 0.5.wait } }).play;\n```"}, {"role": "assistant", "content": "It starts a kick every half second, forever.\n\nA Routine is a language-side coroutine: `.play` runs it on the clock, and `wait` suspends it until the next\nbeat without blocking anything else. Inside the `loop`, `Synth(\\kick)` creates a kick and `0.5.wait` waits\nhalf a beat on the current TempoClock — the tempo, not seconds, so changing the clock changes the rate.\nBecause the kick SynthDef frees itself with `doneAction: 2`, the loop can run for hours without leaking\nnodes."}]}
{"schema": 1, "id": "teacher:explain:buffer-play", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\n~buf = Buffer.read(s, \"C:/sounds/break.wav\");\nPlayBuf.ar(1, ~buf, BufRateScale.kr(~buf), loop: 1);\n```"}, {"role": "assistant", "content": "Loads a sound file into server memory, then plays it in a loop at the file's original pitch.\n\n- `Buffer.read(s, path)` allocates a buffer on the server and fills it from the file. It is asynchronous:\n  the Buffer object returns immediately, the samples arrive later.\n- `PlayBuf.ar(1, buf, ...)` needs the channel count first — 1 for a mono file. A wrong count is the usual\n  cause of a buffer that plays wrongly or not at all.\n- `BufRateScale.kr(buf)` compensates when the file's sample rate differs from the server's, so `rate: 1` is\n  the file's true speed.\n- `loop: 1` restarts at the end instead of stopping.\n\nBecause the read is asynchronous, this line pair is only safe if a `s.sync` or a wait happened in between;\notherwise PlayBuf sees a buffer with no data yet."}]}
{"schema": 1, "id": "teacher:explain:mix-array", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\nMix.ar([SinOsc.ar(220, 0, 0.1), SinOsc.ar(330, 0, 0.1)])\n```"}, {"role": "assistant", "content": "Sums two sine waves into one signal — a perfect fifth, 220 Hz and 330 Hz, at 0.1 amplitude each.\n\n`[SinOsc.ar(220, 0, 0.1), SinOsc.ar(330, 0, 0.1)]` is an Array of two audio-rate signals (each UGen\nreturns a signal; an array of them is just a list). `Mix.ar` adds the elements together. The alternative\n`+` operator does the same for two signals, and `Splay.ar` would spread them across the stereo field\ninstead of summing them."}]}
{"schema": 1, "id": "teacher:explain:synth-args", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\nx = { |freq = 440, amp = 0.2| SinOsc.ar(freq) * amp }.play;\nx.set(\\freq, 660);\n```"}, {"role": "assistant", "content": "Starts an anonymous synth with two controls, then changes one of them while it plays.\n\nThe `|freq = 440, amp = 0.2|` are arguments of the function, and `.play` turns each into a Synth control\nwith that default value. `x` holds the Synth node. `.set(\\freq, 660)` sends a `/n_set` message to the\nserver, so the oscillator changes frequency without being restarted — that is why the sound glides rather\nthan re-triggering. Note that `\\freq` is a Symbol: the backslash is part of the name."}]}
{"schema": 1, "id": "teacher:explain:ndef-filter", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\nNdef(\\x, { Saw.ar(110) * 0.1 }).play;\nNdef(\\x)[1] = \\filter -> { |in| RLPF.ar(in, 800, 0.4) };\n```"}, {"role": "assistant", "content": "Two nodes in one named proxy: a saw source, then a resonant low-pass filter fed by it.\n\n`Ndef(\\x, { ... })` defines the first node of the chain and `.play` starts it. `Ndef(\\x)[1] = \\filter ->`\ninserts a second node at index 1; the `\\filter` key says 'make this node an effect that receives the\nprevious node's output as `in`'. So the patch is `Saw -> RLPF -> out`. Because it is an Ndef, calling\n`Ndef(\\x, { ... })` again replaces the source with a crossfade instead of restarting, and\n`Ndef(\\x).stop` removes the whole chain."}]}
{"schema": 1, "id": "teacher:explain:impulse-env", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\n{ var sig = SinOsc.ar(440) * 0.2; Out.ar(0, sig) }.play;\n```"}, {"role": "assistant", "content": "The minimal SynthDef idiom: a source multiplied by an amplitude, written to the master bus.\n\n`var sig = SinOsc.ar(440) * 0.2` builds the signal; `Out.ar(0, sig)` is the only mandatory part, because a\nUGen graph that never reaches an output produces no sound. `Out`'s first argument is the bus number — 0 is\nthe main stereo output — and the second is the signal. The function's return value does not matter here,\nwhich is why the `Out.ar` can sit on its own line. `.play` compiles this into an anonymous SynthDef and\nstarts one instance."}]}
{"schema": 1, "id": "teacher:explain:gate-release", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\n~pad = Synth(\\pad, [\\freq, 165]);\n~pad.set(\\gate, 0);\n```"}, {"role": "assistant", "content": "It starts a sustained synth and then releases it.\n\n`Synth(\\pad, [\\freq, 165])` creates an instance of a SynthDef that takes a `gate` argument (default 1). The\narray after the name is alternating argument names and values: `\\freq, 165`. Setting `\\gate` to 0 does not\ncut the sound dead — the EnvGen inside sees the gate close and runs the release stage of its Env, then frees\nthe Synth because that EnvGen has `doneAction: 2`. This is the standard lifecycle for pads, drones and any\nsound you want to stop gracefully."}]}
{"schema": 1, "id": "teacher:explain:pan-lfo", "family": "T4", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Explain this code:\n```supercollider\n{ Pan2.ar(SinOsc.ar(440) * 0.2, SinOsc.kr(0.1)) }.play;\n```"}, {"role": "assistant", "content": "A sine that slowly moves between the speakers.\n\n`SinOsc.kr(0.1)` is a control-rate sine at 0.1 Hz — one cycle every 10 seconds — running between -1 and 1.\n`Pan2.ar(sig, pos)` treats that as the pan position, where -1 is hard left, 0 centre, 1 hard right, so the\nsound drifts across the stereo field. Pan2 is equal-power, so the centre is -3 dB per channel rather than\nhalf amplitude on each. The `* 0.2` sets the level before panning."}]}
{"schema": 1, "id": "teacher:mt:no-sound", "family": "T6", "weight": 2, "turns_count": 3, "conversations": [{"role": "user", "content": "I made a synth and I hear nothing. Where do I start?"}, {"role": "assistant", "content": "Start with the node tree, not the code: evaluate `s.plotTree`. If your Synth is not there, it never started or it already freed itself; if it is there, the problem is in the signal. Which of the two do you see?"}, {"role": "user", "content": "It's in the tree."}, {"role": "assistant", "content": "Then the node lives and the signal is being lost. Check three things in order: does the SynthDef reach `Out.ar(0, ...)` with bus 0; is any `amp`/`mul` zero; and is a filter closed, e.g. `LPF.ar(sig, 50)` on a 440 Hz sine. Paste the SynthDef and I will read it."}, {"role": "user", "content": "SynthDef(\\x, { |out = 0| Out.ar(out, LPF.ar(Saw.ar(60), 80) * 0.1) }).add; Synth(\\x, [\\out, 2]);"}, {"role": "assistant", "content": "Two things. You wrote a low-pass at 80 Hz over a 60 Hz saw, which leaves almost nothing above the fundamental — the patch is nearly a sine at 60 Hz at very low level. And you passed `\\out, 2`, so it is going to bus 2, not the master. Try `Synth(\\x)` with the default out and a cutoff of 800:\n\n```supercollider\nSynthDef(\\x, { |out = 0, cutoff = 800| Out.ar(out, LPF.ar(Saw.ar(60), cutoff) * 0.1) }).add;\nSynth(\\x);\n```"}]}
{"schema": 1, "id": "teacher:mt:brighten", "family": "T6", "weight": 2, "turns_count": 2, "conversations": [{"role": "user", "content": "How do I make this brighter?\n```supercollider\n{ LPF.ar(Saw.ar(110), 400) * 0.2 }.play;\n```"}, {"role": "assistant", "content": "Raise the cutoff. 400 Hz is well below the harmonics that carry brightness, so open it to 2000-4000 Hz:\n\n```supercollider\n{ LPF.ar(Saw.ar(110), 3000) * 0.2 }.play;\n```"}, {"role": "user", "content": "Still dull."}, {"role": "assistant", "content": "Then the low-pass is not the limit — the source is. A saw at 110 Hz has energy up to Nyquist, so check the amplitude: at 0.2 the high harmonics are quiet. Two moves: add resonance so the filter peak is audible, and raise the level slightly.\n\n```supercollider\n{ RLPF.ar(Saw.ar(110), 2500, 0.3) * 0.35 }.play;\n```\n\nIf that is still dull, the answer is a different source: `Saw` is band-limited and soft; try `LFSaw` or add a second detuned saw for more high content."}]}
{"schema": 1, "id": "teacher:mt:four-on-floor", "family": "T6", "weight": 2, "turns_count": 2, "conversations": [{"role": "user", "content": "I have a kick SynthDef called \\kick. How do I get a four-on-the-floor?"}, {"role": "assistant", "content": "One kick per beat on the default tempo clock:\n\n```supercollider\nTdef(\\four, { loop { Synth(\\kick); 1.wait } }).play;\n```\n\n`1.wait` is one beat, so `TempoClock.default.tempo = 2` makes it 120 BPM."}, {"role": "user", "content": "Now add hats on the offbeats."}, {"role": "assistant", "content": "A second layer, offset by half a beat:\n\n```supercollider\nTdef(\\hats, {\n    loop {\n        (1/2).wait;\n        Synth(\\hat, [\\amp, 0.12]);\n        (1/2).wait;\n    }\n}).play;\n```\n\nStarting with the wait puts the hat half a beat after the kick. `Tdef(\\hats).stop` removes just that layer."}]}
{"schema": 1, "id": "teacher:mt:pattern-wont-stop", "family": "T6", "weight": 2, "turns_count": 2, "conversations": [{"role": "user", "content": "My pattern keeps playing after I press Ctrl+."}, {"role": "assistant", "content": "Ctrl+. (CmdPeriod) stops everything scheduled on the clocks, including Patterns. If yours survives, it is not scheduled on a clock — most often it is a `Synth` created directly, or a `Task`/`Routine` started on `SystemClock` in a way that outlived the period. Do you still see the node in `s.plotTree`?"}, {"role": "user", "content": "Yes, there's a synth."}, {"role": "assistant", "content": "Then the sound is a node, not a pattern: `s.freeAll` will stop it. The likely cause is a SynthDef whose EnvGen has no `doneAction`, or a drone with `gate = 1` that nothing releases. Add `doneAction: 2` to the envelope, or keep a reference and `x.set(\\gate, 0)` when you want it to end."}]}
{"schema": 1, "id": "teacher:mt:reverb-too-wet", "family": "T6", "weight": 2, "turns_count": 2, "conversations": [{"role": "user", "content": "How do I put reverb on everything?"}, {"role": "assistant", "content": "Send it: one private bus, one FreeVerb instance reading it, and every instrument writing dry to the master and wet to the bus.\n\n```supercollider\n~verb = Bus.audio(s, 2);\nSynthDef(\\verb, { |in = 0| Out.ar(0, FreeVerb.ar(In.ar(in, 2), 0.5, 0.85, 0.5) * 0.7) }).add;\nSynth(\\verb, [\\in, ~verb]);\n```"}, {"role": "user", "content": "Too much reverb now."}, {"role": "assistant", "content": "Lower the wet mix and the return level, not the room size: the room is what makes it sound like a space, the mix is how much of it you hear. `FreeVerb.ar(In.ar(in, 2), 0.25, 0.85, 0.5) * 0.5`. To change it live without restarting, add a control and `.set` it: `|mix = 0.5|` then `~verbSynth.set(\\mix, 0.25)`."}]}
{"schema": 1, "id": "teacher:mt:first-bus", "family": "T6", "weight": 2, "turns_count": 2, "conversations": [{"role": "user", "content": "What is a bus, in one sentence?"}, {"role": "assistant", "content": "A numbered channel on the server that nodes write signal into and read signal out of, which is how sounds are chained without cables."}, {"role": "user", "content": "Show me using one for an effect."}, {"role": "assistant", "content": "Write the source to a private bus, read it in the effect, send the effect to the master:\n\n```supercollider\n(\n~bus = Bus.audio(s, 1);\nSynthDef(\\src, { |out = 0| Out.ar(out, Saw.ar(110) * 0.1) }).add;\nSynthDef(\\fx, { |in = 0| Out.ar(0, RLPF.ar(In.ar(in, 1), 1200, 0.3)) }).add;\n);\nSynth(\\fx, [\\in, ~bus]);\nSynth(\\src, [\\out, ~bus]);\n```\n\nOrder matters: the effect exists before the source, so the source's output has a listener."}]}
{"schema": 1, "id": "teacher:mt:learn-env", "family": "T6", "weight": 2, "turns_count": 2, "conversations": [{"role": "user", "content": "What's the difference between Env.perc and Env.adsr?"}, {"role": "assistant", "content": "`Env.perc(attack, release)` goes up once and decays to zero — one-shot sounds. `Env.adsr(a, d, s, r)` holds at a sustain level while its gate is open and only releases when the gate closes — notes you start and stop."}, {"role": "user", "content": "So which do I use for a pad?"}, {"role": "assistant", "content": "adsr, with `gate` as a Synth argument and `doneAction: 2` on the EnvGen:\n\n```supercollider\nSynthDef(\\pad, { |out = 0, freq = 220, gate = 1|\n    var env = EnvGen.kr(Env.adsr(0.8, 0.4, 0.7, 2), gate, doneAction: 2);\n    Out.ar(out, Saw.ar(freq) * env * 0.1)\n}).add;\n```\n\nThen `x.set(\\gate, 0)` releases it over the 2 seconds of release time."}]}
{"schema": 1, "id": "teacher:workflow:record", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I record my output to a file?"}, {"role": "assistant", "content": "`s.record(path)` starts recording the server's output; `s.stopRecording` stops it.\n\n```supercollider\ns.record(\"C:/audio/take1.wav\");\n// play for a while\ns.stopRecording;\n```\n\nThe path must be writable and the format follows the extension (.wav, .aiff, .flac). The file is written\nby the server, so it captures exactly what the master bus produces — including your effects, which is what\nyou want. `s.record` also accepts `duration:` to stop by itself, which is the reproducible form for a take."}]}
{"schema": 1, "id": "teacher:workflow:deterministic", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I make a piece reproducible instead of a different take every time?"}, {"role": "assistant", "content": "Three things make a SuperCollider piece repeatable: a fixed seed, a fixed tempo, and no live input.\n\n```supercollider\n(\nthisThread.randSeed = 1234;\nTempoClock.default.tempo = 2;\nPbind(\\degree, Pwhite(0, 7, inf), \\dur, 0.25).play;\n)\n```\n\n`thisThread.randSeed` fixes the random sequence of the current thread, so `Pwhite`, `Prand` and friends give\nthe same values again. Recording with `s.record(path, duration: 30)` then makes the take an artifact rather\nthan a performance. Input from `MouseX` or a MIDI controller is the usual remaining source of difference."}]}
{"schema": 1, "id": "teacher:workflow:server-broken", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "The server stopped responding. What do I do?"}, {"role": "assistant", "content": "In order: `Ctrl+.` (CmdPeriod) to reset scheduling, then `s.reboot` if the server itself is wedged.\nA reboot drops every SynthDef and buffer, so re-add them — which is why real projects keep their SynthDefs\nin a file you can re-evaluate rather than typing them in the REPL.\n\nIf the boot itself fails, the post window has the reason: usually the audio device (another application\nholding exclusive access) or a sample-rate mismatch. `Server.default.options.device` picks a device before\n`s.boot`."}]}
{"schema": 1, "id": "teacher:workflow:stop-everything", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "What is the correct way to stop everything?"}, {"role": "assistant", "content": "Depends on what is playing, and they are different layers:\n\n- `s.freeAll` — frees every node on the server (all sound stops, definitions survive).\n- `CmdPeriod.run` — stops everything scheduled on the clocks (Patterns, Routines, Tasks).\n- `Ndef.clear; Pdef.clear` — clears the JITLib proxies.\n- `s.quit` — shuts the server down entirely.\n\nIn a session the habit is `CmdPeriod.run` first (stops the sequencing), then `s.freeAll` if a drone is still\nsounding."}]}
{"schema": 1, "id": "teacher:workflow:organise", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How should I organise a SuperCollider project on disk?"}, {"role": "assistant", "content": "One folder per piece, with a fixed shape:\n\n```text\nmy-piece/\n  synthdefs.scd   // only SynthDef(...).add, loaded first\n  material.scd    // buffers, samples, scales\n  piece.scd       // the performance: Tdefs, Pbinds, Ndefs\n  README.md       // tempo, required samples, how to run it\n```\n\nThen the workflow is: open `synthdefs.scd`, Ctrl+A Ctrl+Enter to load it, load `material.scd`, and work in\n`piece.scd`. Keeping definitions out of the performance file is what makes a reboot survivable and a piece\nre-runnable six months later."}]}
{"schema": 1, "id": "teacher:workflow:metronome", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How do I use a metronome or check my timing?"}, {"role": "assistant", "content": "A click on the clock you are using, plus a counter to see where you are in the bar:\n\n```supercollider\n(\nTdef(\\click, {\n    var count = 0;\n    loop {\n        (Synth(\\hat, [\\amp, if (count % 4 == 0) { 0.25 } { 0.08 }]));\n        count = count + 1;\n        1.wait;\n    }\n}).play;\n)\n```\n\nBecause it waits on `TempoClock.default`, it stays in sync with every Pbind you start, which makes it a\ntempo reference rather than a separate sound."}]}
{"schema": 1, "id": "teacher:workflow:learn-order", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "In what order should I learn SuperCollider?"}, {"role": "assistant", "content": "The order that pays off fastest:\n\n1. **One UGen and Out** — `{ SinOsc.ar(440) * 0.2 }.play`. Learn that a graph must reach Out.\n2. **Envelopes and doneAction** — the difference between a sound and a click.\n3. **SynthDef and Synth** — naming a graph, controlling it with arguments, freeing it with a gate.\n4. **Patterns** — `Pbind` for sequence, so you stop writing loops by hand.\n5. **Buses and effects** — chaining, sends, groups.\n6. **JITLib** — Ndef for patches you modify while they play.\n\nVocabulary to carry: UGen, SynthDef, Synth, bus, group, envelope, gate, doneAction, Pattern, clock. Every\nconfusion in SuperCollider tends to be one of those words."}]}
{"schema": 1, "id": "teacher:workflow:headless", "family": "T7", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Can I run SuperCollider without the IDE?"}, {"role": "assistant", "content": "Yes. `sclang` runs the language and `scsynth` the server, and they are separate processes by design\n— the IDE is only a client. A headless script is a `.scd` run with `sclang my-piece.scd`, and it must boot\nthe server itself:\n\n```supercollider\ns.boot;\ns.waitForBoot {\n    // build SynthDefs, play, then wait\n    30.wait;\n    s.quit;\n};\n```\n\nThat shape — boot, wait, play, quit, exit — is what makes a piece runnable from a cron job or a\nRaspberry Pi."}]}
{"schema": 1, "id": "teacher:limits:no-audio", "family": "T8", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Can you listen to the sound you generate?"}, {"role": "assistant", "content": "No. I am 198M parameters trained on SuperCollider's documentation and class library; I have no audio input and no way to hear a result. What I can do is reason about the code: whether it reaches an output bus, whether the envelope will ever open, whether a filter at that cutoff leaves anything audible. Treat my patches as a starting point you listen to, not as a judgement about how they sound."}]}
{"schema": 1, "id": "teacher:limits:cannot-run", "family": "T8", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "Can you run this code and tell me if it works?"}, {"role": "assistant", "content": "No — I cannot execute SuperCollider. What I can tell you is what would break and why: bracket balance, arguments that must exist for the class, a SynthDef that never reaches Out, a SynthDef played before it is added, an envelope that frees the Synth immediately. For certainty, evaluate it: the post window reports errors precisely, and `s.plotTree` shows whether the node exists."}]}
{"schema": 1, "id": "teacher:limits:knowledge-boundary", "family": "T8", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How current is your SuperCollider knowledge?"}, {"role": "assistant", "content": "It comes from a snapshot of the SuperCollider repository (documentation, class library and examples) plus code I can reason about. So classes and arguments in that snapshot I know well, including argument order. Quarks, newer UGens, and anything outside the official tree I may not know at all, and I will say so rather than invent a method name. If you need certainty about a class, check its help page — `SinOsc.schelp` in the source tree is the authority."}]}
{"schema": 1, "id": "teacher:limits:verify", "family": "T8", "weight": 3, "turns_count": 1, "conversations": [{"role": "user", "content": "How should I check an answer you give me?"}, {"role": "assistant", "content": "Three quick checks, cheapest first. Does it evaluate without a syntax error — the post window points at the exact character. Does the node appear in `s.plotTree` — if yes, the problem is signal rather than lifecycle. Does it reach `Out.ar(0, ...)` with a non-zero amplitude and an open filter. If those three pass and it is still silent, the class's own help page will show the argument order you may have assumed wrong."}]}