Skip to main content
Glama

analyze_loudness

Render a REAPER project to a temporary file and measure integrated loudness in LUFS and true peak in dBTP per the ITU-R BS.1770 standard for loudness analysis.

Instructions

Render the project to a temp file and measure integrated loudness (LUFS) and true peak (dBTP) using the ITU-R BS.1770 standard.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'analyze_loudness' tool. It renders the project to a temp WAV file, measures integrated loudness (LUFS) using pyloudnorm and true peak (dBTP) using numpy, then returns the results.
    @mcp.tool()
    def analyze_loudness() -> dict:
        """
        Render the project to a temp file and measure integrated loudness (LUFS)
        and true peak (dBTP) using the ITU-R BS.1770 standard.
        """
        try:
            import soundfile as sf
            import pyloudnorm as pyln
            import numpy as np
            from reaper_mcp.render_tools import render_to_temp_file
    
            tmp = render_to_temp_file()
            try:
                data, rate = sf.read(tmp)
                meter = pyln.Meter(rate)
                integrated = meter.integrated_loudness(data)
                peak_linear = float(np.max(np.abs(data)))
                peak_db = float(20 * np.log10(peak_linear)) if peak_linear > 0 else -120.0
                return {
                    "success": True,
                    "integrated_lufs": round(integrated, 1),
                    "true_peak_dbtp": round(peak_db, 1),
                    "sample_rate": rate,
                }
            finally:
                if os.path.exists(tmp):
                    os.unlink(tmp)
        except Exception as e:
            logger.error(f"analyze_loudness failed: {e}")
            return {"success": False, "error": str(e)}
  • The tool is registered via the master registration function. 'register_tools' from mastering_tools.py is imported and called with the mcp instance on line 27, which decorates analyze_loudness with @mcp.tool().
    from reaper_mcp.mastering_tools import register_tools as _reg_mastering
    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 outer 'register_tools(mcp)' function that contains the @mcp.tool() decoration for analyze_loudness (line 131-132). All mastering tools are registered inside this function.
    def register_tools(mcp):
  • The 'render_to_temp_file' helper function used by analyze_loudness to render the current REAPER project to a temporary WAV file before 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
Behavior4/5

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

The description discloses the behavior of rendering to a temporary file and measuring using a specific standard, which goes beyond the input schema (no params). However, it does not specify whether the temp file is cleaned up or other side effects. No annotations exist to cover this, so the description adds meaningful context.

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 sentence, concise and front-loaded with the core action. Every word adds value, no redundancy.

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

Completeness4/5

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

Given no output schema and no annotations, the description covers the purpose and key behavioral details (temp file, standard). It could mention the output format or return type, but it's adequate for a no-param tool with straightforward output.

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 input schema has zero parameters, so the description does not need to add parameter details. It adds meaning by explaining what the tool does with the project (render and measure), with baseline 4 appropriate for 0-param tools.

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 tool renders the project to a temp file and measures integrated loudness (LUFS) and true peak (dBTP) using the ITU-R BS.1770 standard. It uses a specific verb (measure) and resource (loudness/peak), distinguishing it from sibling analysis tools like analyze_dynamics or analyze_frequency_spectrum.

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 usage for loudness measurement but does not explicitly state when to use this tool versus alternatives (e.g., analyze_dynamics, analyze_stereo_field). No when-not-to-use guidance or alternative references are provided.

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