Hilbert Transform for Drums — User Guide

Hilbert-transform envelope extraction and envelope-driven transient shaping for mono or stereo Sound objects.

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

What this does

Hilbert Transform for Drums derives a discrete Hilbert transform from the complex Fourier spectrum and uses it either directly as a 90° phase-shifted signal or together with the original waveform to form an analytic-signal magnitude envelope. That envelope can then drive transient contrast or gate-like amplitude shaping.

For a signal x and its Hilbert transform H{x}, the envelope is:

envelope = sqrt(x^2 + H{x}^2)

The envelope is optionally smoothed, normalized to a maximum of 1, and floored at 0.001 for stable multiplication and exponentiation. The script does not perform onset detection, peak picking, or a conventional dynamics-compressor analysis.

Quick start

  1. Select exactly one mono or stereo Sound object in Praat.
  2. Run Hilbert Transform for Drums.praat.
  3. Choose a preset, or use Custom and select an output mode.
  4. For transient work, adjust transient_amount and envelope_smoothing_ms.
  5. Set dry_wet_mix. Leave scale_peak = 0 when natural output level should be preserved.
  6. Run the script. The result is created as a new Sound object; the selected source is not modified.

Output modes

ModeOperationResult
Transient Enhancedoutput = input × envelope^(transient_amount - 1)Changes attack/sustain contrast using the normalized envelope.
Envelope Shapedoutput = input × envelopeGate-like shaping: stronger-envelope regions are retained more strongly; lower-envelope regions are attenuated.
Hilbert (90deg shift)Rotates the positive-frequency complex spectrum by −90°; DC and the Nyquist bin, when present, are set to zero.The discrete Hilbert-transform signal itself. No envelope or smoothing stage is used.
Normalized Envelopesqrt(x^2 + H{x}^2), optional smoothing, then channel-wise normalization.A non-negative modulation/analysis contour rather than conventional audio-program material.

Transient amount

The normalized envelope is approximately in the range 0.001–1. In Transient Enhanced mode, transient_amount = 1 leaves the waveform unchanged before dry/wet mixing. Values above 1 attenuate lower-envelope portions more strongly and therefore increase attack/sustain contrast. Values below 1 apply a negative exponent, raising lower-envelope portions relative to peaks and therefore reducing attack/sustain contrast. This is how the Soft Attack preset works: it does not simply turn transient peaks down; it reduces their contrast relative to the surrounding signal.

Presets

PresetModeTransient amountSmoothingBehavior
CustomUser settingUser settingUser settingLeaves the form values under direct control.
Drum PunchTransient Enhanced2.02 msIncreases attack/sustain contrast.
Soft AttackTransient Enhanced0.510 msReduces attack/sustain contrast by lifting lower-envelope portions relative to peaks.
Phase ShiftHilbert (90deg shift)Not usedOutputs the Hilbert-transformed signal.
Gate EffectEnvelope Shaped1 msMultiplies the source by its normalized envelope for strong envelope-dependent attenuation.

Presets override only the mode, transient amount, and smoothing values shown above. They do not override dry_wet_mix, scale_peak, visualization, or playback settings.

Parameters

ParameterDefaultDescription
PresetCustomSelects a prepared combination or leaves the remaining controls unchanged.
Output_modeTransient EnhancedSelects transient shaping, envelope shaping, Hilbert output, or normalized envelope output.
transient_amount1.5Used only in Transient Enhanced mode. Internally clamped to a minimum of 0.1.
envelope_smoothing_ms5 msControls envelope low-pass smoothing in all envelope-based modes. Values below 0.1 ms are clamped to 0.1 ms. Not used by Hilbert-only mode.
dry_wet_mix1.00 = dry, 1 = processed. Values are clamped to 0–1. Intermediate values linearly mix the processed result with the original channel(s).
scale_peak00 preserves the natural output level. A value above 0 peak-normalizes the final result to that target after dry/wet mixing.
draw_visualizationyesDraws the AudioTools diagnostic page.
play_after_processingyesPlays the final Sound object after processing.

Signal behavior

Hilbert construction

The selected channel is transformed with Praat's full-length Fourier spectrum. The complex spectrum is rotated so that, for stored positive-frequency bins, the new real part comes from the original imaginary part and the new imaginary part is the negative original real part. DC is removed; for an even-length Sound, the Nyquist bin is also removed before inverse transformation.

Envelope smoothing

When smoothing is used, the normalized-magnitude precursor is low-pass filtered with Praat's Hann-band filter from 0 Hz to approximately 1000 / envelope_smoothing_ms Hz, with a transition width equal to 20% of that cutoff. If the requested cutoff reaches or exceeds Nyquist, this smoothing filter is skipped.

Mono and stereo

Mono and stereo inputs are supported; inputs with more than two channels are rejected. Stereo channels are processed independently and recombined in their original order. In Normalized Envelope mode, each stereo envelope is normalized independently to its own maximum, so the envelope output should not be interpreted as preserving the original inter-channel level ratio.

Dry/wet and level

With dry_wet_mix = 0, the Hilbert/envelope calculation is skipped and the source is copied directly. If scale_peak = 0, this is a true dry copy apart from the new object name. If scale_peak > 0, the requested final normalization is still applied even on a fully dry result.

Time and sampling

The final Sound preserves the source sample rate, duration, channel count, and original start time (xmin). Internally, Spectrum-to-Sound synthesis uses a zero-based time domain; the script restores the source start time before naming and returning the output.

No random process is used in the audio algorithm. A random internal identifier is generated only to keep temporary Praat object names unique; it does not affect the samples.

Visualization

When enabled, the script creates an 8-inch AudioTools diagnostic page. Visualization uses temporary mono display copies; the stored audio output is not folded to mono.

For sources whose time domain does not start at 0, only the temporary visualization copies are shifted to a zero-based display axis. The final Sound retains the original xmin.

Outputs

ModeObject suffix
Transient Enhanced_TransientEnhanced
Envelope Shaped_EnvelopeShaped
Hilbert (90deg shift)_Hilbert90
Normalized Envelope_NormalizedEnvelope

The complete output name is <originalName>_<modeSuffix>. Temporary processing and visualization objects are removed before completion.

Further Reading