strudel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStrudel
Strudel
Overview
概述
Strudel is a browser-based live-coding environment that ports TidalCycles' pattern language to JavaScript. It uses pure functional programming to create musical patterns that can include drums, melodies, synthesis, and effects. Patterns are immutable query functions that transform time spans into event streams, supporting mini-notation DSL, Euclidean rhythms, and extensive audio processing.
Strudel是一个基于浏览器的实时编码环境,它将TidalCycles的节奏型语言移植到JavaScript中。它采用纯函数式编程来创建包含鼓点、旋律、合成器音效和效果器的音乐节奏型。节奏型是不可变的查询函数,可将时间跨度转换为事件流,支持迷你表示法DSL、欧几里得节奏以及丰富的音频处理功能。
When to Use This Skill
何时使用本技能
Use this skill when:
- Creating drum patterns, melodies, basslines, or full compositions
- Generating algorithmic or generative music
- Applying effects like filters, reverb, delay, or distortion
- Debugging Strudel code or explaining pattern behavior
- Encoding Strudel code into shareable URLs
在以下场景中使用本技能:
- 创建鼓点节奏型、旋律、贝斯线或完整音乐作品
- 生成算法音乐或生成式音乐
- 应用滤波器、混响、延迟或失真等效果器
- 调试Strudel代码或解释节奏型的运行逻辑
- 将Strudel代码编码为可分享的URL
Core Workflow
核心工作流程
1. Understanding the User's Musical Intent
1. 理解用户的音乐创作意图
When a user requests a pattern, clarify:
- Genre/style (techno, ambient, jazz, etc.)
- Artist references (Lorn, Clams Casino, Aphex Twin, etc.)
- Tempo (BPM or cycles per minute)
- Elements needed (drums only, drums + bass, full arrangement)
- Complexity level (simple loop vs. generative/evolving)
For genre/artist-specific techniques, consult which provides:
references/genre-styles.md- Sonic characteristics for common genres and artists
- Strudel implementation patterns
- Concrete code examples for each style
- Typical tempo ranges, effects, and structural elements
当用户请求创作某个节奏型时,需明确以下信息:
- 流派/风格(Techno、氛围音乐、爵士等)
- 参考艺术家(Lorn、Clams Casino、Aphex Twin等)
- 速度(BPM或每分钟循环数)
- 所需元素(仅鼓点、鼓点+贝斯、完整编排)
- 复杂程度(简单循环 vs 生成式/演进式)
针对特定流派/艺术家的创作技巧,可参考,其中包含:
references/genre-styles.md- 常见流派和艺术家的声音特征
- Strudel实现方案
- 每种风格的具体代码示例
- 典型速度范围、效果器使用和结构元素
2. Writing the Pattern
2. 编写节奏型代码
Build patterns using Strudel's functional, compositional approach:
Basic structure:
javascript
// Simple drum pattern
s("bd hh sd hh")
// With tempo
s("bd hh sd hh").cpm(120)
// Layered with stack
stack(
s("bd(3,8)"), // Kick drum
s("hh*8"), // Hi-hats
s("~ sd ~ sd") // Snare on backbeat
).cpm(120)Key patterns:
- Use mini-notation () for concise rhythm specification
"bd hh sd" - Use to layer multiple patterns
stack() - Use for tempo in cycles per minute
.cpm() - Use Euclidean rhythms for interesting distributions
(pulses, steps) - Use lambda functions for transformations:
.off(1/8, x => x.add(7))
采用Strudel的函数式组合方式构建节奏型:
基础结构:
javascript
// Simple drum pattern
s("bd hh sd hh")
// With tempo
s("bd hh sd hh").cpm(120)
// Layered with stack
stack(
s("bd(3,8)"), // Kick drum
s("hh*8"), // Hi-hats
s("~ sd ~ sd") // Snare on backbeat
).cpm(120)关键节奏型写法:
- 使用迷你表示法()简洁定义节奏
"bd hh sd" - 使用叠加多个节奏型
stack() - 使用设置每分钟循环数(速度)
.cpm() - 使用欧几里得节奏创建富有变化的节奏分布
(pulses, steps) - 使用lambda函数实现变换:
.off(1/8, x => x.add(7))
3. Providing Output to the User
3. 向用户交付成果
The user always wants to run the code in their browser. Provide both:
- The raw code - for copy-pasting into https://strudel.cc/
- An encoded URL - using for immediate playback
scripts/strudel_url.py
When to encode URLs:
- Initial creation: Always provide encoded URL when creating a new pattern from scratch
- Iterations/refinements: Skip encoding unless user requests it
- Final version: Offer to encode when work is complete
Encoding a URL:
bash
python3 scripts/strudel_url.py encode 's("bd hh sd hh").cpm(120)'This produces a clickable link like:
https://strudel.cc/#cygiYmQgaGggc2QgaGgiKS5jcG0oMTIwKQ%3D%3DPresent the URL as a clickable link the user can immediately open.
用户始终希望能在浏览器中运行代码,需同时提供:
- 原始代码 - 用于复制粘贴到https://strudel.cc/中运行
- 编码后的URL - 使用生成可直接点击播放的链接
scripts/strudel_url.py
何时生成编码URL:
- 初始创作完成后:从零创建新节奏型时,务必提供编码后的URL
- 迭代/优化过程中:除非用户要求,否则可跳过URL编码
- 最终版本交付时:完成所有修改后,主动提供编码后的URL
生成编码URL的方法:
bash
python3 scripts/strudel_url.py encode 's("bd hh sd hh").cpm(120)'执行后会生成如下可点击链接:
https://strudel.cc/#cygiYmQgaGggc2QgaGgiKS5jcG0oMTIwKQ%3D%3D将该URL以可点击链接的形式呈现给用户,方便其直接打开使用。
4. Iteration and Refinement
4. 迭代与优化
After the user tests the pattern, they may request modifications:
- Adjust tempo: or
.cpm(130)or.slow(2).fast(2) - Add effects: ,
.room(.5),.lpf(1000).delay(.25) - Add variation: ,
.sometimes(x => x.speed(2)).every(4, rev) - Change sounds: Replace sample names or add synthesis parameters
Provide the updated code for copy-pasting. Skip URL encoding during iterations unless requested.
用户测试节奏型后,可能会提出修改需求:
- 调整速度:或
.cpm(130)或.slow(2).fast(2) - 添加效果器:、
.room(.5)、.lpf(1000).delay(.25) - 增加变化:、
.sometimes(x => x.speed(2)).every(4, rev) - 更换音色:替换采样名称或添加合成器参数
提供修改后的代码供用户复制粘贴。迭代过程中除非用户要求,否则无需生成URL编码。
Common Pattern Templates
常用节奏型模板
Use templates from as starting points:
assets/patterns/- techno-drums.js - 4/4 techno with Euclidean patterns
- acid-bass.js - TB-303 style bassline with filter sweeps
- ambient-pad.js - Lush pad with slow chord progression
- generative-melody.js - Algorithmic melody with scale and Euclidean rhythms
- breakbeat.js - Amen break slicing and manipulation
- polyrhythm.js - Multiple time signatures layered
Reference these when users request similar styles.
可使用中的模板作为创作起点:
assets/patterns/- techno-drums.js - 带有欧几里得节奏的4/4拍Techno鼓点
- acid-bass.js - TB-303风格的贝斯线,带滤波器扫频效果
- ambient-pad.js - 舒缓的氛围铺垫,搭配缓慢和弦进行
- generative-melody.js - 基于音阶和欧几里得节奏的算法旋律
- breakbeat.js - Amen碎拍的切片与处理
- polyrhythm.js - 不同拍号的节奏叠加
当用户请求类似风格时,可参考这些模板。
Key Syntax Quick Reference
关键语法速查
Mini-notation:
- - Sequence (evenly distributed)
"a b c" - - Slow cat (one per cycle)
"<a b c>" - - Subdivision (faster)
"[a b]" - - Parallel/chord
"a,b,c" - - Speed up (4x)
"a*4" - - Slow down (2x)
"a/2" - - Euclidean rhythm (3 pulses in 8 steps)
"a(3,8)" - - Rest/silence
"~" - - 50% probability
"a?"
Common functions:
- or
s()- Sample selection.sound() - or
note()- Pitch (note name or MIDI number).note() - - Apply scale (e.g.,
.scale())"C:minor" - - Layer patterns
stack() - /
.fast()- Speed control.slow() - - Reverse
.rev() - - Apply transformation 50% of the time
.sometimes() - - Apply transformation every n cycles
.every(n, fn)
Effects:
- - Low-pass filter (cutoff frequency)
.lpf() - - High-pass filter
.hpf() - - Reverb (0-1)
.room() - - Delay effect (0-1)
.delay() - - Volume
.gain() - - Stereo position (0=left, 1=right)
.pan()
For comprehensive syntax, consult which contains:
references/strudel-reference.md- Complete mini-notation syntax
- All pattern transformations (Euclidean, temporal, stochastic)
- Audio effects and synthesis parameters
- Signal functions (sine, perlin, saw, etc.)
- Pattern alignment strategies
- Practical composition examples
Search this file with grep when needed:
bash
grep -i "euclidean" references/strudel-reference.md
grep -i "filter" references/strudel-reference.md
grep -i "delay" references/strudel-reference.md迷你表示法:
- - 序列(均匀分布)
"a b c" - - 慢循环(每周期播放一个)
"<a b c>" - - 细分(加快播放速度)
"[a b]" - - 并行/和弦
"a,b,c" - - 加速4倍
"a*4" - - 减速至1/2
"a/2" - - 欧几里得节奏(8步内播放3个脉冲)
"a(3,8)" - - 休止/静音
"~" - - 50%概率触发
"a?"
常用函数:
- 或
s()- 选择采样.sound() - 或
note()- 设置音高(音符名称或MIDI编号).note() - - 应用音阶(例如
.scale())"C:minor" - - 叠加节奏型
stack() - /
.fast()- 速度控制.slow() - - 反向播放
.rev() - - 50%概率应用变换
.sometimes() - - 每n个周期应用一次变换
.every(n, fn)
效果器:
- - 低通滤波器(截止频率)
.lpf() - - 高通滤波器
.hpf() - - 房间混响(0-1)
.room() - - 延迟效果(0-1)
.delay() - - 音量控制
.gain() - - 立体声定位(0=左,1=右)
.pan()
如需完整语法参考,请查阅,其中包含:
references/strudel-reference.md- 完整的迷你表示法语法
- 所有节奏型变换(欧几里得、时间、随机)
- 音频效果器和合成器参数
- 信号函数(正弦、柏林噪声、锯齿波等)
- 节奏型对齐策略
- 实用作曲示例
可使用grep命令在该文件中搜索所需内容:
bash
grep -i "euclidean" references/strudel-reference.md
grep -i "filter" references/strudel-reference.md
grep -i "delay" references/strudel-reference.mdDebugging Common Issues
常见问题调试
Pattern not playing:
- Ensure the pattern ends with appropriate audio output (,
.s(), or.sound()).note() - Check that samples are loaded (default samples work without loading)
- Verify syntax: balanced brackets, quotes, parentheses
Timing issues:
- Use or
.cpm()to set tempo explicitlysetcpm() - Check for conflicting /
.fast()calls.slow() - Verify Euclidean rhythms have valid (pulses, steps) values
Filter not working:
- Ensure cutoff frequency is in valid range (20-20000 Hz)
- Check filter envelope parameters (,
.lpa(),.lpd(),.lps()).lpr() - Use for filter envelope depth
.lpenv()
Code too complex:
- Break into smaller patterns and test individually
- Use variables:
let drums = s("bd hh") - Stack tested patterns:
stack(drums, bass, melody)
节奏型无法播放:
- 确保节奏型代码末尾包含正确的音频输出调用(、
.s()或.sound()).note() - 检查采样是否已加载(默认采样无需额外加载即可使用)
- 验证语法正确性:括号、引号是否配对
** timing问题(节奏不准):**
- 使用或
.cpm()明确设置速度setcpm() - 检查是否存在冲突的/
.fast()调用.slow() - 验证欧几里得节奏的(脉冲数,步数)参数是否有效
滤波器不生效:
- 确保截止频率在有效范围(20-20000 Hz)内
- 检查滤波器包络参数(、
.lpa()、.lpd()、.lps()).lpr() - 使用设置滤波器包络深度
.lpenv()
代码过于复杂:
- 将代码拆分为多个小节奏型,逐个测试
- 使用变量存储节奏型:
let drums = s("bd hh") - 将测试通过的节奏型叠加:
stack(drums, bass, melody)
Resources
资源
scripts/strudel_url.py
scripts/strudel_url.py
Python script for encoding/decoding Strudel URLs.
Encode:
bash
python3 scripts/strudel_url.py encode '<strudel-code>'Decode:
bash
python3 scripts/strudel_url.py decode '<strudel-url>'Always encode URLs after creating or modifying patterns to provide clickable links.
用于编码/解码Strudel URL的Python脚本。
编码:
bash
python3 scripts/strudel_url.py encode '<strudel-code>'解码:
bash
python3 scripts/strudel_url.py decode '<strudel-url>'创建或修改节奏型后,务必生成编码URL以提供可点击的播放链接。
references/strudel-reference.md
references/strudel-reference.md
Comprehensive technical reference including:
- Complete mini-notation syntax
- All pattern operations and transformations
- Audio effects and synthesis
- Signals and continuous patterns
- Composition examples
- Best practices
Load this file when users need detailed syntax explanations or advanced techniques.
全面的技术参考文档,包含:
- 完整的迷你表示法语法
- 所有节奏型操作与变换
- 音频效果器与合成器参数
- 信号与连续节奏型
- 作曲示例
- 最佳实践
当用户需要详细的语法解释或高级创作技巧时,可查阅该文档。
references/genre-styles.md
references/genre-styles.md
Genre and artist style guide including:
- Dark Ambient Hip-Hop (Lorn, Clams Casino)
- Techno (General, Dub Techno)
- Drum & Bass / Jungle (Jungle, Liquid DnB)
- Trap / Hip-Hop (Trap, Boom Bap)
- Ambient / Experimental (Dark Ambient, IDM/Glitch)
- House (Deep House, Acid House)
Each entry provides sonic characteristics and Strudel implementation techniques. Load when users reference specific genres or artists.
Search this file when needed:
bash
grep -i "lorn" references/genre-styles.md
grep -i "techno" references/genre-styles.md
grep -i "ambient" references/genre-styles.md流派与艺术家风格指南,包含:
- 黑暗氛围嘻哈(Lorn、Clams Casino)
- Techno(通用、Dub Techno)
- 鼓打贝斯/丛林音乐(Jungle、Liquid DnB)
- Trap/嘻哈(Trap、Boom Bap)
- 氛围/实验音乐(黑暗氛围、IDM/Glitch)
- House(Deep House、Acid House)
每个条目都提供了声音特征和Strudel实现技巧。当用户提及特定流派或艺术家时,可参考该文档。
可使用grep命令在该文件中搜索所需内容:
bash
grep -i "lorn" references/genre-styles.md
grep -i "techno" references/genre-styles.md
grep -i "ambient" references/genre-styles.mdassets/patterns/
assets/patterns/
Example pattern templates for common musical styles. Copy and adapt these as starting points:
- - Electronic drum patterns
techno-drums.js - - Resonant basslines
acid-bass.js - - Atmospheric textures
ambient-pad.js - - Algorithmic melodies
generative-melody.js - - Sample manipulation
breakbeat.js - - Complex rhythmic structures
polyrhythm.js
适用于常见音乐风格的节奏型示例模板,可复制并修改后作为创作起点:
- - 电子鼓点节奏型
techno-drums.js - - 共鸣贝斯线
acid-bass.js - - 氛围音色铺垫
ambient-pad.js - - 算法生成旋律
generative-melody.js - - 采样处理
breakbeat.js - - 复杂节奏结构
polyrhythm.js