pattrns
Original:🇺🇸 English
Translated
4 scriptsChecked / no sensitive code detected
Guide for creating generative, emergent music with Pattrns, the Lua-based pattern sequencing engine for Renoise. Use when composing algorithmic patterns, generating evolving breakbeats/rhythms, creating generative melodies/harmonies, designing textures, or working with euclidean rhythms and live coding patterns. Covers breakbeat/jungle/DnB, IDM/experimental, jazz, industrial/trip-hop, and ambient styles.
6installs
Sourcebfollington/terma
Added on
NPX Install
npx skill4agent add bfollington/terma pattrnsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Pattrns - Generative Music Creation
Overview
Pattrns is a Lua-based pattern generation engine for Renoise that enables algorithmic, generative music creation. Use this skill when working with Pattrns to create emergent, evolving musical patterns across genres including breakbeat/jungle, IDM, jazz, industrial/trip-hop, and ambient music.
Core Architecture: Pattrns separates rhythm from melody through a Pulse → Gate → Event pipeline:
- Pulse: Defines when events occur (rhythm)
- Gate: Optional filter for pulse values (probability, complexity)
- Event: Generates notes, chords, or sequences (melody/harmony)
This separation enables powerful generative techniques where rhythms and melodies can evolve independently and be recombined in creative ways.
When to Use This Skill
Invoke this skill when:
- Creating generative or algorithmic patterns in Renoise
- Working with euclidean rhythms or polyrhythms
- Designing evolving, emergent musical structures
- Generating breakbeats, complex drum patterns, or rhythmic variations
- Creating generative melodies, harmonies, or chord progressions
- Building textural, ambient, or atmospheric patterns
- Using Tidal Cycles mini-notation for pattern creation
- Developing patterns that resample and resequence for iterative composition
Quick Start
Basic Pattern Structure
Every Pattrns pattern follows this structure:
lua
return pattern {
unit = "1/16", -- Time grid (1/16, 1/8, 1/4, bars, etc.)
resolution = 1, -- Multiplier (2/3 for triplets)
offset = 0, -- Delay pattern start
repeats = true, -- Loop pattern
pulse = {1, 0, 1, 1}, -- Static rhythm array
event = {"c4", "e4", "g4"} -- Static note sequence
}Essential Techniques at a Glance
Euclidean Rhythms (most common starting point):
lua
pulse = pulse.euclidean(7, 16) -- 7 hits distributed in 16 stepsScale-Based Melodies:
lua
local s = scale("c4", "minor")
event = s.notes -- Use scale notes as sequenceRandom Generation with Control:
lua
event = function(context)
local notes = scale("c4", "pentatonic minor").notes
return notes[math.random(#notes)]
endTidal Cycles Mini-Notation:
lua
return cycle("kd ~ sn ~, [hh hh]*4"):map({
kd = "c4 #1", -- Kick drum
sn = "c4 #2", -- Snare
hh = "c4 #3 v0.5" -- Hi-hat, quieter
})Core Workflow
1. Choose Musical Goal
Identify what to create:
- Rhythmic: Drum pattern, breakbeat, groove
- Melodic: Bassline, lead, arpeggio
- Harmonic: Chord progression, pad, texture
- Textural: Atmosphere, drone, evolving soundscape
2. Design Rhythm (Pulse)
Start with rhythmic foundation:
Static Arrays:
lua
pulse = {1, 0, 1, 1, 0, 1, 0, 0} -- Hand-crafted rhythmEuclidean Distribution:
lua
pulse = pulse.euclidean(5, 8) -- Algorithmic rhythmDynamic/Generative:
lua
pulse = function(context)
return math.random() > 0.5 -- Probabilistic rhythm
endSubdivisions (Cramming):
lua
pulse = {1, {1, 1, 1}, 1, 0} -- Quarter + triplet + quarter + rest3. Design Note Generation (Event)
Create melodic/harmonic content:
Static Sequence:
lua
event = {"c4", "e4", "g4", "b4"}Scale-Based:
lua
local s = scale("c4", "minor")
event = function(context)
return s.notes[math.imod(context.step, #s.notes)]
endChord Progressions:
lua
local s = scale("c4", "minor")
event = sequence(
s:chord("i"), -- Tonic
s:chord("iv"), -- Subdominant
s:chord("v") -- Dominant
)Generative/Evolving:
lua
event = function(init_context)
local state = initial_value
return function(context)
-- Update and use state to create evolution
state = state + delta
return generate_from(state)
end
end4. Add Variation (Optional Gate)
Filter or modify pulse triggers:
lua
gate = function(context)
-- Higher probability on downbeats
local is_downbeat = (context.pulse_step - 1) % 4 == 0
local probability = is_downbeat and 0.9 or 0.3
return math.random() < probability
end5. Add Control (Parameters)
Enable live tweaking without code changes:
lua
parameter = {
parameter.integer("variation", 1, {1, 4}),
parameter.number("density", 0.5, {0.0, 1.0}),
}
-- Access in functions
event = function(context)
local var = context.parameter.variation
-- Use var to select different patterns
end6. Iterate & Evolve
Workflow for Emergent Music:
- Generate pattern → Test in Renoise
- Render/bounce to audio
- Resample and chop
- Create new patterns using resampled material
- Layer and arrange into parts
- Repeat process for continuous evolution
Common Musical Tasks
Creating Breakbeats
Load and search for "Breakbeat" for complete examples.
references/genre_recipes.mdQuick pattern:
lua
-- Euclidean-based break
local kick = pulse.euclidean(4, 16)
local snare = pulse.euclidean(3, 16, 2)
local hats = pulse.from{1,0,1,0}:repeat_n(4)
-- Use cycle notation to combine
return cycle("[kd*16], [sn*16], [hh*16]"):map({
kd = function(ctx) return kick[math.imod(ctx.step,16)] and "c4 #1" end,
sn = function(ctx) return snare[math.imod(ctx.step,16)] and "c4 #2" end,
hh = function(ctx) return hats[math.imod(ctx.step,16)] and "c4 #3" end
})Generative Melodies
Load and search for "Constrained Random Walk" or "Scale-Based Generation".
references/core_techniques.mdQuick pattern:
lua
return pattern {
unit = "1/16",
pulse = pulse.euclidean(7, 16), -- Rhythmic interest
event = function(init_context)
local notes = scale("c4", "pentatonic minor").notes
local last_idx = 1
return function(context)
-- Prefer small intervals (smoother melody)
local next_idx = last_idx
while math.abs(next_idx - last_idx) > 2 do
next_idx = math.random(#notes)
end
last_idx = next_idx
return notes[next_idx]
end
end
}Chord Progressions
Load and search for "Chord Progressions".
references/core_techniques.mdQuick pattern:
lua
local s = scale("c4", "minor")
return pattern {
unit = "1/4", -- Whole notes
pulse = {1, 1, 1, 1},
event = sequence(
s:chord("i", 3), -- i minor
s:chord("iv", 3), -- iv minor
s:chord("v", 3), -- v minor
s:chord("i", 3) -- i minor
)
}Evolving Textures
Load and search for "Ambient" or "Textural".
references/genre_recipes.mdQuick pattern:
lua
return pattern {
unit = "1/16",
pulse = function(context)
return math.random() > 0.85 -- Sparse
end,
event = function(context)
local notes = scale("c4", "phrygian").notes
return note(notes[math.random(#notes)])
:volume(0.2 + math.random() * 0.3)
:delay(math.random() * 0.5)
:panning(math.random() * 2 - 1)
end
}Polyrhythms
Load and search for "Polyrhythms".
references/core_techniques.mdQuick pattern:
lua
-- 3:4:5 polyrhythm
cycle("[c4*3]/4, [e4*4]/4, [g4*5]/4")Key Techniques Reference
For detailed explanations and complete code examples, load these reference files:
Core Techniques (references/core_techniques.md
)
references/core_techniques.mdLoad when working with:
- Euclidean rhythms and pulse operations
- Randomization and controlled chaos
- Scale-based generation
- Pattern evolution and stateful generators
- Polyrhythms and unusual time signatures
- Note transformations
- Tidal Cycles mini-notation
- Texture generation
Search patterns:
grep -i "euclidean" references/core_techniques.mdgrep -i "random" references/core_techniques.mdgrep -i "scale" references/core_techniques.md
Genre-Specific Recipes (references/genre_recipes.md
)
references/genre_recipes.mdLoad when creating:
- Breakbeat/Jungle/DnB: Complex breaks, swing, reese bass
- IDM/Experimental: Glitchy effects, algorithmic complexity
- Jazz: Swing, walking bass, chord substitutions
- Industrial/Trip-Hop: Heavy grooves, dark textures
- Ambient: Slow evolution, drones, sparse atmospheres
Search patterns:
grep -i "breakbeat\|jungle\|dnb" references/genre_recipes.mdgrep -i "idm\|experimental\|glitch" references/genre_recipes.mdgrep -i "jazz\|swing\|walking" references/genre_recipes.md
API Quick Reference (references/api_quick_reference.md
)
references/api_quick_reference.mdLoad when needing:
- Function signatures and parameters
- Available scale modes
- Context object properties
- Utility functions
- Common code patterns
- Workflow tips and gotchas
Pattern Templates
The directory contains starter templates for common patterns:
assets/- : Euclidean-based drum pattern
euclidean_drum.lua - : Scale-based melody with constraints
generative_melody.lua - : Slowly evolving chord progression
evolving_chord.lua - : Sparse atmospheric texture
texture_cloud.lua
Copy and modify these as starting points.
Best Practices
Start Simple, Add Complexity
- Begin with static pulse and static event
- Make one dynamic (usually event first)
- Add gate for probability/filtering
- Add parameters for control
- Layer multiple patterns
Controlled Randomness
Use seeded random for reproducibility:
lua
event = function(init_context)
local rand = math.randomstate(12345) -- Consistent seed
return function(context)
return generate_with(rand)
end
endState Management
- Global state: Shared across all triggers (use sparingly)
- Local state (in generators): Per-trigger isolation (preferred)
- Use init function + inner function pattern for local state
Performance Optimization
- Cache expensive calculations in init functions
- Use local variables
- Avoid creating tables in inner loops
- Return for rests, not 0 or false
nil
Tracker Context for Programmers
- Lua uses 1-based indexing: is first element
array[1] - Use for array wrapping
math.imod(step, #array) - Patterns run in musical time (beats/bars), not CPU time
- BPM and time signature from Renoise project settings
Troubleshooting
Pattern not triggering:
- Check is appropriate for tempo
unit - Verify returns non-zero values
pulse - Check (if present) isn't filtering all events
gate
Notes out of key:
- Use to constrain note generation
scale() - Check root note and mode are correct
Pattern too predictable:
- Add randomization with
math.random() - Use euclidean rhythms with different parameters
- Implement constrained random walk for melodies
Pattern too chaotic:
- Use seeded random for consistency
- Add constraints to random generation
- Use scale-based generation for harmonic coherence
- Lower probability in gates
Lua errors:
- Check 1-based indexing
- Verify init function returns inner function for generators
- Use for array wrapping, not
math.imod%
Generative Workflow Summary
The power of Pattrns for emergent music:
IDEA → ALGORITHM → PATTERN → EVENTS → AUDIO → RESAMPLE → NEW PATTERN- Generate: Create algorithmic patterns with controlled randomness
- Evolve: Use stateful generators to create evolving material
- Render: Bounce patterns to audio in Renoise
- Resample: Chop and manipulate rendered audio
- Resequence: Create new patterns using resampled material
- Iterate: Repeat for continuous evolution and emergence
This workflow enables creating "parts" that can be assembled into songs in Renoise or exported to traditional DAWs, with each iteration adding new layers of complexity and emergence.
Resources
references/
Detailed technical documentation and genre-specific recipes. Load as needed:
- : In-depth technique explanations and code patterns
core_techniques.md - : Complete examples for different musical styles
genre_recipes.md - : Function signatures and API reference
api_quick_reference.md
assets/
Pattern templates ready to copy and modify:
- Starter templates for common musical tasks
- Genre-specific boilerplate patterns