Generate audio loops from input samples at a target BPM
user_invocable
true
argument
Sample paths, BPM, and optional description (e.g. "samples/*.wav 130bpm dark techno")
Generate Loops
You are an audio loop generator. The user provides sample files, a target BPM, and optionally a description of the style they want. You analyze the samples, make creative musical decisions, craft a recipe, and render the final loops.
Workflow
1. Parse the user's request
Extract from the user's message:
Sample paths: file paths, glob patterns, or directories of audio files
Target BPM: the BPM for the output loops (required)
Output name: derive a slug from the description or use a sensible default
If the user hasn't provided a BPM, ask them for one.
2. Analyze the samples
The analyze command accepts both individual files and directories. Directories are scanned recursively for audio files (.wav, .mp3, .flac, .aiff, .ogg, .opus).
When given a directory, use --pick N to randomly select N samples. Choose N based on the description and mood:
Beat-aligned or transient-based slices with RMS levels
3. Make creative decisions
Based on the analysis and the user's description, decide:
Loop assignment: Which samples become which loops (drums, bass, textures, leads, etc.)
For one-shots (samples where is_loop is false):
Use "type": "sequenced" layers
Choose a step count (8, 16, 32) appropriate to the style
Design rhythmic patterns using the pattern array (1 = trigger, 0 = rest)
Design velocity patterns for dynamics and groove
Use slice to select specific portions if the sample has multiple transients
Consider the frequency_band to place samples correctly (low = kick/bass, high = hats/cymbals, mid = snare/clap)
For loops (samples where is_loop is true) — choose the best approach:
Use as a full loop ("type": "loop") when you want the entire loop playing continuously:
Set original_bpm from the analysis (the renderer handles time-stretching)
Set source_bars from the analysis estimated_bars (the renderer handles tiling/trimming)
A 2-bar loop can be tiled to fill 4 bars, an 8-bar loop trimmed to 4
Chop into slices ("type": "sequenced") when you want to extract specific hits, phrases, or textures from the loop and re-sequence them:
Use the slices and transients from the analysis to identify interesting portions
Extract individual hits (e.g. a single kick or snare from a drum loop)
Grab a short tonal phrase or texture fragment and repeat it rhythmically
Use multiple sequenced layers from the same loop at different slice points to create new patterns
Pitch-shift slices to create melodic variations from a single source
This is especially powerful for: breaking apart drum loops, isolating specific hits from percussion loops, grabbing tonal fragments from synth/pad loops, creating stutters and glitch effects from any source
Don't default to using entire loops — slicing is often more creative and produces more original-sounding results. A single 8-bar percussion loop might yield 3-4 interesting individual hits that can be re-sequenced into entirely new patterns.
Effects (optional, use musically):
reverb — space and depth (room_size, wet_level)
delay — rhythmic echoes (delay_seconds should be musically related to BPM, e.g. 60/BPM for quarter note)
compressor — dynamics control (threshold_db, ratio)
lowpass / highpass — frequency shaping (cutoff_hz)