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.
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.
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
- Choose Custom or one of the eight named presets.
- Set the total Duration.
- In Custom mode, choose Terrain type plus X and Y trajectory waveforms and their base rates.
- Enable Edit details to change terrain resolution/scale, spans, offsets, phases, phase-modulation rates/index, Sample rate, Output peak, or Random seed.
- 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.
This terrain normalization happens before the trajectory scans the surface. It is separate from the final Sound normalization.
1 — Sine product
2 — Chebyshev product
Coordinates are first centered to approximately −1…1 and stretched by Terrain spatial scale:
3 — Random smoothed
Every Matrix cell starts as an independent Gaussian random value. The script then performs one periodic cross-neighbor smoothing pass:
The smoothing wraps across Matrix boundaries for this terrain-construction step only.
4 — Multi-scale harmonic
This is a deterministic sum of three spatial harmonic layers. It replaces the earlier “Fractal” label.
5 — Spiral
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:
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
| Waveform | Normalized waveform used inside the span |
|---|---|
| Sine | sin(phase) |
| Triangle | Periodic triangle in −1…1. |
| Saw | Periodic rising saw in −1…1 with an instantaneous reset. |
| Square | Switches 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:
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.
Bilinear terrain lookup
The normalized X/Y controls are converted to continuous Matrix indices:
The script takes the four neighboring terrain values and blends them according to the fractional X/Y positions:
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.
| Preset | Terrain | X trajectory | Y trajectory | Important details |
|---|---|---|---|---|
| Classic Sine Terrain | Sine product, scale 1.0, N=128 | Sine, 220 Hz, span .90 | Sine, 330 Hz, span .90 | Offsets .5/.5; phases 0°/90°; no phase modulation. |
| Metallic Chebyshev | Chebyshev product, scale 1.0, N=128 | Sine, 165 Hz, span .70 | Sine, 247 Hz, span .70 | Offsets .5/.5; phases 0°/90°; no phase modulation. |
| Chaotic Multiscale | Multi-scale harmonic, scale 1.5, N=96 | Triangle, 110 Hz, span .95 | Saw, 165 Hz, span .95 | Phase-mod rates 2.3 / 3.7 Hz; β=.30 rad. |
| Spiral Galaxy | Spiral, scale 2.0, N=128 | Sine, 130 Hz, span .85 | Sine, 195 Hz, span .85 | Phase-mod rates .5 / .7 Hz; β=.40 rad. |
| FM Complex | Sine product, scale 2.0, N=96 | Sine, 440 Hz, span .60 | Sine, 660 Hz, span .60 | Phase-mod rates 6.5 / 9.8 Hz; β=.70 rad. |
| Alien Landscape | Random smoothed, scale 1.0, N=128 | Square, 82.4 Hz, span .90 | Triangle, 123.6 Hz, span .90 | Phase-mod rates .2 / .3 Hz; β=.60 rad. |
| Rhythmic Pulses | Sine product, scale 3.0, N=128 | Square, 8 Hz, span .80 | Sine, 440 Hz, span .50 | No phase modulation. |
| Smooth Ambient | Sine product, scale .5, N=96 | Sine, 55 Hz, span .95 | Sine, 82.5 Hz, span .95 | Phase-mod rates .1 / .15 Hz; β=.20 rad. |
Controls
Main page
| Control | Default | Meaning |
|---|---|---|
| Preset | Custom | Custom plus eight named configurations. |
| Duration | 3.0 s | Final Sound duration. |
| Terrain type | Sine product | Used directly in Custom; presets override it before Details. |
| X trajectory | Sine | Horizontal path waveform. |
| X frequency | 220 Hz | Base horizontal trajectory rate. |
| Y trajectory | Sine | Vertical path waveform. |
| Y frequency | 330 Hz | Base vertical trajectory rate. |
| Edit details | off | Opens terrain resolution, spatial and modulation controls, sample rate, Output peak, and Random seed. |
| Draw visualization | on | Draws the process-oriented terrain/path/QC display. |
| Play result | on | Plays the generated Sound after processing. |
Details page
| Control | Default | Meaning |
|---|---|---|
| Terrain size | 128 | Matrix resolution N×N; accepted range 8–512. |
| Terrain spatial scale | 1.0 | Scales spatial features inside the terrain equation; must be positive. |
| X / Y span | .8 / .8 | Fraction of terrain width/height traversed around the corresponding offset. |
| X / Y phase | 0° / 90° | Starting trajectory phase. |
| X / Y offset | .5 / .5 | Center position in normalized terrain coordinates. |
| X / Y phase-mod rate | 0 / 0 Hz | Separate modulation rates applied to X/Y trajectory phase. |
| Phase-mod index | .5 rad | Shared X/Y phase-modulation index β. |
| Sample rate | 44100 Hz | Direct synthesis/output rate; must be at least 4000 Hz. |
| Output peak | .95 | Final target peak normalization; accepted range >0…1. |
| Random seed | 0 | A 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:
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:
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:
The larger of these must remain below 45% of Sample rate.
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.
Output and level
| Property | Behavior |
|---|---|
| Input | No input Sound required. |
| Channels | Mono. |
| Duration | Exactly the requested Duration. |
| Sample rate | Exactly the Details-page Sample rate. |
| Raw signal | Bilinearly interpolated terrain height along the X/Y path. |
| DC treatment | Subtract mean is applied to the complete raw scan. |
| Normalization | If non-silent, the complete Sound is peak-scaled once to Output peak. This is target normalization, not a down-only ceiling. |
| Object name | waveTerrain_<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:
- terrain type, N×N size, and bilinear lookup;
- X waveform, base rate, and span;
- Y waveform, base rate, and span;
- shared phase-modulation index and the two modulation rates;
- raw terrain-height RMS and sample rate;
- measured final peak and RMS.