Skip to main content
Glama

analyze_dynamics

Analyze the dynamic range of a rendered REAPER project by measuring RMS, peak levels, crest factor, and calculating a simplified DR score from 3-second blocks.

Instructions

Render the project and measure dynamic range: RMS, peak, crest factor, and a simplified DR score (average peak-to-RMS over 3-second blocks).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'analyze_dynamics' tool. Renders the project to a temp WAV file, loads it, computes RMS, peak, crest factor, and a simplified DR score over 3-second blocks, and returns the results as a dict.
    @mcp.tool()
    def analyze_dynamics() -> dict:
        """
        Render the project and measure dynamic range: RMS, peak, crest factor,
        and a simplified DR score (average peak-to-RMS over 3-second blocks).
        """
        try:
            import soundfile as sf
            from reaper_mcp.render_tools import render_to_temp_file
    
            tmp = render_to_temp_file()
            try:
                data, rate = sf.read(tmp)
            finally:
                if os.path.exists(tmp):
                    os.unlink(tmp)
    
            mono = np.mean(data, axis=1) if data.ndim > 1 else data
            rms = float(np.sqrt(np.mean(mono ** 2)))
            peak = float(np.max(np.abs(mono)))
            rms_db = float(20 * np.log10(rms)) if rms > 0 else -120.0
            peak_db = float(20 * np.log10(peak)) if peak > 0 else -120.0
            crest_db = peak_db - rms_db
    
            # Simplified DR score: average crest factor over 3-second blocks
            block_size = rate * 3
            n_blocks = len(mono) // block_size
            dr_scores = []
            for i in range(n_blocks):
                block = mono[i * block_size:(i + 1) * block_size]
                blk_peak = np.max(np.abs(block))
                blk_rms = np.sqrt(np.mean(block ** 2))
                if blk_rms > 0:
                    dr_scores.append(float(20 * np.log10(blk_peak / blk_rms)))
            dr = float(np.mean(dr_scores)) if dr_scores else 0.0
    
            return {
                "success": True,
                "rms_db": round(rms_db, 1),
                "peak_db": round(peak_db, 1),
                "crest_factor_db": round(crest_db, 1),
                "dr_score": round(dr, 1),
            }
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Registration: the analysis_tools module's register_tools function is imported as _reg_analysis and called with the mcp instance on line 28. This triggers the @mcp.tool() decorator that registers analyze_dynamics.
    from reaper_mcp.analysis_tools import register_tools as _reg_analysis
    
    _reg_project(mcp)
    _reg_track(mcp)
    _reg_midi(mcp)
    _reg_fx(mcp)
    _reg_audio(mcp)
    _reg_mixing(mcp)
    _reg_render(mcp)
    _reg_mastering(mcp)
    _reg_analysis(mcp)
  • The register_tools function that defines all analysis tools, including analyze_dynamics, using the @mcp.tool() decorator pattern.
    def register_tools(mcp):
  • The render_to_temp_file helper used by analyze_dynamics to render the REAPER project to a temporary WAV file for analysis.
    def render_to_temp_file(sample_rate: int = 48000) -> str:
        """
        Render the current project to a temporary WAV file and return its path.
        Used by analysis and mastering tools. Caller is responsible for deleting the file.
        """
        import tempfile
        tmp = tempfile.mktemp(suffix=".wav")
        _set_render_settings(tmp, "wav", sample_rate, 24, 2, bounds=0)
        RPR.Main_OnCommand(41824, 0)
        return tmp
Behavior2/5

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

The description mentions 'Render the project' without clarifying whether this is a destructive action (e.g., overwriting files) or if it has side effects. With no annotations provided, the description fails to disclose behavioral traits like output type or project state changes.

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 conveys all necessary information without redundancy. Every part earns its place.

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

Completeness3/5

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

While the description outlines the measurements, it omits details about return values (e.g., numeric results or visual output) and potential side effects of rendering. Given zero parameters and no output schema, the description partially satisfies completeness but leaves gaps.

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

Parameters4/5

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

The tool has no parameters, and the description adds no parameter details. With schema coverage at 100% (empty schema), a baseline of 4 is appropriate since no additional explanation is needed.

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

Purpose5/5

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

The description clearly states the verb 'Render the project and measure dynamic range' and enumerates specific metrics (RMS, peak, crest factor, DR score), making the tool's purpose unambiguous. It distinguishes from siblings like analyze_loudness by focusing on dynamics.

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

Usage Guidelines3/5

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

The description implies use for dynamic range measurement but provides no explicit guidance on when to use this tool versus alternatives such as analyze_loudness or detect_clipping. No exclusions or prerequisites are mentioned.

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/bonfire-audio/reaper-mcp'

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