XMod — Cross Modulation — User Guide

Carrier-preserving cross modulation with ring modulation, bipolar-to-unipolar amplitude modulation, and attack/release-smoothed rhythmic or envelope gating. Control can come from an internal oscillator or a second Sound.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 1.2.1 (2026) License: MIT License Repo: Praat AudioTools
Contents:

Overview

XMod multiplies a carrier Sound by a time-varying control signal. Depending on the selected mode, that control produces a dry-to-ring transformation, unipolar amplitude modulation, or a smoothed gate/envelope effect. The carrier's channel count, sample rate, duration, and original start time are preserved.

The modulator can be a sine, square, triangle, or sawtooth oscillator, or a second selected Sound. In Second Sound mode, v1.2.1 explicitly asks which of the two selected Sounds is the Carrier; the other becomes the Modulator. This avoids relying on Praat's object-list selection order.

Depth is mode-dependent. For Ring Modulation, depth 0–1 is a crossfade from dry to pure ring modulation; values above 1 scale the pure ring signal. For AM and Gate, depth is clamped to 0–1 and blends dry audio with the corresponding amplitude-control result. In all three modes, depth 0 is an exact dry bypass unless another operation is explicitly requested; the safety stage is also skipped at depth 0.

Quick start

  1. Select one Sound when using an oscillator modulator.
  2. For Second Sound, select exactly two Sounds. After the main form, XMod displays both names and IDs and asks which one is the Carrier.
  3. Choose a preset or Custom.
  4. Select Ring Modulation, Amplitude Modulation, or Rhythmic Gate.
  5. Choose the modulator source and set frequency/depth. Gate mode also uses Attack and Release; Duty Cycle shapes the Square oscillator.
  6. Leave Safety peak at 0.99 for attenuation-only peak protection, or set it to 0 to disable that stage.
  7. Enable visualization and/or playback as desired, then run the script.
Second Sound alignment: the external modulator is treated as a control track beginning at the carrier's first sample. Its own start time is removed before processing. It is therefore not synchronized to the carrier by absolute Praat time coordinates.

Three modulation modes

Ring Modulation

With modulator m[n], carrier x[n], and depth d:

For 0 ≤ d ≤ 1: y[n] = x[n] · ((1-d) + d·m[n]) At d = 0: y[n] = x[n] At d = 1: y[n] = x[n]·m[n] For d > 1: y[n] = d·x[n]·m[n]

Thus 0–1 is a dry-to-ring interpolation, not merely a ring-output gain control. Above 1, the dry term is removed and depth scales the pure ring product. For sinusoidal carrier/modulator components, multiplication produces the familiar sum/difference-frequency relationship.

External Ring modulation is not control-normalized. A Second Sound is downmixed/resampled/aligned as needed, but its sample amplitude enters the ring product directly. Its own peak therefore affects the resulting ring level.

Amplitude Modulation (AM)

XMod converts the bipolar modulator to a unipolar 0–1 amplitude control, then interpolates between dry and controlled amplitude:

c[n] = (1 + m[n]) / 2 y[n] = x[n] · ((1-d) + d·c[n])

At depth 0 the output is exactly dry. At depth 1, a sine oscillator varies the gain from 0 to 1. For a Second Sound, the modulator is peak-normalized only for the control calculation; the original source object is never modified.

Rhythmic Gate / Envelope Gate

Gate mode first creates a 0–1 target signal and then follows it with separate one-pole attack and release time constants. The smoothed envelope controls the carrier:

target[n] = oscillator mapped to 0..1 or |external modulator[n]| / external peak if target[n] > envelope[n-1]: use attack coefficient else: use release coefficient y[n] = x[n] · ((1-d) + d·envelope[n])

For a Square oscillator this behaves as a conventional rhythmic gate, with Duty Cycle determining the high portion of each cycle. Sine, triangle, and sawtooth sources generate continuous 0–1 targets rather than binary on/off targets. With a Second Sound, the rectified normalized amplitude of that sound becomes the gate target, so the result behaves as an external envelope-controlled gate.

Modulator sources

SourceControl waveformImportant behavior
Sine Oscillatorsin(2πft)Smooth bipolar control.
Square Oscillator+1 / −1Duty Cycle determines the proportion of each cycle spent at +1.
Triangle OscillatorLinear rise and fall from −1 to +1Continuous piecewise-linear control.
Sawtooth OscillatorLinear rise from −1 to +1, then resetAsymmetric periodic control.
Second SoundExternal mono control derived from another selected SoundCarrier is chosen explicitly in v1.2.1; multichannel modulator is converted to mono; sample rate, duration, and time origin are adapted to the carrier grid.

Second Sound preparation

  1. Select exactly two Sounds; XMod asks which one is the Carrier.
  2. The other Sound is copied/converted to mono for control use.
  3. Its original xmin is removed so its first sample corresponds to local time 0.
  4. If its sample rate differs from the carrier, it is resampled to the carrier rate.
  5. If it is longer than the carrier, it is trimmed. If shorter, the remainder is explicitly zero-padded.
  6. The prepared control Sound is temporary; the original modulator Sound remains unchanged.

AM and external Gate normalize this temporary control by its absolute peak for control purposes. Ring Modulation does not.

Presets

Choosing a preset overrides the listed mode/source parameters. Safety peak, Draw visualization, and Play result remain user-controlled.

PresetModeSourceFrequencyDepthGate settings
CustomUserUserUserUserUser
Ring Mod - MetallicRingSine440 Hz1.0
Ring Mod - DeepRingSine80 Hz1.0
AM - Radio StyleAMSine1000 Hz0.8
AM - TremoloAMSine6 Hz0.7
Gate - Fast StutterGateSquare10 Hz1.0Duty 0.5; A/R 2/2 ms
Gate - Slow PulseGateSquare2 Hz1.0Duty 0.5; A/R 10/10 ms
Gate - HelicopterGateSquare12.5 Hz1.0Duty 0.5; A/R 1/1 ms
Sidechain-like PumpGateSquare2 Hz0.9Duty 0.3; A/R 5/80 ms
Sidechain-like Pump is oscillator-driven. It does not analyze a kick track or perform compression. The name describes the amplitude contour it produces.

Parameters

ParameterDefaultMeaning
PresetCustomCustom or one of eight fixed configurations.
Mod typeRing ModulationRing, AM, or Rhythmic Gate.
Mod sourceSine OscillatorFour internal oscillators or Second Sound.
Mod frequency (Hz)10Oscillator frequency. If it reaches/exceeds carrier Nyquist, XMod clamps it to 95% of Nyquist. It is irrelevant to Second Sound.
Mod depth1.0Negative values clamp to 0. AM/Gate clamp to 0–1. Ring allows values above 1 as pure-ring gain.
Attack (ms)5Gate-envelope rise time constant.
Release (ms)5Gate-envelope fall time constant.
Duty cycle0.5Clamped to 0–1; used by the Square oscillator to set its +1 portion.
Safety peak0.99Clamped to 0–1. 0 disables protection; otherwise attenuation is applied only when the processed peak exceeds the threshold.
Draw visualizationOnDraws diagnostic waveforms, control signal, spectrograms, and summary.
Play resultOnPlays the final output after processing.

Input & output behavior

PropertyBehavior
Oscillator inputExactly one selected Sound.
Second Sound inputExactly two selected Sounds, followed by explicit Carrier selection.
Carrier channelsPreserved exactly; the same mono control is applied independently to every carrier channel.
Carrier sample ratePreserved.
Carrier durationPreserved; XMod adds no tail.
Carrier start timexmin preserved.
External modulator channelsDownmixed to mono for control use.
External modulator durationTrimmed or zero-padded to exactly the carrier duration.
Output name<carrier>_xmod_<presetName>.
RandomnessNone. With the same inputs/settings, processing is deterministic.

Level management

XMod does not normalize every result. After modulation it measures the output peak. If depth is greater than 0, Safety peak is enabled, and the peak exceeds the threshold, XMod attenuates the whole output to that threshold. Quieter results are never boosted.

Because the safety stage is bypassed at depth 0, all three modes can return an exact dry signal even when the dry carrier itself is above the selected safety threshold.

Visualization

When enabled, v1.2.1 uses the Praat AudioTools 8-inch page layout. The visualization is diagnostic only and does not alter the processed audio.

For multichannel carriers, mono conversion is used only for drawing. DSP processing remains channel-preserving.

Technical notes

Attack and release coefficients

Gate smoothing is performed sample by sample. For time constant τ and sample rate Fs, the script uses:

α = exp(-1 / (τ · Fs)) envelope[n] = α·envelope[n-1] + (1-α)·target[n]

Separate coefficients are calculated for Attack and Release and selected according to whether the target is above or below the previous envelope value.

External control normalization differs by mode

ModeUse of Second Sound amplitude
RingDirect sample multiplication; no peak normalization of the control.
AMDivided by the control Sound's absolute peak before bipolar-to-unipolar mapping.
GateAbsolute value divided by the control Sound's peak, yielding a 0–1 target.

Limits and interpretation

Further Reading