Wave Terrain Synthesis — User Guide

A bounded two-dimensional trajectory scans a normalized mathematical terrain. Bilinear interpolation converts the continuously moving X/Y position into terrain height, which becomes the mono audio signal before DC removal and final target peak normalization.

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

What this does

The script generates sound from a two-dimensional Matrix terrain z(x,y). Two normalized control signals, x(t) and y(t), define a path across the surface. At every audio sample, the terrain height underneath that path becomes the raw audio value.

Process:
terrain generation → centering / terrain peak normalization → bounded X/Y trajectories → bilinear terrain sampling → raw terrain-height signal → DC removal → target peak normalization

No input Sound is required. The final result is mono.

The terrain is a discrete Matrix, but the trajectory is not restricted to Matrix cell centers. Version 0.4 and later use bilinear interpolation so motion across the surface is continuous between neighboring terrain samples.

Quick start

  1. Choose Custom or one of the eight named presets.
  2. Set the total Duration.
  3. In Custom mode, choose Terrain type plus X and Y trajectory waveforms and their base rates.
  4. Enable Edit details to change terrain resolution/scale, spans, offsets, phases, phase-modulation rates/index, Sample rate, Output peak, or Random seed.
  5. Run the script. A mono Sound named waveTerrain_<terrain name> is created.

Terrain construction

The terrain occupies normalized coordinates x,y ∈ [0,1]. It is first filled according to the selected terrain equation, then globally centered by subtracting the Matrix mean. Finally, the entire terrain is divided by its largest absolute value so that its largest positive or negative height reaches magnitude 1 whenever the terrain is nonzero.

terrain := terrain - mean(terrain) terrainPeak = max(|terrainMaximum|, |terrainMinimum|) if terrainPeak > 0: terrain := terrain / terrainPeak

This terrain normalization happens before the trajectory scans the surface. It is separate from the final Sound normalization.

1 — Sine product

z(x,y) = sin(2π × 4 × scale × x) × sin(2π × 4 × scale × y)

2 — Chebyshev product

Coordinates are first centered to approximately −1…1 and stretched by Terrain spatial scale:

u = (2x - 1) × scale v = (2y - 1) × scale T2(q) = 2q² - 1 T3(q) = 4q³ - 3q z(x,y) = T3(u)T2(v) - T2(u)T3(v)
At scale = 1, these are the exact T2/T3 Chebyshev polynomial terms. Scale values other than 1 stretch the polynomial coordinates before evaluation.

3 — Random smoothed

Every Matrix cell starts as an independent Gaussian random value. The script then performs one periodic cross-neighbor smoothing pass:

new cell = (center + up + down + left + right) / 5

The smoothing wraps across Matrix boundaries for this terrain-construction step only.

4 — Multi-scale harmonic

z = sin(2π × 2 × scale × x) sin(2π × 2 × scale × y) + 0.5 sin(2π × 4 × scale × x) sin(2π × 4 × scale × y) + 0.25 sin(2π × 8 × scale × x) sin(2π × 8 × scale × y)

This is a deterministic sum of three spatial harmonic layers. It replaces the earlier “Fractal” label.

5 — Spiral

r = sqrt[(x-.5)² + (y-.5)²] θ = atan2(y-.5, x-.5) z = sin(2π × 10 × scale × r + θ)

Trajectory controls

X and Y each have an independent base rate, waveform, phase, span, offset, and phase-modulation rate. Both axes share one modulation-index value.

Span means terrain coverage

Version 0.4 redefines span directly as a fraction of the terrain dimension:

coordinate = offset + 0.5 × span × waveform(phase)

With Offset = .5, Span = 1.0 covers the full 0…1 range. Span = .8 covers .1….9.

The script validates span against offset so the trajectory remains inside the terrain instead of relying on clipping.

Trajectory waveforms

WaveformNormalized waveform used inside the span
Sinesin(phase)
TrianglePeriodic triangle in −1…1.
SawPeriodic rising saw in −1…1 with an instantaneous reset.
SquareSwitches between +1 and −1 at half-cycle.

These waveforms describe motion through the terrain; they are not directly used as oscillator audio waveforms.

Trajectory phase modulation

The modulation controls perturb trajectory phase, not the coordinate after the offset/span mapping.

For a sine trajectory, for example:

φx(t) = 2π fx t + phaseX + β sin(2π fmx t) x(t) = offsetX + 0.5 × spanX × sin[φx(t)]

Y uses the same modulation index β but its own modulation rate.

For Triangle, Saw, and Square, the equivalent phase perturbation is applied before the periodic waveform is evaluated.

The Details field Phase-mod index (rad) is shared by X and Y. The X and Y phase-mod rates are independent.

Bilinear terrain lookup

The normalized X/Y controls are converted to continuous Matrix indices:

ix = 1 + x(t)(N - 1) iy = 1 + y(t)(N - 1)

The script takes the four neighboring terrain values and blends them according to the fractional X/Y positions:

a = fractional part of ix b = fractional part of iy z = (1-a)(1-b) z00 + a(1-b) z10 + (1-a)b z01 + ab z11

This interpolated z is the raw audio sample value. Edge lookups are clamped to the last valid Matrix row/column.

Presets

Presets are applied before the Details page opens, so enabling Edit details lets you inspect and modify the preset's actual advanced settings.

PresetTerrainX trajectoryY trajectoryImportant details
Classic Sine TerrainSine product, scale 1.0, N=128Sine, 220 Hz, span .90Sine, 330 Hz, span .90Offsets .5/.5; phases 0°/90°; no phase modulation.
Metallic ChebyshevChebyshev product, scale 1.0, N=128Sine, 165 Hz, span .70Sine, 247 Hz, span .70Offsets .5/.5; phases 0°/90°; no phase modulation.
Chaotic MultiscaleMulti-scale harmonic, scale 1.5, N=96Triangle, 110 Hz, span .95Saw, 165 Hz, span .95Phase-mod rates 2.3 / 3.7 Hz; β=.30 rad.
Spiral GalaxySpiral, scale 2.0, N=128Sine, 130 Hz, span .85Sine, 195 Hz, span .85Phase-mod rates .5 / .7 Hz; β=.40 rad.
FM ComplexSine product, scale 2.0, N=96Sine, 440 Hz, span .60Sine, 660 Hz, span .60Phase-mod rates 6.5 / 9.8 Hz; β=.70 rad.
Alien LandscapeRandom smoothed, scale 1.0, N=128Square, 82.4 Hz, span .90Triangle, 123.6 Hz, span .90Phase-mod rates .2 / .3 Hz; β=.60 rad.
Rhythmic PulsesSine product, scale 3.0, N=128Square, 8 Hz, span .80Sine, 440 Hz, span .50No phase modulation.
Smooth AmbientSine product, scale .5, N=96Sine, 55 Hz, span .95Sine, 82.5 Hz, span .95Phase-mod rates .1 / .15 Hz; β=.20 rad.
Preset names are descriptive labels for parameter combinations. They do not imply a separate synthesis algorithm.

Controls

Main page

ControlDefaultMeaning
PresetCustomCustom plus eight named configurations.
Duration3.0 sFinal Sound duration.
Terrain typeSine productUsed directly in Custom; presets override it before Details.
X trajectorySineHorizontal path waveform.
X frequency220 HzBase horizontal trajectory rate.
Y trajectorySineVertical path waveform.
Y frequency330 HzBase vertical trajectory rate.
Edit detailsoffOpens terrain resolution, spatial and modulation controls, sample rate, Output peak, and Random seed.
Draw visualizationonDraws the process-oriented terrain/path/QC display.
Play resultonPlays the generated Sound after processing.

Details page

ControlDefaultMeaning
Terrain size128Matrix resolution N×N; accepted range 8–512.
Terrain spatial scale1.0Scales spatial features inside the terrain equation; must be positive.
X / Y span.8 / .8Fraction of terrain width/height traversed around the corresponding offset.
X / Y phase0° / 90°Starting trajectory phase.
X / Y offset.5 / .5Center position in normalized terrain coordinates.
X / Y phase-mod rate0 / 0 HzSeparate modulation rates applied to X/Y trajectory phase.
Phase-mod index.5 radShared X/Y phase-modulation index β.
Sample rate44100 HzDirect synthesis/output rate; must be at least 4000 Hz.
Output peak.95Final target peak normalization; accepted range >0…1.
Random seed0A positive value initializes Praat's RNG predictably before terrain generation; 0 leaves the current RNG state unchanged.

Validation and safety

Terrain-size guard

Version 0.4.2 limits Terrain size before Matrix allocation:

8 ≤ TerrainSize ≤ 512

The upper bound prevents accidental very large Matrix allocation and the associated nested Praat loops.

Bounded trajectory validation

Span and offset are validated together. For each axis:

span ≤ 2 × min(offset, 1-offset)

This guarantees the generated path stays within normalized terrain coordinates 0…1.

Trajectory-rate / Nyquist guard

The script estimates the largest instantaneous trajectory phase rate as:

X maximum rate = X base rate + β × X modulation rate Y maximum rate = Y base rate + β × Y modulation rate

The larger of these must remain below 45% of Sample rate.

This guard limits trajectory control rate, but wave-terrain scanning is a nonlinear sampling process and is not strictly band-limited. Bright terrain features and discontinuous Saw/Square trajectories can still produce energy above Nyquist. Higher Sample rates are useful for aggressive settings.

Random terrain and seed

Random seed affects the Gaussian values used by Random smoothed terrain.

If Random seed is positive, the script calls Praat's predictable seeded RNG before terrain creation, so the same terrain parameters and seed reproduce the same initial random Matrix and therefore the same result.

When Random seed = 0, the script does not replace Praat's current random state with a fixed seed.

The script does not restore the previous/global RNG state after a positive seed. This matters only to subsequent random operations performed in the same Praat session.

Output and level

PropertyBehavior
InputNo input Sound required.
ChannelsMono.
DurationExactly the requested Duration.
Sample rateExactly the Details-page Sample rate.
Raw signalBilinearly interpolated terrain height along the X/Y path.
DC treatmentSubtract mean is applied to the complete raw scan.
NormalizationIf non-silent, the complete Sound is peak-scaled once to Output peak. This is target normalization, not a down-only ceiling.
Object namewaveTerrain_<terrain name>.

The earlier Output gain control is no longer present because a single fixed gain applied before unconditional target normalization would not alter the final peak.

Visualization and QC

The visualization is organized as a direct representation of the synthesis process rather than as a decorative terrain display.

A — Terrain surface + actual trajectory excerpt

The normalized terrain Matrix is painted in the same 0…1 coordinates used by synthesis. A white line overlays the actual generated X/Y trajectory for a short excerpt.

The excerpt length is chosen automatically: up to two cycles of the slower base trajectory, bounded to 30–500 ms and never longer than the Sound.

Manual plot queries are clamped to the first and last actual Sound sample-center times. This is the v0.4.1 visualization hotfix that prevents undefined endpoint queries at nominal time 0 or exactly Duration.

B — X/Y trajectory controls

The same excerpt is shown as normalized x(t) and y(t) curves, making span, offset, waveform, rate, phase, and phase modulation directly visible.

Bilinear equation strip

A separate strip states the four-neighbor interpolation law used by the audio engine.

C — Sampled terrain height → conditioned audio

The raw interpolated terrain-height signal is plotted against the final DC-removed and peak-normalized output over the same excerpt.

D — Full measured output

The final mono waveform is drawn over the complete requested Duration.

QC

The bottom grid reports: