fix agents

This commit is contained in:
libretech committed 2025-09-27 23:10:16 +02:00
1 parent d01c64200d
commit a3c8e198a7
1 file changed
+273 -30
+273 -30
View File
@@ -8,9 +8,10 @@ This document provides essential guidelines for AI agents assisting with Strudel
### Critical Knowledge Requirements
#### 1. Core Syntax Understanding
- **NOT JavaScript**: Strudel uses its own pattern-based syntax, not standard JavaScript
- **NO variable declarations**: No `const`, `let`, `var`, `export`, `import`
- **NO function syntax**: Patterns are composed directly, not stored in functions
- **IS JavaScript**: Strudel is built on JavaScript and supports all JavaScript features including variables, functions, objects, arrays, loops, conditionals, and more
- **Variable declarations**: You can use `const`, `let`, `var` for variables
- **Function syntax**: You can define functions using arrow functions, regular functions, or the `register()` function for custom pattern functions
- **ES6+ features**: Template literals, destructuring, spread operators, async/await, etc. are all supported
#### 2. Parallel Pattern Syntax
```javascript
@@ -19,9 +20,21 @@ $: sound("bd*4")
$: sound("~ sd ~ sd")
$: sound("hh*8").gain(0.3)
// ❌ WRONG - JavaScript-style
// ✅ ALSO CORRECT - JavaScript variables and functions
const kick = sound("bd*4");
const snare = sound("~ sd ~ sd");
const hats = sound("hh*8").gain(0.3);
stack(kick, snare, hats)
// ✅ Custom functions
const createBeat = () => stack(
sound("bd*4"),
sound("~ sd ~ sd"),
sound("hh*8").gain(0.3)
);
createBeat()
```
#### 3. Muting Patterns
@@ -31,6 +44,12 @@ _$: sound("bd*4") // underscore mutes
// ✅ Active pattern
$: sound("bd*4") // dollar sign plays
// ✅ Named patterns (can be muted/unmuted)
kick: sound("bd*4")
snare: sound("~ sd ~ sd")
// To mute: _kick: sound("bd*4")
```
#### 4. Notes and Scales
@@ -85,13 +104,21 @@ $: n("0 2 4 6").sound("gm_acoustic_bass") // GM sounds
```
##### Built-in Synths
```
brown bytebeat crackle gm_accordion(7) gm_acoustic_bass(4) gm_acoustic_guitar_nylon(9) gm_acoustic_guitar_steel(10) gm_agogo(6) gm_alto_sax(6) gm_applause(15) gm_bagpipe(1) gm_bandoneon(10) gm_banjo(6) gm_baritone_sax(6) gm_bassoon(4) gm_bird_tweet(7) gm_blown_bottle(5) gm_brass_section(5) gm_breath_noise(8) gm_celesta(6) gm_cello(6) gm_choir_aahs(9) gm_church_organ(5) gm_clarinet(6) gm_clavinet(4) gm_contrabass(3) gm_distortion_guitar(7) gm_drawbar_organ(7) gm_dulcimer(5) gm_electric_bass_finger(4) gm_electric_bass_pick(5) gm_electric_guitar_clean(9) gm_electric_guitar_jazz(9) gm_electric_guitar_muted(10) gm_english_horn(4) gm_epiano1(11) gm_epiano2(9) gm_fiddle(9) gm_flute(5) gm_french_horn(5) gm_fretless_bass(2) gm_fx_atmosphere(13) gm_fx_brightness(12) gm_fx_crystal(10) gm_fx_echoes(10) gm_fx_goblins(9) gm_fx_rain(6) gm_fx_sci_fi(9) gm_fx_soundtrack(5) gm_glockenspiel(5) gm_guitar_fret_noise(8) gm_guitar_harmonics(3) gm_gunshot(12) gm_harmonica(6) gm_harpsichord(8) gm_helicopter(16) gm_kalimba(5) gm_koto(9) gm_lead_1_square(3) gm_lead_2_sawtooth(7) gm_lead_3_calliope(7) gm_lead_4_chiff(6) gm_lead_5_charang(10) gm_lead_6_voice(6) gm_lead_7_fifths(5) gm_lead_8_bass_lead(5) gm_marimba(7) gm_melodic_tom(9) gm_music_box(5) gm_muted_trumpet(5) gm_oboe(5) gm_ocarina(4) gm_orchestra_hit(5) gm_orchestral_harp(5) gm_overdriven_guitar(10) gm_pad_bowed(5) gm_pad_choir(6) gm_pad_halo(8) gm_pad_metallic(7) gm_pad_new_age(12) gm_pad_poly(7) gm_pad_sweep(7) gm_pad_warm(7) gm_pan_flute(8) gm_percussive_organ(6) gm_piano(32) gm_piccolo(5) gm_pizzicato_strings(6) gm_recorder(5) gm_reed_organ(8) gm_reverse_cymbal(9) gm_rock_organ(5) gm_seashore(16) gm_shakuhachi(5) gm_shamisen(7) gm_shanai(5) gm_sitar(7) gm_slap_bass_1(4) gm_slap_bass_2(4) gm_soprano_sax(5) gm_steel_drums(6) gm_string_ensemble_1(11) gm_string_ensemble_2(7) gm_synth_bass_1(9) gm_synth_bass_2(7) gm_synth_brass_1(4) gm_synth_brass_2(7) gm_synth_choir(5) gm_synth_drum(7) gm_synth_strings_1(7) gm_synth_strings_2(4) gm_taiko_drum(10) gm_telephone(10) gm_tenor_sax(4) gm_timpani(6) gm_tinkle_bell(1) gm_tremolo_strings(6) gm_trombone(5) gm_trumpet(4) gm_tuba(4) gm_tubular_bells(6) gm_vibraphone(6) gm_viola(5) gm_violin(9) gm_voice_oohs(6) gm_whistle(4) gm_woodblock(9) gm_xylophone(6) pink pulse saw sawtooth sbd sin sine sqr square supersaw tri triangle white z_noise z_sawtooth z_sine z_square z_tan z_triangle zzfx
```
##### Built-in Drum Machines
```
9000_bd(1) 9000_cb(2) 9000_cr(2) 9000_hh(1) 9000_ht(2) 9000_lt(2) 9000_mt(1) 9000_oh(1) 9000_perc(3) 9000_rd(2) 9000_rim(1) 9000_sd(1) 9000_tb(1) ace_bd(3) ace_hh(1) ace_ht(1) ace_lt(1) ace_oh(1) ace_perc(6) ace_sd(3) ajkpercusyn_bd(1) ajkpercusyn_cb(2) ajkpercusyn_ht(1) ajkpercusyn_sd(1) akailinn_bd(1) akailinn_cb(1) akailinn_cp(1) akailinn_cr(1) akailinn_hh(1) akailinn_ht(1) akailinn_lt(1) akailinn_mt(1) akailinn_oh(1) akailinn_rd(1) akailinn_sd(1) akailinn_sh(1) akailinn_tb(1) akaimpc60_bd(2) akaimpc60_cp(1) akaimpc60_cr(1) akaimpc60_hh(1) akaimpc60_ht(1) akaimpc60_lt(1) akaimpc60_misc(2) akaimpc60_mt(1) akaimpc60_oh(1) akaimpc60_perc(5) akaimpc60_rd(1) akaimpc60_rim(1) akaimpc60_sd(3) akaixr10_bd(10) akaixr10_cb(1) akaixr10_cp(1) akaixr10_cr(3) akaixr10_hh(2) akaixr10_ht(1) akaixr10_lt(2) akaixr10_misc(4) akaixr10_mt(2) akaixr10_oh(1) akaixr10_perc(15) akaixr10_rd(1) akaixr10_rim(2) akaixr10_sd(10) akaixr10_sh(1) akaixr10_tb(1) alesishr16_bd(1) alesishr16_cp(1) alesishr16_hh(1) alesishr16_ht(1) alesishr16_lt(1) alesishr16_oh(1) alesishr16_perc(8) alesishr16_rim(1) alesishr16_sd(1) alesishr16_sh(3) alesissr16_bd(13) alesissr16_cb(1) alesissr16_cp(1) alesissr16_cr(2) alesissr16_hh(3) alesissr16_misc(3) alesissr16_oh(4) alesissr16_perc(7) alesissr16_rd(3) alesissr16_rim(1) alesissr16_sd(12) alesissr16_sh(1) alesissr16_tb(1) bd(8) bossdr110_bd(1) bossdr110_cp(1) bossdr110_cr(1) bossdr110_hh(1) bossdr110_oh(1) bossdr110_rd(1) bossdr110_sd(1) bossdr220_bd(1) bossdr220_cp(1) bossdr220_cr(1) bossdr220_hh(1) bossdr220_ht(1) bossdr220_lt(1) bossdr220_mt(1) bossdr220_oh(1) bossdr220_perc(1) bossdr220_rd(1) bossdr220_sd(1) bossdr55_bd(2) bossdr55_hh(2) bossdr55_rim(1) bossdr55_sd(8) bossdr550_bd(5) bossdr550_cb(2) bossdr550_cp(1) bossdr550_cr(1) bossdr550_hh(2) bossdr550_ht(3) bossdr550_lt(3) bossdr550_misc(3) bossdr550_mt(2) bossdr550_oh(2) bossdr550_perc(11) bossdr550_rd(2) bossdr550_rim(1) bossdr550_sd(6) bossdr550_sh(2) bossdr550_tb(1) brk(1) casiorz1_bd(1) casiorz1_cb(1) casiorz1_cp(1) casiorz1_cr(1) casiorz1_hh(1) casiorz1_ht(1) casiorz1_lt(1) casiorz1_mt(1) casiorz1_rd(2) casiorz1_rim(1) casiorz1_sd(1) casiosk1_bd(1) casiosk1_hh(1) casiosk1_ht(1) casiosk1_mt(1) casiosk1_oh(1) casiosk1_sd(1) casiovl1_bd(1) casiovl1_hh(1) casiovl1_sd(1) cb(1) circuitsdrumtracks_bd(1) circuitsdrumtracks_cb(1) circuitsdrumtracks_cp(1) circuitsdrumtracks_cr(1) circuitsdrumtracks_hh(1) circuitsdrumtracks_ht(1) circuitsdrumtracks_oh(1) circuitsdrumtracks_rd(1) circuitsdrumtracks_rim(1) circuitsdrumtracks_sd(1) circuitsdrumtracks_sh(1) circuitsdrumtracks_tb(1) circuitstom_bd(1) circuitstom_cp(1) circuitstom_cr(1) circuitstom_hh(1) circuitstom_ht(2) circuitstom_oh(1) circuitstom_sd(1) compurhythm1000_bd(1) compurhythm1000_cb(1) compurhythm1000_cp(1) compurhythm1000_cr(1) compurhythm1000_hh(1) compurhythm1000_ht(1) compurhythm1000_lt(1) compurhythm1000_mt(1) compurhythm1000_oh(1) compurhythm1000_perc(3) compurhythm1000_rd(1) compurhythm1000_rim(1) compurhythm1000_sd(1) compurhythm78_bd(1) compurhythm78_cb(1) compurhythm78_hh(2) compurhythm78_misc(4) compurhythm78_oh(2) compurhythm78_perc(8) compurhythm78_sd(1) compurhythm78_tb(1) compurhythm8000_bd(1) compurhythm8000_cb(1) compurhythm8000_cp(1) compurhythm8000_cr(1) compurhythm8000_hh(1) compurhythm8000_ht(1) compurhythm8000_lt(1) compurhythm8000_mt(1) compurhythm8000_oh(1) compurhythm8000_perc(2) compurhythm8000_rim(1) compurhythm8000_sd(1) concertmatemg1_bd(3) concertmatemg1_sd(2) cp(2) cr(2) d110_bd(1) d110_cb(2) d110_cr(1) d110_hh(1) d110_lt(1) d110_oh(2) d110_perc(3) d110_rd(1) d110_rim(1) d110_sd(3) d110_sh(1) d110_tb(1) d70_bd(4) d70_cb(1) d70_cp(1) d70_cr(1) d70_hh(1) d70_lt(1) d70_mt(1) d70_oh(1) d70_perc(1) d70_rd(1) d70_rim(1) d70_sd(5) d70_sh(1) ddm110_bd(1) ddm110_cp(1) ddm110_cr(1) ddm110_hh(1) ddm110_ht(2) ddm110_lt(2) ddm110_oh(1) ddm110_rim(1) ddm110_sd(1) ddr30_bd(8) ddr30_ht(4) ddr30_lt(4) ddr30_sd(8) dmx_bd(3) dmx_cp(1) dmx_cr(1) dmx_hh(1) dmx_ht(1) dmx_lt(1) dmx_mt(1) dmx_oh(1) dmx_rd(1) dmx_rim(1) dmx_sd(3) dmx_sh(1) dmx_tb(1) doepferms404_bd(2) doepferms404_hh(1) doepferms404_lt(1) doepferms404_oh(1) doepferms404_sd(1) dpm48_bd(3) dpm48_cp(1) dpm48_cr(1) dpm48_hh(2) dpm48_ht(1) dpm48_lt(2) dpm48_mt(1) dpm48_oh(1) dpm48_perc(2) dpm48_rd(1) dpm48_rim(1) dpm48_sd(2) dpm48_sh(2) dr110_bd(1) dr110_cp(1) dr110_cr(1) dr110_hh(1) dr110_oh(1) dr110_rd(1) dr110_sd(1) dr220_bd(1) dr220_cp(1) dr220_cr(1) dr220_hh(1) dr220_ht(1) dr220_lt(1) dr220_mt(1) dr220_oh(1) dr220_perc(1) dr220_rd(1) dr220_sd(1) dr55_bd(2) dr55_hh(2) dr55_rim(1) dr55_sd(8) dr550_bd(5) dr550_cb(2) dr550_cp(1) dr550_cr(1) dr550_hh(2) dr550_ht(3) dr550_lt(3) dr550_misc(3) dr550_mt(2) dr550_oh(2) dr550_perc(11) dr550_rd(2) dr550_rim(1) dr550_sd(6) dr550_sh(2) dr550_tb(1) drumulator_bd(1) drumulator_cb(1) drumulator_cp(1) drumulator_cr(1) drumulator_hh(1) drumulator_ht(1) drumulator_lt(1) drumulator_mt(1) drumulator_oh(1) drumulator_perc(1) drumulator_rim(1) drumulator_sd(1) emudrumulator_bd(1) emudrumulatLine truncated
```
##### Built-in Samples
```
agogo(5) anvil(9) balafon(6) balafon_hard(6) balafon_soft(6) ballwhistle(2) bassdrum1(8) bassdrum2(30) belltree(6) bongo(28) brakedrum(17) cabasa(6) cajon(18) casio(3) clap(10) clash(10) clash2(5) clave(6) clavisynth(19) conga(34) cowbell(13) crow(4) dantranh(17) dantranh_tremolo(16) dantranh_vibrato(16) darbuka(20) didgeridoo(12) east(9) fingercymbal(1) flexatone(8) fmpiano(22) folkharp(29) framedrum(18) glockenspiel(7) gong(7) gong2(6) guiro(5) handbells(3) handchimes(19) harmonica(9) harmonica_soft(10) harmonica_vib(10) harp(23) hihat(15) insect(3) jazz(8) kalimba(11) kalimba2(25) kalimba3(22) kalimba4(22) kalimba5(14) kawai(37) marimba(10) marktrees(6) metal(10) num(21) numbers(9) ocarina(11) ocarina_small(10) ocarina_small_stacc(13) ocarina_vib(10) oceandrum(3) organ_4inch(27) organ_8inch(27) organ_full(27) piano(29) piano1(22) pipeorgan_loud(21) pipeorgan_loud_pedal(11) pipeorgan_quiet(21) pipeorgan_quiet_pedal(11) psaltery_bow(11) psaltery_pluck(11) psaltery_spiccato(11) ratchet(8) recorder_alto_stacc(12) recorder_alto_sus(12) recorder_alto_vib(12) recorder_bass_stacc(15) recorder_bass_sus(12) recorder_bass_vib(14) recorder_soprano_stacc(12) recorder_soprano_sus(13) recorder_tenor_stacc(12) recorder_tenor_sus(13) recorder_tenor_vib(14) sax(23) sax_stacc(23) sax_vib(19) saxello(8) saxello_stacc(8) saxello_vib(8) shaker_large(6) shaker_small(16) siren(5) slapstick(5) sleighbells(6) slitdrum(6) snare_hi(8) snare_low(20) snare_modern(72) snare_rim(4) space(18) steinway(42) strumstick(19) super64(13) super64_acc(13) super64_vib(13) sus_cymbal(25) sus_cymbal2(23) tambourine(7) tambourine2(7) timpani(30) timpani_roll(10) timpani2(204) tom_mallet(8) tom_rim(6) tom_stick(8) tom2_mallet(8) tom2_rim(6) tom2_stick(8) trainwhistle(6) triangles(37) tubularbells(9) tubularbells2(11) vibraphone(11) vibraphone_bowed(6) vibraphone_soft(11) vibraslap(4) wind(10) wineglass(4) wineglass_slow(4) woodblock(10) xylophone_hard_ff(8) xylophone_hard_pp(8) xylophone_medium_ff(8) xylophone_medium_pp(8) xylophone_soft_ff(8) xylophone_soft_pp(8)
```
**Note**: Strudel includes hundreds of built-in synths, drum machines, and samples. See the examples/ directory for extensive usage of various sound sources including custom banks and GM instruments.
#### 8. Effects and Modulation
```javascript
@@ -145,48 +172,188 @@ Strudel supports several advanced features for complex live coding:
**Interactive Elements**: Strudel supports embedding interactive controls directly in code, allowing real-time parameter manipulation during performance.
**Custom Pattern Functions**: Use `register()` to create reusable pattern transformations and effects.
**Euclidean Rhythms**: `.euclid()` for generating complex rhythmic patterns algorithmically.
**Arrangement Tools**: `arrange()` for sequencing different sections of music.
**Advanced Pattern Manipulation**: `.pickRestart()`, `.pickOut()`, `.split()`, `.penv()` for sophisticated pattern control.
**Markov Chains**: `.markov()` for generative music using probability matrices.
**Looping and Sampling**: `.loop()`, `.loopBegin()`, `.loopEnd()`, `.speed()` for sample manipulation.
**Envelope Control**: `.attack()`, `.sustain()`, `.adsr()` for shaping sound envelopes.
**Structural Control**: `.struct()`, `.clip()`, `.segment()` for pattern structuring.
**Math Operations**: `.add()`, `.sub()`, `.mul()`, `.div()` for mathematical transformations.
**External Integration**: Support for Hydra visuals, MIDI, OSC, and other external systems.
**Interactive Controls**: `slider()`, keyboard event handlers for live parameter control.
These features enable sophisticated composition techniques beyond basic sequencing, supporting professional live coding performance.
## Additional Features from Examples
Based on analysis of the examples/ directory, here are additional Strudel features and patterns:
### Pattern Construction Functions
```javascript
// stack() - Layer multiple patterns
stack(
sound("bd*4"),
sound("~ sd ~ sd"),
sound("hh*8")
)
// arrange() - Sequence different sections
const verse = sound("bd*4")
const chorus = sound("bd*8").fast(2)
arrange([4, verse], [4, chorus]) // 4 cycles of verse, 4 of chorus
```
### Custom Pattern Functions with register()
```javascript
// Create reusable effects
const stutter = register('stutter', (times, pat) =>
pat.fast(times).segment(times).slow(times)
);
const euclidPattern = register('euclidPattern', (pulses, steps, pat) =>
pat.euclid(pulses, steps)
);
// Usage
$: sound("bd").stutter(4)
$: sound("hh").euclidPattern(3, 8)
```
### Interactive Controls
```javascript
// Slider controls for live manipulation
$: sound("bd*4").lpf(slider(1, 200, 2000)) // freq from 200-2000
// Keyboard input
window.onkeydown = (e) => {
if (e.key === ' ') setCps(getCps() * 1.1); // speed up on space
}
```
### Advanced Sound Design
```javascript
// ADSR envelopes
$: sound("piano").adsr([0.01, 0.1, 0.8, 0.2])
// Sample manipulation
$: sound("bd").loop(1).loopBegin(0.1).loopEnd(0.3).speed(0.5)
// Pitch envelopes
$: note("c4").penv([0, 1, 0.5, 0]) // pitch envelope
```
### Generative Techniques
```javascript
// Markov chains for generative music
const markov = register('markov', (id, pat) => pat.withHap((hap) => {
// Implementation for markov chain generation
}));
// Random selection
$: sound(rand.range(0, 3).pick(["bd", "sd", "hh"]))
// Euclidean rhythms
$: sound("bd").euclid(3, 8) // 3 hits in 8 steps
```
### External Integration
```javascript
// Hydra visuals integration
await initHydra()
solid(0,0,0).add(osc(10, 0.1, 10)).out()
// MIDI, OSC, etc. (depending on packages loaded)
```
### Complex Arrangement Techniques
```javascript
// pickRestart() for conditional patterns
"<a b c>".pickRestart({
a: "bd*4",
b: "~ sd ~ sd",
c: "hh*8"
})
// split() for multi-output patterns
"0 1 2".split([0, 0], parts =>
stack(
n(parts[0]).sound("piano"),
n(parts[1]).sound("bass")
)
)
```
### Live Performance Techniques
```javascript
// Hush to silence all
$: sound("bd").hush()
// Conditional muting
_$: sound("bd*4") // muted
$: sound("bd*4") // active
// Real-time parameter changes
let intensity = 1;
setInterval(() => intensity = Math.random(), 1000);
$: sound("bd*4").gain(intensity)
```
### Documentation Sources
Before providing Strudel code, agents should:
1. **Always check official documentation**: https://strudel.cc/
2. **Reference workshop tutorials**: https://strudel.cc/workshop/
3. **Verify syntax against examples** in the Strudel REPL
3. **Analyze examples/**: Study the examples/ directory for advanced patterns and JavaScript integration
4. **Verify syntax against examples** in the Strudel REPL
### Common Mistakes to Avoid
#### ❌ JavaScript Assumptions
#### ❌ Incorrect Assumptions (These are actually CORRECT in Strudel!)
```javascript
// WRONG - This is not JavaScript
// ✅ CORRECT - JavaScript variables work fine
const pattern = sound("bd*4");
export default pattern;
import { stack } from "strudel";
```
const kick = sound("bd*4");
kick.gain(0.8);
#### ❌ Function Declarations
```javascript
// WRONG - No function syntax
// ✅ CORRECT - Function declarations work
function createBeat() {
return sound("bd*4");
}
```
#### ❌ Stack Usage
```javascript
// WRONG - stack() doesn't exist in REPL
// ✅ CORRECT - stack() function exists and works
stack(
sound("bd*4"),
sound("~ sd ~ sd")
)
// ✅ CORRECT - All JavaScript features work
const beats = ["bd", "sd", "hh"];
beats.forEach(sound => {
$: s(sound + "*4")
});
```
#### ❌ Variable References
#### ❌ Actual Mistakes to Avoid
```javascript
// WRONG - No variable system
const kick = sound("bd*4");
kick.gain(0.8);
// WRONG - Missing $: prefix for anonymous patterns
sound("bd*4") // This won't play unless assigned to a variable or used in stack()
// WRONG - Incorrect mini-notation
$: sound("bd*4 sd*4") // This plays both simultaneously, not sequentially
// CORRECT: $: sound("bd sd").fast(4) // or $: sound("<bd sd>*4")
```
### ✅ Correct Patterns
@@ -199,6 +366,63 @@ $: sound("~ sd ~ sd").gain(0.7)
$: sound("hh*8").gain(0.3).hpf(8000)
$: n("0 ~ 2 ~ 4 ~ 6 ~").scale("C2:minor").sound("sawtooth").lpf(120)
$: n("~ 0 ~ 2 ~ 4 ~ 6").scale("C4:minor").sound("piano").room(0.6)
// Using JavaScript variables and functions
const tempo = 120;
const createDrums = () => stack(
sound("bd*4").gain(0.8),
sound("~ sd ~ sd").gain(0.7),
sound("hh*8").gain(0.3)
);
setCps(tempo/60/4);
createDrums();
```
#### Live Coding Effects
```javascript
// Instant filter sweep
$: sound("bd*4").lpf(sine.range(100, 2000).slow(4))
// Rhythmic gating
$: n("0 2 4 6").scale("C:minor").sound("piano").mask("1 0 1 1")
// Probability effects
$: sound("hh*8").sometimes(rev).often(x => x.fast(2))
// Custom functions with register()
const stutter = register('stutter', (times, pat) =>
pat.fast(times).segment(times).slow(times)
);
$: sound("bd").stutter(4) // Creates stutter effect
```
#### Advanced JavaScript Integration
```javascript
// Arrays and loops
const notes = ["c", "d", "e", "f", "g"];
notes.forEach((note, i) => {
$: note(i*2).sound("piano").delay(i*0.1)
});
// Objects for complex patterns
const instruments = {
kick: sound("bd*4").gain(0.8),
snare: sound("~ sd ~ sd").gain(0.7),
hats: sound("hh*8").gain(0.3)
};
stack(instruments.kick, instruments.snare, instruments.hats);
// Async functions for dynamic content
const loadPattern = async () => {
const response = await fetch('/api/pattern');
const data = await response.json();
return sound(data.pattern);
};
loadPattern().then(pattern => pattern.gain(0.5));
```
#### Live Coding Effects
@@ -217,10 +441,12 @@ $: sound("hh*8").sometimes(rev).often(x => x.gain(0.5))
1. **Read documentation first** when unsure about syntax
2. **Provide working examples** that can be copy-pasted into REPL
3. **Use `$:` prefix** for all patterns
3. **Use `$:` prefix** for anonymous patterns or named patterns with `:`
4. **Include muting options** with `_$:` for live performance
5. **Explain mini-notation** when using complex patterns
6. **Test understanding** by referring to official examples
6. **Leverage JavaScript features** including variables, functions, loops, and custom logic
7. **Use `stack()`** for layering multiple patterns
8. **Test understanding** by referring to official examples and the examples/ directory
### Git Commit Guidelines
@@ -342,15 +568,32 @@ When creating beats for live performance:
### Example Response Structure
```javascript
// MAIN BEAT
$: sound("bd*4").gain(0.8) // kick
$: sound("~ sd ~ sd").gain(0.7) // snare
$: sound("hh*8").gain(0.3) // hats
$: n("0 ~ 2 ~ 4 ~ 6 ~").scale("C2:minor").sound("sawtooth") // bass
// Using JavaScript variables and functions
const tempo = 120;
const gain = 0.8;
setCps(tempo/60/4);
// Custom function for creating beats
const createBeat = (intensity = 1) => stack(
sound("bd*4").gain(gain * intensity),
sound("~ sd ~ sd").gain(0.7 * intensity),
sound("hh*8").gain(0.3 * intensity)
);
// Named patterns for live control
kick: sound("bd*4").gain(gain)
snare: sound("~ sd ~ sd").gain(0.7)
hats: sound("hh*8").gain(0.3)
bass: n("0 ~ 2 ~ 4 ~ 6 ~").scale("C2:minor").sound("sawtooth")
// MAIN BEAT - uncomment to play
// stack(kick, snare, hats, bass)
// LIVE VARIATIONS (comment/uncomment as needed)
// $: sound("bd*4").lpf(sine.range(200, 2000).slow(8)) // filter sweep
// $: sound("~ sd ~ sd").mask("1 0 1 1") // gated snare
// createBeat(0.5).lpf(sine.range(200, 2000).slow(8)) // filter sweep
// snare.mask("1 0 1 1") // gated snare
// hats.sometimes(rev).often(x => x.fast(2)) // probability effects
```
This structure allows for immediate use and live manipulation in the Strudel REPL environment.