Add Signals

Sum, average, and weight multiple audio signals with precise alignment, gain staging, polarity control, and safe normalization.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.1 (2025) Praat
Contents:

What this does

Select two or more Sound objects and combine them into a single output via sum, average, or weighted mixing. The script aligns lengths, manages sample-rate differences (with optional resample), applies per-signal gain/polarity, and prevents clipping via peak normalization or headroom trims.

Output: A new Sound named sum_N (or custom) is created.

Quick start

  1. Select two or more Sound objects in Praat.
  2. Run script…Add signals.praat.
  3. Choose mix_mode (Sum, Average, Weighted).
  4. Enter optional gains_db and invert_mask (e.g., 0,-6,0 and 0,1,0).
  5. Select align_by and pad_mode (trim/pad with silence).
  6. Enable normalize to target peak (e.g., 0.99). Press OK.

Inputs & Alignment

OptionValuesDescription
align_bystart | end | offsetAlign start times, right-align by end, or apply offsets per input (s).
offsets_sCSV secondsUsed when align_by=offset. Positive delays a signal.
pad_modepad | trimPad shorter sounds with silence to match longest, or trim all to shortest.
resample_if_neededyes/noIf sample rates differ, resample to the first (or highest) rate.

Mix Modes

➕ Sum

Direct arithmetic addition of all inputs (after gains). Best when gains are pre-managed.

⚖️ Average

Sum divided by number of inputs; preserves overall loudness across varying counts.

🧮 Weighted

Apply per-input weights (normalized internally) for precise balances.

Parameters

ParameterTypeDefaultDescription
mix_modeoptionAverageSum | Average | Weighted
weightsCSV (linear)""Per-input weights; auto-normalized when set
gains_dbCSV (dB)""Per-input pre-sum gain; blank ⇒ 0 dB
invert_maskCSV (0/1)""Invert polarity per input (1 = invert)
remove_dcbooleanyesHigh-pass or mean-subtract each input before mixing
align_byoptionstartstart | end | offset
offsets_sCSV (s)""Only used for offset alignment
pad_modeoptionpadpad | trim
resample_if_neededbooleanyesMatch sample rates automatically
normalizebooleanyesPeak-normalize output to norm_target
norm_targetreal0.99Peak target
auto_headroom_dbreal (dB)0Apply global negative gain pre-sum (e.g., -6 dB)
limit_hardbooleannoSimple hard limiter after normalization
reportbooleannoPrint effective gains, offsets, and headroom

Presets

🎙️ Dual-mic blend

weights=0.6,0.4; gains_db=0,-3; align_by=offset; offsets_s=0,0.001

🎹 Layered pads

mix_mode=Average; gains_db=-6,-6,-6; pad_mode=pad; normalize=yes

🥁 Parallel buss

mix_mode=Weighted; weights=0.7,0.3; gains_db=0,0; invert_mask=0,0; limit_hard=yes

Tips & Pitfalls

Watch out: Averaging with zeros (silent pads) lowers level; consider weights that ignore silences.

Math

Sum / Average / Weighted

Given inputs x_i(t) with gains g_i (linear) and polarity s_i ∈ {+1, -1}:
Sum: y(t) = Σ s_i g_i x_i(t)
Average: y(t) = (1/M) Σ s_i g_i x_i(t)
Weighted: y(t) = (1/Σ w_i) Σ w_i s_i g_i x_i(t)

dB ↔ Linear

g = 10^{(dB/20)}; dB = 20 log10(g).

Headroom & Normalization

Apply pre-sum headroom G_H (linear). After mixing, normalize by α = T/peak(y) with target T ∈ (0,1].