Adaptive Transient Decomposition — User Guide
Separates a Sound into transient and sustain components using an LPC-residual-derived detector mask that is applied to the original audio.
What this does
Adaptive Transient Decomposition creates two complementary components from one selected Praat Sound: transients and sustain. An LPC inverse-filtered residual is used only to detect rapidly changing activity. The resulting mask is then applied to the original Sound, not to the LPC residual.
m(t) between 0 and 1. Before optional transient output gain, the two outputs are transient = x × m and sustain = x × (1 − m). Because the masks are complementary, their pre-gain sum reconstructs the original signal apart from numerical precision.
Signal path
Strongest-RMS channel → internal padding → LPC autocorrelation analysis → inverse-filtered residual → fast/slow residual-energy ratio → dB threshold → sigmoid → optional soft temporal extension → one shared mask → original × mask / original × (1 − mask).
The detector is an offline process. Its Hann-band filters are used as zero-phase frequency-domain filters, so the detector is not intended as a causal real-time transient detector.
Quick start
- Select exactly one Sound object in Praat.
- Run
Adaptive Transient Decomposition(1).praat. - Choose a preset or select Custom and set the analysis/detector parameters.
- Set Transient output gain if the transient component should be level-adjusted after decomposition.
- Leave Draw visualization enabled if a detector/decomposition summary is wanted.
- Click OK.
The script creates:
<source>_transients<source>_sustain
Detector and decomposition
1. Representative detector channel
For a multichannel Sound, the script measures RMS independently on every channel and selects the channel with the highest RMS as the detector channel. The original multichannel Sound is not folded to mono. Only the detector is derived from this representative channel.
2. Internal sample-indexed padding
The detector channel is copied into a temporary Sound with silence added by sample index. The normal padding duration is 100 ms on each side. For input shorter than 0.5 s, padding is 25% of the input duration. The detector products are cropped back by sample index, so the output duration and alignment match the original Sound.
3. LPC residual detector
4. Fast and slow residual-energy envelopes
The residual is squared and smoothed twice. Both smoothed power signals are clipped at zero before the square root, avoiding conversion of negative filter ringing into positive energy.
5. Adaptive dB score and sigmoid
The implementation clamps the exponent used by exp() to a finite range, including in Custom mode. Threshold_dB therefore operates on a local fast/slow residual-envelope ratio, not on absolute signal level or an estimated noise floor in amplitude units.
6. Soft temporal extension
If Burst_padding_ms > 0, the raw sigmoid mask is low-pass filtered and passed through a second normalized sigmoid. This extends detected regions in time while keeping the mask within 0–1. It is a soft temporal extension, not a hard morphological dilation and not an explicit fixed pre/post time window. A value of 0 disables this stage.
7. Shared-mask decomposition
The same detector mask is used on every channel. This preserves the original channel count and avoids channel-specific mask differences altering the stereo or multichannel relationship.
Parameters and presets
Form parameters
| Parameter | Custom default | Role |
|---|---|---|
| Preset | Custom | Loads one of six predefined analysis/detector configurations, or leaves the entered Custom values unchanged. |
| LPC_order_per_kHz | 2.0 | Scales LPC order from the input Nyquist frequency. |
| Analysis_window_ms | 25.0 ms | Window length supplied to the LPC autocorrelation analysis. |
| Time_step_ms | 5.0 ms | Time step supplied to the LPC analysis. |
| Integration_ms | 5.0 ms | Controls the fast residual-energy envelope; approximately 1000 / Integration_ms Hz before Nyquist limiting. |
| Floor_rate_Hz | 10.0 Hz | Low-pass rate used for the slow local residual-energy reference. |
| Threshold_dB | 6.0 dB | Center of the raw sigmoid on the fast/slow detector score. |
| Sigmoid_steepness | 2.0 | Controls how sharply the raw mask changes around the threshold. |
| Burst_padding_ms | 15.0 ms | Controls the optional soft temporal-extension filter; negative values are clamped to 0. |
| Transient_output_gain_dB | 0.0 dB | Post-decomposition gain applied only to the transient output. |
| Draw_visualization | On | Draws the detector/decomposition summary in the Picture window. |
Preset values
| Preset | LPC / kHz | Window | Step | Integration | Floor | Threshold | Steepness | Soft pad |
|---|---|---|---|---|---|---|---|---|
| Percussion | 2.0 | 20 ms | 3 ms | 3 ms | 8 Hz | 4 dB | 3.0 | 10 ms |
| Piano | 2.5 | 25 ms | 5 ms | 5 ms | 10 Hz | 6 dB | 2.0 | 20 ms |
| Strings | 3.0 | 30 ms | 8 ms | 8 ms | 5 Hz | 8 dB | 1.5 | 25 ms |
| Speech | 2.0 | 25 ms | 5 ms | 4 ms | 12 Hz | 5 dB | 2.5 | 15 ms |
| Gentle | 2.0 | 30 ms | 8 ms | 10 ms | 5 Hz | 10 dB | 1.0 | 30 ms |
| Aggressive | 1.5 | 15 ms | 2 ms | 2 ms | 15 Hz | 3 dB | 4.0 | 5 ms |
Parameter direction
- Higher Threshold_dB: requires a larger fast/slow residual-energy contrast before the raw mask opens strongly.
- Higher Sigmoid_steepness: makes the threshold transition sharper.
- Longer Integration_ms: lowers the fast-envelope bandwidth and smooths rapid detector changes.
- Lower Floor_rate_Hz: makes the slow reference vary more slowly.
- Larger Burst_padding_ms: increases temporal smoothing/extension of the mask; it does not specify an exact number of milliseconds added before and after every event.
Multichannel handling and edge cases
Channel behavior
The detector uses the strongest-RMS input channel. One mask derived from that channel is then applied to every original channel. The final transient and sustain Sounds therefore retain the original channel count.
| Case | Current behavior |
|---|---|
| Silent input | If the strongest-channel RMS is ≤ 1e-12, the mask is set to zero. The transient output is silence and the sustain output is the original Sound. |
| Sound shorter than 0.10 s | The script exits without processing. |
| Sound shorter than 0.5 s | Internal detector padding is reduced from 100 ms to 25% of the Sound duration. |
| Negative Burst_padding_ms | Clamped to 0. |
| High Custom steepness | The sigmoid exponent is bounded internally to avoid exponential overflow. |
| Randomness | A random integer is used only to make temporary object names unique. It does not alter the audio algorithm or output mask. |
Visualization
When enabled, the Picture window provides a compact process view rather than an additional analysis layer:
- A — Adaptive Detector: the clipped fast/slow score in dB with the selected threshold.
- B — Mask Evolution: raw sigmoid mask and final shared mask.
- C — Decomposition: source, transient, and sustain waveforms from the detector channel on the same amplitude scale.
- D — Output Level / QC: transient/sustain RMS relative to source RMS, mean mask value, and the pre-gain reconstruction check.
The visualization is descriptive only. It does not modify the Sound objects or the detector.
Applications
The decomposition can be used wherever attacks and the complementary sustain component need separate processing or inspection, for example:
- transient shaping or level control;
- processing attacks and sustain with different effects;
- constructing hybrid sounds from components of different sources;
- using the transient component as material for rhythmic or onset-oriented analysis;
- comparing detector behavior across different parameter configurations.