analyze_transients
Detect and analyze transient events in your audio project, such as note attacks and drum hits. Returns the count and timing of up to 100 onset events for precise editing.
Instructions
Render the project and detect transient events (note attacks, drum hits, etc.). Returns the count and timing of up to 100 transient onset events.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/reaper_mcp/analysis_tools.py:197-224 (handler)The main handler for the 'analyze_transients' MCP tool. Renders the project to a temp WAV, uses librosa to detect onset events (note attacks, drum hits), and returns up to 100 onset timestamps.
def analyze_transients() -> dict: """ Render the project and detect transient events (note attacks, drum hits, etc.). Returns the count and timing of up to 100 transient onset events. """ try: import librosa from reaper_mcp.render_tools import render_to_temp_file tmp = render_to_temp_file(sample_rate=44100) try: y, sr = librosa.load(tmp, sr=None, mono=True) finally: if os.path.exists(tmp): os.unlink(tmp) onset_frames = librosa.onset.onset_detect(y=y, sr=sr, units="frames") onset_times = librosa.frames_to_time(onset_frames, sr=sr).tolist() capped = onset_times[:100] return { "success": True, "onset_count": len(onset_times), "onset_times_seconds": [round(t, 3) for t in capped], "note": "Showing up to 100 events" if len(onset_times) > 100 else None, } except Exception as e: return {"success": False, "error": str(e)} - The decorator-based schema/registration for the tool. No input parameters; returns a dict with success, onset_count, onset_times_seconds, and optional note.
@mcp.tool() def analyze_transients() -> dict: - src/reaper_mcp/server.py:18-28 (registration)The tool registration entry point: imports and calls register_tools from analysis_tools.py on the mcp instance in server.py.
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) - src/reaper_mcp/analysis_tools.py:21-21 (registration)The register_tools function that decorates analyze_transients (and analyze_frequency_spectrum) as MCP tools.
def register_tools(mcp): - src/reaper_mcp/render_tools.py:47-56 (helper)Helper function used by analyze_transients to render the 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