Skip to main content
Glama

sc_play_synth_advanced

Generate synthesized audio using customizable parameters for sine, pluck, bell, bass, pad, kick, snare, hihat, atmosphere, and sweep sounds. Control frequency, amplitude, duration, pan position, decay, and filter settings to create specific audio outputs.

Instructions

Play a specific synth with explicit parameters. Available synths: sine, pluck, bell, bass, pad, kick, snare, hihat, atmosphere, sweep

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ampNoAmplitude 0-1 (default: 0.3)
cutoffNoFilter cutoff frequency for bass/pad (default: varies)
decayNoDecay time for pluck synth (default: 2)
durationNoDuration in seconds (default: 1)
endFreqNoEnd frequency for sweep (default: 2000)
freqNoFrequency in Hz (default: 440)
panNoPan position -1 (left) to 1 (right) (default: 0)
startFreqNoStart frequency for sweep (default: 100)
synthNameYesName of the synth to play

Implementation Reference

  • Handler for sc_play_synth_advanced: validates input parameters using Zod, checks if SuperCollider server is booted, constructs dynamic Synth SuperCollider code with provided synthName and parameters, executes it via scServer.executeCode, and returns confirmation.
    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 object for sc_play_synth_advanced, including full input schema with parameter definitions and enum for synthName matching available SynthDefs.
    { 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'], }, },
  • Detailed input schema for sc_play_synth_advanced tool defining all parameters, types, descriptions, defaults implied, and required synthName with exact enum of supported synths.
    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'],
  • Helper function to generate initialization code that concatenates all SynthDef definitions for the synths used in sc_play_synth_advanced (must be executed via sc_execute after boot).
    export function getSynthDefInitCode(): string { return Object.values(SYNTH_DEFS).join('\n\n'); }
  • Collection of SuperCollider SynthDef source code strings for all synths supported by sc_play_synth_advanced (sine, pluck, etc.), defining the actual sound generation logic with parameters matching the tool schema.
    export const SYNTH_DEFS = { // Simple sine wave tone sine: ` SynthDef(\\sine, { |freq=440, amp=0.3, pan=0, gate=1| var sig = SinOsc.ar(freq, 0, amp); var env = EnvGen.kr(Env.asr(0.01, 1, 0.1), gate, doneAction: 2); Out.ar(0, Pan2.ar(sig * env, pan)); }).add; `, // Plucked string sound pluck: ` SynthDef(\\pluck, { |freq=440, amp=0.3, pan=0, decay=2| var sig = Pluck.ar( WhiteNoise.ar(amp), Impulse.kr(0), freq.reciprocal, freq.reciprocal, decay, coef: 0.1 ); var env = EnvGen.kr(Env.linen(0, decay, 0), doneAction: 2); Out.ar(0, Pan2.ar(sig * env, pan)); }).add; `, // Bell-like FM tone bell: ` SynthDef(\\bell, { |freq=440, amp=0.3, pan=0, duration=2| var modulator = SinOsc.ar(freq * 2.4, 0, freq * 0.8); var carrier = SinOsc.ar(freq + modulator, 0, amp); var env = EnvGen.kr(Env.perc(0.01, duration, 1, -4), doneAction: 2); Out.ar(0, Pan2.ar(carrier * env, pan)); }).add; `, // Bass tone bass: ` SynthDef(\\bass, { |freq=110, amp=0.4, pan=0, duration=1, cutoff=1000| var sig = LPF.ar(Saw.ar(freq), cutoff); var env = EnvGen.kr(Env.perc(0.01, duration), doneAction: 2); Out.ar(0, Pan2.ar(sig * env * amp, pan)); }).add; `, // Pad sound pad: ` SynthDef(\\pad, { |freq=220, amp=0.2, pan=0, gate=1, cutoff=2000| var sig = RLPF.ar( Saw.ar([freq, freq * 1.01], amp), cutoff, 0.5 ); var env = EnvGen.kr(Env.asr(0.5, 1, 2), gate, doneAction: 2); Out.ar(0, Pan2.ar(Mix(sig) * env, pan)); }).add; `, // Kick drum kick: ` SynthDef(\\kick, { |amp=0.5, pan=0| var freqEnv = EnvGen.kr(Env.perc(0.001, 0.3), 1, 60, 50); var sig = SinOsc.ar(freqEnv, 0, amp); var env = EnvGen.kr(Env.perc(0.001, 0.5), doneAction: 2); Out.ar(0, Pan2.ar(sig * env, pan)); }).add; `, // Snare drum snare: ` SynthDef(\\snare, { |amp=0.3, pan=0| var sig = WhiteNoise.ar(amp) + SinOsc.ar(180, 0, amp); var env = EnvGen.kr(Env.perc(0.001, 0.2), doneAction: 2); Out.ar(0, Pan2.ar(sig * env, pan)); }).add; `, // Hi-hat hihat: ` SynthDef(\\hihat, { |amp=0.2, pan=0| var sig = HPF.ar(WhiteNoise.ar(amp), 8000); var env = EnvGen.kr(Env.perc(0.001, 0.1), doneAction: 2); Out.ar(0, Pan2.ar(sig * env, pan)); }).add; `, // Atmospheric noise atmosphere: ` SynthDef(\\atmosphere, { |amp=0.15, pan=0, gate=1, cutoff=3000| var sig = RHPF.ar( PinkNoise.ar(amp), LFNoise1.kr(0.5).range(cutoff * 0.5, cutoff), 0.2 ); var env = EnvGen.kr(Env.asr(2, 1, 3), gate, doneAction: 2); Out.ar(0, Pan2.ar(sig * env, pan)); }).add; `, // Sweep/riser sweep: ` SynthDef(\\sweep, { |startFreq=100, endFreq=2000, amp=0.3, pan=0, duration=2| var freq = Line.kr(startFreq, endFreq, duration); var sig = Saw.ar(freq, amp); var env = EnvGen.kr(Env.linen(0.1, duration - 0.2, 0.1), doneAction: 2); Out.ar(0, Pan2.ar(sig * env, pan)); }).add; `, };

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/BradA1878/mcp-wave'

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