Skip to main content
Glama

analyze

Analyzes audio to extract musical patterns and structures for use in TidalCycles/Strudel music generation and live coding.

Instructions

Complete audio analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the 'analyze' MCP tool in the tools list returned by getTools(), including name, description, and input schema (no parameters).
    name: 'analyze', description: 'Complete audio analysis', inputSchema: { type: 'object', properties: {} } },
  • Primary MCP tool handler for 'analyze'. Validates initialization and delegates to StrudelController.analyzeAudio() which performs the actual analysis.
    case 'analyze': if (!this.isInitialized) { return 'Browser not initialized. Run init first.'; } return await this.controller.analyzeAudio();
  • Intermediate handler in StrudelController that forwards the analysis request to the AudioAnalyzer instance.
    async analyzeAudio(): Promise<AudioAnalysisResult> { if (!this._page) throw new Error('Browser not initialized. Run init tool first.'); return await this.analyzer.getAnalysis(this._page); }
  • Core analysis handler. Uses page.evaluate to call the injected JavaScript analyzer in the browser, which computes FFT-based features like average, peak, frequency bands, etc. Includes caching.
    async getAnalysis(page: Page): Promise<AudioAnalysisResult> { // Client-side caching with local fallback const now = Date.now(); if (this._analysisCache && (now - this._cacheTimestamp) < this.ANALYSIS_CACHE_TTL) { return this._analysisCache; } const result = await page.evaluate(() => { const analyzer = (window as any).strudelAudioAnalyzer; if (!analyzer) { return { connected: false, error: 'Analyzer not initialized. Audio context may not have started yet.', hint: 'Try playing a pattern first to initialize the audio context.' }; } if (!analyzer.isConnected) { return { connected: false, error: 'Analyzer not connected to audio output.', hint: 'Play a pattern to connect the analyzer to Strudel audio output.' }; } const analysis = analyzer.analyze(); // Add diagnostic info if no audio detected if (analysis.features && analysis.features.isSilent) { analysis.hint = 'Audio analyzer connected but no audio detected. Ensure pattern is playing.'; } return analysis; }); // Update cache this._analysisCache = result; this._cacheTimestamp = now; return result; }
  • TypeScript interfaces defining the input/output structure for audio analysis results, used throughout the implementation chain.
    export interface AudioAnalysisResult { connected: boolean; timestamp?: number; features?: AudioAnalysisFeatures; error?: string; }

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