Skip to main content
Glama

Detect onsets

detect_onsets

Analyze live audio to detect drum hits (kick, snare, hi-hat) and output per-band spike pulses. Adjust threshold and sensitivity knobs to control hit detection.

Instructions

Build a transient/onset detector that flags kick/snare/hi-hat hits in live audio and exposes a per-band pulse channel (a 0→1 spike on each hit) on a Null CHOP. Unlike create_tempo_sync (a fixed internal clock), this follows the ACTUAL audio: bind a parameter to op('…/onsets/onsets')['kick'] to flash or cut exactly on the kick drum. Each band is built from primitives (band filter → RMS energy → moving-baseline compare → threshold), so a Threshold knob tunes hit sensitivity and a Sensitivity knob scales the output. Source can be the live device (mic/line — may prompt for macOS permission), an audio file, a synthetic oscillator (for testing), or an existing CHOP. With emit_events on, it also broadcasts an onset event over the bridge WebSocket on each hit. The audio-following complement to create_tempo_sync.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceNoAudio source. 'device' = live microphone/line in (the real-world default; creating it may pop a one-time macOS microphone-permission dialog — click Allow). 'file' = an audio file. 'oscillator' = a synthetic tone, handy for testing without any device permission. 'existing_chop' = reuse a CHOP you already have.device
audio_file_pathNoAudio file path (source='file').
existing_chop_pathNoPath of an existing audio CHOP to analyze (source='existing_chop').
kick_hzNoLow-pass cutoff (Hz) isolating the kick/bass-drum band.
snare_hzNoBand-pass centre (Hz) isolating the snare/body band.
hat_hzNoHigh-pass cutoff (Hz) isolating the hi-hat/cymbal band.
thresholdNoHow far an instant's band energy must rise above its own moving baseline (in RMS units) to count as a hit. Band-RMS magnitudes are small (a steady tone reads ~0.002 live), so the default is 0.01 — the old 0.15 was unreachable and never fired. Lower = more sensitive; raise it if a loud track double-triggers. Tune live per source (needs real percussive audio to dial in).
emit_eventsNoAlso broadcast an `onset` event over the bridge WebSocket on every detected hit (with the band name), so `tdmcp-agent watch` and the AI can react to drum hits live.
expose_controlsNoExpose live 'Sensitivity' (output gain) and 'Threshold' (hit sensitivity) knobs.
parent_pathNo/project1
Behavior5/5

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

Discloses side effects like macOS permission prompt, event broadcasting over WebSocket, and internal processing chain. No contradiction with annotations (readOnlyHint=false, destructiveHint=false).

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

Conciseness4/5

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

Well-structured paragraph with key points front-loaded, but could be slightly more concise without losing essential detail.

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

Completeness5/5

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

Despite no output schema, covers main outputs (per-band pulse channel, events), side effects (permission dialog), and includes usage context, adequately completing the picture for a 10-parameter tool.

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

Parameters5/5

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

Explains threshold in relation to moving baseline, provides concrete tuning values, and clarifies the function of emit_events and expose_controls, adding value beyond the high schema coverage (90%).

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?

Clearly states it builds a transient/onset detector for kick/snare/hi-hat hits, distinguishes from sibling create_tempo_sync by emphasizing it follows actual audio.

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

Usage Guidelines5/5

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

Explicitly contrasts with create_tempo_sync, provides example binding and usage for audio-reactive triggers, and mentions when to use (real audio) versus when not (fixed clock).

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/Pantani/tdmcp'

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