generate_drums
Create custom drum patterns for Strudel.cc by specifying style and complexity levels. Facilitates music generation and live coding within the Strudel MCP Server environment.
Instructions
Generate drum pattern
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| complexity | No | Complexity (0-1) | |
| style | Yes | Drum style |
Implementation Reference
- src/services/PatternGenerator.ts:6-54 (handler)Core handler function that implements the generate_drums tool logic. Selects a pre-defined drum pattern string based on the provided style and complexity level.generateDrumPattern(style: string, complexity: number = 1): string { const patterns: Record<string, string[]> = { techno: [ 's("bd*4")', 's("bd*4, ~ cp ~ cp")', 's("bd*4, ~ cp ~ cp, hh*8")', 's("bd*4, ~ cp ~ cp, [~ hh]*4, oh ~ ~ ~").swing(0.05)' ], house: [ 's("bd*4, hh*8")', 's("bd*4, hh*8, ~ cp ~ cp")', 's("bd*4, [~ hh]*4, ~ cp ~ cp, oh ~ oh ~")', 's("bd*4, [~ hh]*4, ~ cp ~ cp").every(4, x => x.fast(2))' ], dnb: [ 's("bd ~ ~ bd ~ ~ bd ~, ~ ~ cp ~ ~ cp ~ ~")', 's("bd ~ ~ [bd bd] ~ ~ bd ~, ~ ~ cp ~ ~ cp ~ ~, hh*16")', 's("bd ~ ~ [bd bd] ~ ~ bd ~, ~ ~ cp ~ [~ cp] ~ cp ~ ~, hh*16").fast(2)' ], breakbeat: [ 's("bd ~ ~ bd ~ ~ ~ bd, ~ cp ~ ~ cp ~")', 's("bd ~ ~ bd ~ [~ bd] ~ bd, ~ cp ~ ~ cp ~, hh*8")', 's("bd ~ [~ bd] bd ~ [~ bd] ~ bd, ~ cp ~ ~ cp [~ cp], hh*8").swing(0.1)' ], trap: [ 's("bd*2, ~ cp ~ cp")', 's("bd*2, ~ cp ~ cp, hh*8").every(2, x => x.fast(2))', 's("bd [bd bd] ~ bd, ~ cp ~ cp, hh*16").swing(0.2)' ], jungle: [ 's("bd ~ [~ bd] bd ~ ~ bd ~, ~ cp ~ ~ cp ~").fast(2)', 's("bd ~ [~ bd] bd ~ [bd bd] bd ~, ~ cp ~ [~ cp] cp ~, hh*32").fast(2)' ], ambient: [ 's("bd ~ ~ ~")', 's("bd ~ ~ ~, ~ ~ ~ hh:8").room(0.9)', 's("bd ~ ~ ~, ~ ~ ~ hh:8, ~ ~ oh:5 ~").room(0.9).gain(0.5)' ], experimental: [ 's("bd").euclid(5, 8)', 's("bd cp").euclid(7, 16)', 's("bd cp hh").euclid(choose([3, 5, 7]), 16)' ] }; const stylePatterns = patterns[style] || patterns.techno; const index = Math.min(Math.floor(complexity * stylePatterns.length), stylePatterns.length - 1); return stylePatterns[index]; }
- MCP server handler case that dispatches generate_drums tool call to PatternGenerator and appends the generated pattern to the current editor content.case 'generate_drums': const drums = this.generator.generateDrumPattern(args.style, args.complexity || 0.5); const currentDrum = await this.getCurrentPatternSafe(); const newDrumPattern = currentDrum ? currentDrum + '\n' + drums : drums; await this.writePatternSafe(newDrumPattern); return `Generated ${args.style} drums`;
- src/server/EnhancedMCPServerFixed.ts:207-218 (registration)Tool registration in getTools(): defines name, description, and input schema for generate_drums.{ name: 'generate_drums', description: 'Generate drum pattern', inputSchema: { type: 'object', properties: { style: { type: 'string', description: 'Drum style' }, complexity: { type: 'number', description: 'Complexity (0-1)' } }, required: ['style'] } },
- Input schema definition for generate_drums tool validating style (required string) and optional complexity (number 0-1).inputSchema: { type: 'object', properties: { style: { type: 'string', description: 'Drum style' }, complexity: { type: 'number', description: 'Complexity (0-1)' } }, required: ['style'] } },
- src/server/EnhancedMCPServer.ts:525-529 (handler)Alternative MCP server handler (non-fixed version) for generate_drums tool.case 'generate_drums': const drums = this.generator.generateDrumPattern(args.style, args.complexity || 0.5); const currentDrum = await this.controller.getCurrentPattern(); await this.controller.writePattern(currentDrum + '\n' + drums); return `Added ${args.style} drums`;