synchronize
Align lines, loops, and vibes to a master rhythm with an optional phase offset for cohesive creative flow.
Instructions
Synchronize lines, loops, and vibes
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elements | Yes | Elements to synchronize (names of lines/loops/vibes) | |
| master_rhythm | No | Master rhythm to sync to | |
| phase_offset | No | Phase offset in degrees |
Implementation Reference
- index.js:221-245 (registration)Tool 'synchronize' is registered in the ListToolsRequestSchema with its schema: name, description, inputSchema containing 'elements' (required array of strings), 'master_rhythm' (optional string), and 'phase_offset' (optional number 0-360).
{ name: 'synchronize', description: 'Synchronize lines, loops, and vibes', inputSchema: { type: 'object', properties: { elements: { type: 'array', items: { type: 'string' }, description: 'Elements to synchronize (names of lines/loops/vibes)', }, master_rhythm: { type: 'string', description: 'Master rhythm to sync to', }, phase_offset: { type: 'number', minimum: 0, maximum: 360, description: 'Phase offset in degrees', }, }, required: ['elements'], }, }, - index.js:683-744 (handler)The synchronize(args) method is the handler for the 'synchronize' tool. It validates 'elements' input, looks up each element in lines/loops/vibes maps, builds sync results, and returns a formatted text response with a visual sync pattern.
synchronize(args) { const { elements, master_rhythm = null, phase_offset = 0 } = args; if (!elements || elements.length === 0) { return { content: [ { type: 'text', text: `ā No elements provided for synchronization. Please specify at least one line, loop, or vibe to synchronize.`, }, ], }; } const syncData = { elements, master_rhythm, phase_offset, timestamp: new Date().toISOString(), }; const syncResults = elements.map(element => { const hasLine = this.lines.has(element); const hasLoop = this.loops.has(element); const hasVibe = this.vibes.has(element); return { element, type: hasLine ? 'line' : hasLoop ? 'loop' : hasVibe ? 'vibe' : 'unknown', synced: hasLine || hasLoop || hasVibe, }; }); const validElements = syncResults.filter(r => r.synced); const invalidElements = syncResults.filter(r => !r.synced); if (validElements.length === 0) { return { content: [ { type: 'text', text: `ā No valid elements found for synchronization.\n\nMissing elements: ${invalidElements.map(r => r.element).join(', ')}\n\nPlease create these elements first using create_line, create_loop, or create_vibe.`, }, ], }; } let resultText = `š Synchronizing ${validElements.length} elements\n\nMaster Rhythm: ${master_rhythm || 'Auto-detected'}\nPhase Offset: ${phase_offset}°\n\n${syncResults.map(r => `${r.synced ? 'ā ' : 'ā'} ${r.element} (${r.type})`).join('\n')}\n\n${this.visualizeSyncPattern(validElements.length, phase_offset)}`; if (invalidElements.length > 0) { resultText += `\n\nā ļø Warning: ${invalidElements.length} elements not found: ${invalidElements.map(r => r.element).join(', ')}`; } return { content: [ { type: 'text', text: resultText, }, ], }; } - index.js:345-346 (registration)The CallToolRequestSchema routes the 'synchronize' case to this.synchronize(args).
case 'synchronize': return this.synchronize(args); - index.js:1006-1015 (helper)The visualizeSyncPattern helper generates a visual representation of synchronized elements based on count and phase offset.
visualizeSyncPattern(count, offset) { const base = 'āÆ'; const synced = 'ā'; const pattern = []; for (let i = 0; i < count; i++) { const phase = (i * 360 / count + offset) % 360; pattern.push(phase < 180 ? synced : base); } return pattern.join(' ā '); }