Skip to main content
Glama

generate_polyrhythm

Create complex polyrhythms by combining multiple sound patterns with different rhythmic cycles for experimental music composition.

Instructions

Generate polyrhythm

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
soundsYesSounds to use
patternsYesPattern numbers

Implementation Reference

  • Core handler function that implements generate_polyrhythm by stacking individual Euclidean rhythms (using Strudel's .euclid) for each provided sound and pattern length over 16 steps.
    generatePolyrhythm(sounds: string[], patterns: number[]): string { if (sounds.length !== patterns.length) { throw new Error('Number of sounds must match number of patterns'); } const rhythms = sounds.map((sound, i) => { return `s("${sound}").euclid(${patterns[i]}, 16)`; }); return `stack(\n ${rhythms.join(',\n ')}\n)`; }
  • MCP tool registration in getTools(), including name, description, and input schema defining sounds (array of strings) and patterns (array of numbers).
    name: 'generate_polyrhythm', description: 'Generate polyrhythm', inputSchema: { type: 'object', properties: { sounds: { type: 'array', items: { type: 'string' }, description: 'Sounds to use' }, patterns: { type: 'array', items: { type: 'number' }, description: 'Pattern numbers' } }, required: ['sounds', 'patterns'] } },
  • Input schema for validating tool arguments: arrays of sounds and patterns.
    inputSchema: { type: 'object', properties: { sounds: { type: 'array', items: { type: 'string' }, description: 'Sounds to use' }, patterns: { type: 'array', items: { type: 'number' }, description: 'Pattern numbers' } }, required: ['sounds', 'patterns'] }
  • Server-side dispatch handler: validates inputs, calls PatternGenerator.generatePolyrhythm, appends to current pattern, writes to editor, and returns confirmation.
    case 'generate_polyrhythm': args.sounds.forEach((sound: string) => { InputValidator.validateStringLength(sound, 'sound', 100, false); }); args.patterns.forEach((pattern: number) => { InputValidator.validatePositiveInteger(pattern, 'pattern'); }); const poly = this.generator.generatePolyrhythm(args.sounds, args.patterns); const currentPoly = await this.getCurrentPatternSafe(); const newPolyPattern = currentPoly ? currentPoly + '\n' + poly : poly; await this.writePatternSafe(newPolyPattern); return `Generated polyrhythm`;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/williamzujkowski/strudel-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server