sc_play_synth_advanced
Generate audio synthesis by playing specific synth types with customizable parameters including frequency, amplitude, duration, pan, and filter controls.
Instructions
Play a specific synth with explicit parameters. Available synths: sine, pluck, bell, bass, pad, kick, snare, hihat, atmosphere, sweep
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| synthName | Yes | Name of the synth to play | |
| freq | No | Frequency in Hz (default: 440) | |
| amp | No | Amplitude 0-1 (default: 0.3) | |
| duration | No | Duration in seconds (default: 1) | |
| pan | No | Pan position -1 (left) to 1 (right) (default: 0) | |
| decay | No | Decay time for pluck synth (default: 2) | |
| cutoff | No | Filter cutoff frequency for bass/pad (default: varies) | |
| startFreq | No | Start frequency for sweep (default: 100) | |
| endFreq | No | End frequency for sweep (default: 2000) |
Implementation Reference
- src/index.ts:351-389 (handler)Handler function for 'sc_play_synth_advanced': parses Zod schema, checks server booted and synthDefs loaded, builds SuperCollider Synth command string with provided parameters, executes it via scServer.executeCode, returns status message.case 'sc_play_synth_advanced': { const schema = z.object({ synthName: z.string(), freq: z.number().optional(), amp: z.number().optional(), duration: z.number().optional(), pan: z.number().optional(), decay: z.number().optional(), cutoff: z.number().optional(), startFreq: z.number().optional(), endFreq: z.number().optional(), }); const params = schema.parse(args); if (!scServer.getBooted() || !synthDefsLoaded) { return { content: [{ type: 'text', text: 'Error: SuperCollider server is not running. Call sc_boot first.' }], isError: true, }; } const { synthName, ...synthParams } = params; const paramStr = Object.entries(synthParams) .filter(([_, value]) => value !== undefined) .map(([key, value]) => `\\${key}, ${value}`) .join(', '); const code = `Synth(\\${synthName}, [${paramStr}]);`; await scServer.executeCode(code); return { content: [ { type: 'text', text: `Playing ${synthName} synth with parameters: ${JSON.stringify(synthParams)}`, }, ], }; }
- src/index.ts:96-142 (registration)Tool registration in the tools array, defining name, description, and input schema (JSON Schema) for parameter validation with synthName required and enum of available synths, optional params for freq, amp, etc.{ name: 'sc_play_synth_advanced', description: 'Play a specific synth with explicit parameters. Available synths: sine, pluck, bell, bass, pad, kick, snare, hihat, atmosphere, sweep', inputSchema: { type: 'object', properties: { synthName: { type: 'string', description: 'Name of the synth to play', enum: ['sine', 'pluck', 'bell', 'bass', 'pad', 'kick', 'snare', 'hihat', 'atmosphere', 'sweep'], }, freq: { type: 'number', description: 'Frequency in Hz (default: 440)', }, amp: { type: 'number', description: 'Amplitude 0-1 (default: 0.3)', }, duration: { type: 'number', description: 'Duration in seconds (default: 1)', }, pan: { type: 'number', description: 'Pan position -1 (left) to 1 (right) (default: 0)', }, decay: { type: 'number', description: 'Decay time for pluck synth (default: 2)', }, cutoff: { type: 'number', description: 'Filter cutoff frequency for bass/pad (default: varies)', }, startFreq: { type: 'number', description: 'Start frequency for sweep (default: 100)', }, endFreq: { type: 'number', description: 'End frequency for sweep (default: 2000)', }, }, required: ['synthName'], }, },
- src/index.ts:352-362 (schema)Zod schema used in handler for runtime validation of input arguments.const schema = z.object({ synthName: z.string(), freq: z.number().optional(), amp: z.number().optional(), duration: z.number().optional(), pan: z.number().optional(), decay: z.number().optional(), cutoff: z.number().optional(), startFreq: z.number().optional(), endFreq: z.number().optional(), });