Create energy structure
create_energy_structureBuild an adaptive song structure detector that tracks energy levels and outputs states for breakdown, build, and drop sections using customizable thresholds.
Instructions
[experimental] Build a song-structure (build / drop / breakdown) edge detector COMP with adaptive thresholds. Listens to an existing audio CHOP (audioSource) or a freshly created Audio Device In, follows a long-window envelope, and runs a Script CHOP that maintains a rolling buffer (last windowSec seconds) to derive an adaptive mean (mu) and std (sigma). Emits a 5-channel Null CHOP out with: energy (smoothed RMS 0..1), state (0=breakdown, 1=build, 2=drop), and three 1-sample edge pulses build_edge / drop_edge / breakdown_edge. buildThreshold and dropThreshold are k-multipliers of sigma above mu (NOT absolute amplitudes), so the detector self-calibrates to the current mix loudness. Hysteresis (4 cooks above to step up, 30 below to fall back) stops chattering at thresholds. windowSec/Buildthreshold/Dropthreshold are exposed as custom params on the parent COMP so artists can tweak live. Default audio source builds an Audio Device In CHOP (may pop the macOS mic-permission dialog once — click Allow); pass audioSource to skip the device.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Parent COMP name to create under parent. | |
| parent | No | Parent path (default project root). | / |
| audioSource | No | Optional existing CHOP path producing audio (e.g. an Audio Device In or Audio File In). If omitted, an Audio Device In is created inside the COMP as 'audioin'. | |
| windowSec | No | Length of the rolling energy buffer (sec) used to compute adaptive mean/std. | |
| buildThreshold | No | k_build: state becomes BUILD when energy > mu + k_build*sigma. | |
| dropThreshold | No | k_drop: state becomes DROP when energy > mu + k_drop*sigma (must be > buildThreshold). |