Skip to main content
Glama
DeveloperZo

MCP Audio Tweaker

by DeveloperZo

layer_sounds

Combine multiple audio files with precise control over blending, timing, pitch, and volume to create layered sound effects or music compositions.

Instructions

Layer multiple sounds together with advanced blending and timing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputFilesYesArray of input file paths to layer
outputFileYesPath for output file
layersYesLayer configuration for each input
overwriteNoWhether to overwrite existing output files

Implementation Reference

  • Core handler function implementing the layer_sounds tool logic using FFmpeg to layer multiple audio files with blending, timing, pitch, volume, and pan controls.
    async layerSounds(
      inputFiles: string[],
      outputFile: string,
      layering: LayeringOperation,
      overwrite: boolean = false
    ): Promise<ProcessingResult> {
      const startTime = Date.now();
      
      try {
        if (inputFiles.length === 0) {
          throw new FFmpegError('No input files provided for layering');
        }
        
        // Validate all input files
        for (const file of inputFiles) {
          await validateInputFile(file);
        }
        
        await ensureOutputDirectory(outputFile);
        await handleExistingOutput(outputFile, overwrite);
        
        const command = ffmpeg();
        
        // Add all input files
        inputFiles.forEach(file => command.input(file));
        
        // Build complex filter for layering
        const filterGraph = this.buildLayeringFilter(inputFiles, layering);
        command.complexFilter(filterGraph);
        
        // Execute command
        await executeFFmpegCommand(command, outputFile);
        
        return {
          success: true,
          inputFile: inputFiles.join(', '),
          outputFile,
          processingTime: Date.now() - startTime,
          operations: { advanced: { layering } }
        };
        
      } catch (error) {
        return {
          success: false,
          inputFile: inputFiles.join(', '),
          outputFile,
          processingTime: Date.now() - startTime,
          operations: { advanced: { layering } },
          error: error instanceof Error ? error.message : 'Unknown error'
        };
      }
    }
  • Tool metadata and input schema definition for validating parameters of the layer_sounds tool.
    export const layerSoundsTool: Tool = {
      name: 'layer_sounds',
      description: 'Layer multiple sounds together with advanced blending and timing',
      inputSchema: {
        type: 'object',
        properties: {
          inputFiles: {
            type: 'array',
            description: 'Array of input file paths to layer',
            items: { type: 'string' },
            minItems: 1,
            maxItems: 8
          },
          outputFile: {
            type: 'string',
            description: 'Path for output file'
          },
          layers: {
            type: 'array',
            description: 'Layer configuration for each input',
            items: {
              type: 'object',
              properties: {
                blend: { type: 'string', enum: ['mix', 'multiply', 'add', 'subtract'] },
                delay: { type: 'number', minimum: 0, maximum: 5000 },
                pitch: { type: 'number', minimum: -12, maximum: 12 },
                volume: { type: 'number', minimum: 0, maximum: 2 },
                pan: { type: 'number', minimum: -1, maximum: 1 }
              },
              required: ['blend']
            }
          },
          overwrite: {
            type: 'boolean',
            description: 'Whether to overwrite existing output files',
            default: false
          }
        },
        required: ['inputFiles', 'outputFile', 'layers']
      }
    };
  • Registration and dispatch logic within the unified tool handler that routes layer_sounds calls to the AdvancedAudioProcessor.
    case 'layer_sounds': {
      const input = args as any;
      const layering = {
        layers: input.layers
      };
      
      const result = await advancedProcessor.layerSounds(
        input.inputFiles,
        input.outputFile,
        layering,
        input.overwrite || false
      );
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Supporting utility that generates the complex FFmpeg filter graph string for multi-layer audio blending with per-layer effects.
    private buildLayeringFilter(inputFiles: string[], layering: LayeringOperation): string {
      const layers = layering.layers;
      
      let filterGraph = '';
      
      // Apply individual layer processing
      layers.forEach((layer, i) => {
        if (i < inputFiles.length) {
          let layerFilter = `[${i}:a]`;
          
          // Apply layer-specific effects
          if (layer.delay) {
            layerFilter += `adelay=${layer.delay}[delayed${i}];[delayed${i}]`;
          }
          
          if (layer.pitch) {
            const ratio = Math.pow(2, layer.pitch / 12);
            layerFilter += `asetrate=44100*${ratio},aresample=44100[pitched${i}];[pitched${i}]`;
          }
          
          if (layer.volume !== undefined) {
            layerFilter += `volume=${layer.volume}[vol${i}];[vol${i}]`;
          }
          
          if (layer.pan !== undefined) {
            layerFilter += `pan=stereo|c0=${1 - Math.abs(Math.min(0, layer.pan))}*c0+${Math.max(0, -layer.pan)}*c1|c1=${1 - Math.abs(Math.max(0, layer.pan))}*c1+${Math.max(0, layer.pan)}*c0[pan${i}];[pan${i}]`;
          }
          
          filterGraph += layerFilter + `[processed${i}];`;
        }
      });
      
      // Mix all layers together
      const mixInputs = layers.map((_, i) => `[processed${i}]`).join('');
      filterGraph += `${mixInputs}amix=inputs=${layers.length}:duration=longest:dropout_transition=2[final]`;
      
      return filterGraph;
    }
  • The tools export array includes layerSoundsTool for server registration.
    export const tools = [
      processAudioFileTool,
      batchProcessAudioTool,
      applyPresetTool,
      listPresetsTool,
      getQueueStatusTool,
      generateVariationsTool,
      createHarmonicsTool,
      advancedProcessTool,
      layerSoundsTool
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'advanced blending and timing' but fails to detail critical aspects like file format requirements, performance constraints, error handling, or output characteristics. For a tool with 4 parameters and file operations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality ('Layer multiple sounds together') and adds key details ('with advanced blending and timing') without unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, file operations, no annotations, and no output schema), the description is insufficient. It lacks details on output format, error conditions, or integration with sibling tools, leaving gaps that could hinder effective agent usage in a multi-tool audio processing context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional meaning beyond the schema, such as explaining how 'blend' modes interact or the practical effects of 'delay' and 'pitch.' This meets the baseline for high schema coverage but doesn't enhance understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Layer multiple sounds together with advanced blending and timing,' which specifies the verb ('layer') and resource ('sounds') with additional context about capabilities. However, it doesn't explicitly differentiate from sibling tools like 'batch_process_audio' or 'process_audio_file,' which may have overlapping audio processing functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It lacks context about specific scenarios, prerequisites, or comparisons to sibling tools such as 'apply_preset' or 'generate_variations,' leaving the agent without clear usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/DeveloperZo/mcp-audio-tweaker'

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