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.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.7 (2026) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

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.

What is the decomposition? The detector produces a mask 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

  1. Select exactly one Sound object in Praat.
  2. Run Adaptive Transient Decomposition(1).praat.
  3. Choose a preset or select Custom and set the analysis/detector parameters.
  4. Set Transient output gain if the transient component should be level-adjusted after decomposition.
  5. Leave Draw visualization enabled if a detector/decomposition summary is wanted.
  6. Click OK.

The script creates:

Reconstruction: With Transient output gain = 0 dB, the transient and sustain components are complementary and their sum reconstructs the original signal to numerical precision. A non-zero transient output gain is applied only after this decomposition, so the final two outputs no longer sum exactly to the input.
Input requirements: The script requires exactly one Sound and rejects Sounds shorter than 0.10 s. No normalization or limiter is applied to the outputs. Positive transient gain can therefore produce sample values above ±1.

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

LPC method: Praat To LPC (autocorrelation) Nyquist_kHz = (sample_rate / 2) / 1000 LPC_order = round(Nyquist_kHz × LPC_order_per_kHz + 2) LPC_order = max(2, LPC_order) Analysis window = Analysis_window_ms Time step = Time_step_ms Pre-emphasis frequency argument = 50 Hz The LPC model is inverse-filtered to produce a prediction-error residual. The residual is a detector signal only; it is not one of the final components.

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.

Fast envelope: squared residual → Hann low-pass with upper frequency ≈ 1000 / Integration_ms → sqrt(max(0, value)) Slow floor envelope: squared residual → Hann low-pass with upper frequency = Floor_rate_Hz → sqrt(max(0, value))

5. Adaptive dB score and sigmoid

score_dB(t) = 20 log10((fast(t) + ε) / (slow(t) + ε)) ε = 1e-12 z(t) = Sigmoid_steepness × (score_dB(t) − Threshold_dB) raw_mask(t) = 1 / (1 + exp(−z(t)))

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

For every original channel c: transient_c(t) = original_c(t) × mask(t) sustain_c(t) = original_c(t) × (1 − mask(t)) Before optional transient gain: transient_c(t) + sustain_c(t) = original_c(t)

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

ParameterCustom defaultRole
PresetCustomLoads one of six predefined analysis/detector configurations, or leaves the entered Custom values unchanged.
LPC_order_per_kHz2.0Scales LPC order from the input Nyquist frequency.
Analysis_window_ms25.0 msWindow length supplied to the LPC autocorrelation analysis.
Time_step_ms5.0 msTime step supplied to the LPC analysis.
Integration_ms5.0 msControls the fast residual-energy envelope; approximately 1000 / Integration_ms Hz before Nyquist limiting.
Floor_rate_Hz10.0 HzLow-pass rate used for the slow local residual-energy reference.
Threshold_dB6.0 dBCenter of the raw sigmoid on the fast/slow detector score.
Sigmoid_steepness2.0Controls how sharply the raw mask changes around the threshold.
Burst_padding_ms15.0 msControls the optional soft temporal-extension filter; negative values are clamped to 0.
Transient_output_gain_dB0.0 dBPost-decomposition gain applied only to the transient output.
Draw_visualizationOnDraws the detector/decomposition summary in the Picture window.
Preset behavior: Choosing a named preset replaces the LPC/detector parameters listed below. Transient_output_gain_dB and Draw_visualization are not replaced by a preset.

Preset values

PresetLPC / kHzWindowStepIntegrationFloorThresholdSteepnessSoft pad
Percussion2.020 ms3 ms3 ms8 Hz4 dB3.010 ms
Piano2.525 ms5 ms5 ms10 Hz6 dB2.020 ms
Strings3.030 ms8 ms8 ms5 Hz8 dB1.525 ms
Speech2.025 ms5 ms4 ms12 Hz5 dB2.515 ms
Gentle2.030 ms8 ms10 ms5 Hz10 dB1.030 ms
Aggressive1.515 ms2 ms2 ms15 Hz3 dB4.05 ms

Parameter direction

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.

CaseCurrent behavior
Silent inputIf 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 sThe script exits without processing.
Sound shorter than 0.5 sInternal detector padding is reduced from 100 ms to 25% of the Sound duration.
Negative Burst_padding_msClamped to 0.
High Custom steepnessThe sigmoid exponent is bounded internally to avoid exponential overflow.
RandomnessA 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:

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:

Interpretation: The two components are defined by this detector and mask, not by a universal physical boundary between “transient” and “sustain.” LPC prediction error can also respond to noise, spectral change, and other poorly predicted material. Parameter choices therefore affect what is assigned to each component.