Detect onsets
detect_onsetsAnalyze 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
| Name | Required | Description | Default |
|---|---|---|---|
| source | No | Audio 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_path | No | Audio file path (source='file'). | |
| existing_chop_path | No | Path of an existing audio CHOP to analyze (source='existing_chop'). | |
| kick_hz | No | Low-pass cutoff (Hz) isolating the kick/bass-drum band. | |
| snare_hz | No | Band-pass centre (Hz) isolating the snare/body band. | |
| hat_hz | No | High-pass cutoff (Hz) isolating the hi-hat/cymbal band. | |
| threshold | No | How 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_events | No | Also 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_controls | No | Expose live 'Sensitivity' (output gain) and 'Threshold' (hit sensitivity) knobs. | |
| parent_path | No | /project1 |