Waveguide & Modal Synthesis — User Guide
Six compact synthesis models: two fractional-delay feedback loops and four explicit modal banks. A shared envelope stage, optional melody demo, reproducible random seed, one final normalization stage, and a process-oriented visualization make the synthesis mechanism directly inspectable.
What this does
The script generates a new mono Sound; no input Sound is required. The six model choices are deliberately explicit rather than attempts to reproduce complete acoustic instruments.
windowed random initial state → compensated fractional delay → two-sample loss averaging → damping feedback → optional continuous breath drive → envelope → short boundary tapers → final normalization
Modal path:
fixed mode-frequency template → damped sinusoidal mode sum → envelope → short boundary tapers → final normalization
The selected Damping control affects the two families differently: in waveguide models it is the loop-feedback multiplier; in modal models it controls a common decay-rate scale applied to every modal template.
Quick start
- Choose one of the six synthesis methods.
- Leave Melody demo off for one note, or enable it for the built-in eight-note phrase.
- For a single note, set Frequency and Duration.
- Set Damping and choose one of the ten envelope modes.
- Use Edit details for Sample rate, Envelope amount, Output peak, and Random seed.
- Run the script. The output is generated offline and optionally visualized and played.
Waveguide models
Both waveguide modes use the same fractional-delay feedback structure. The target period in samples is:
Fractional-delay loop
Dline = Dtarget - 0.5
N = floor(Dline)
frac = Dline - N
loop[n] = 0.5 × [(1-frac)y[n-N] + y[n-N-1] + frac·y[n-N-2]]
y[n] = Damping × loop[n] + drive[n]
The -0.5-sample compensation offsets the approximate half-sample phase delay contributed by the two-point loss averaging. Fractional interpolation then avoids restricting the pitch to integer delay lengths.
1 — Waveguide: Plucked String
Finite initial excitation Waveguide
The delay line is initialized with random values multiplied by a sin² window across the seed region. After that initial state, drive[n] = 0; the sound evolves only through the damped feedback loop.
2 — Waveguide: Breath-driven Loop
Continuously driven loop Waveguide
The same windowed random initial state is used, but each later sample also receives a small independent random drive:
This keeps injecting broadband energy into the resonant loop. It is a generic breath-driven feedback model, not a complete pipe or reed simulation.
Modal models
Modal methods directly sum damped sinusoids. For mode m:
decayScale = (1 - Damping) × 500
dm = decayTemplate[m] × decayScale
mode[m](t) = amplitude[m] × sin(2π fm t) × exp(-dm t)
Higher Damping values therefore produce smaller decay exponents and longer modal persistence. Each model uses a fixed ratio/amplitude/decay template:
3 — Modal: Bell-like Inharmonic
Six-mode inharmonic bank Modal
| Ratio | Amplitude | Decay template |
|---|---|---|
| 1.000 | 1.000 | 0.500 |
| 2.143 | 0.700 | 3.000 |
| 3.413 | 0.500 | 6.000 |
| 4.090 | 0.300 | 10.000 |
| 5.190 | 0.150 | 15.000 |
| 6.250 | 0.080 | 20.000 |
4 — Modal: Plucked String
Eight near-harmonic modes Modal
| Ratio | Amplitude | Decay template |
|---|---|---|
| 1.000 | 1.000 | 0.300 |
| 2.001 | 0.500 | 0.800 |
| 3.004 | 0.333 | 1.500 |
| 4.010 | 0.250 | 2.500 |
| 5.020 | 0.200 | 4.000 |
| 6.035 | 0.167 | 6.000 |
| 7.055 | 0.143 | 8.500 |
| 8.080 | 0.125 | 12.000 |
5 — Modal: Struck Bar
Five strongly inharmonic modes Modal
| Ratio | Amplitude | Decay template |
|---|---|---|
| 1.000 | 1.000 | 0.400 |
| 2.756 | 0.600 | 2.000 |
| 5.404 | 0.350 | 5.000 |
| 8.933 | 0.200 | 10.000 |
| 13.344 | 0.100 | 18.000 |
6 — Modal: Circular Membrane
Five membrane-like ratios Modal
| Ratio | Amplitude | Decay template |
|---|---|---|
| 1.000 | 1.000 | 0.200 |
| 1.593 | 0.700 | 0.800 |
| 2.135 | 0.500 | 1.800 |
| 2.296 | 0.400 | 3.000 |
| 2.917 | 0.300 | 5.000 |
Envelope shapers
The selected envelope is applied after the waveguide or modal model. Envelope amount affects the parameterized envelopes but does not change the underlying synthesis model.
| Envelope | Implementation |
|---|---|
| No Envelope | No additional envelope multiplication. The universal anti-click note-boundary tapers still apply. |
| Percussive | exp(-rate·t), where rate = 3 + 8·amount. |
| Slow Decay | exp(-rate·t), where rate = 0.15 + 0.8·amount. |
| Smooth Gate | Repeated sin² gate pulses, rate 2 + 10·amount Hz, duty 0.65. |
| Reverse Ramp | Monotonic half-cosine rise: 0.5 - 0.5 cos(πt/duration). |
| Tremolo | Rate 4 + 12·amount Hz; depth 0.2 + 0.7·amount; modulation stays non-negative. |
| Swell | sin²(πt/duration): zero at both ends, maximum at the midpoint. |
| ADSR | Attack ≤30 ms, decay ≤150 ms, release ≤200 ms; each is also scaled to short notes. Sustain = 0.45 + 0.40·amount. |
| Smooth Stutter | Repeated sin² pulses, rate 6 + 24·amount Hz, duty 0.55. |
| Random Bursts | Poisson events at density 2 + 12·amount events/s. Each event receives a random 0.45–1.0 amplitude and a raised-cosine burst window. |
Universal note-boundary taper
After the selected envelope, every note receives a short raised-cosine fade-in and fade-out:
This is separate from the user-selectable envelope and is always applied.
Melody demo
Melody demo ignores the Single-note Frequency and Duration controls and renders this fixed eight-note sequence with the currently selected model, Damping, Envelope, Details settings, and seed:
| Frequency | Duration |
|---|---|
| 261.63 Hz | 0.4 s |
| 329.63 Hz | 0.4 s |
| 392.00 Hz | 0.4 s |
| 523.25 Hz | 0.6 s |
| 392.00 Hz | 0.4 s |
| 329.63 Hz | 0.4 s |
| 261.63 Hz | 0.4 s |
| 196.00 Hz | 0.8 s |
Total duration is 3.8 s. Every note is generated and tapered separately, the eight Sounds are concatenated, and only then is one final peak normalization applied. There is no per-note normalization.
Controls
Main page
| Control | Default | Meaning |
|---|---|---|
| Method | Modal: Plucked String | One of two waveguide or four modal models. |
| Melody demo | off | Off = one note; on = fixed 3.8 s eight-note phrase. |
| Frequency | 220 Hz | Single-note fundamental. Ignored by Melody demo. |
| Duration | 2.0 s | Single-note duration. Ignored by Melody demo. |
| Damping | 0.998 | Validated range 0.9–0.9999. Waveguide feedback gain or modal decay-scale control. |
| Envelope | No Envelope | One of ten post-model amplitude shapers. |
| Edit details | off | Opens sample-rate, envelope amount, output peak, and seed controls. |
| Draw visualization | on | Draws the model/decay/spectral/output diagnostic view. |
| Play result | on | Plays the final normalized Sound. |
Details page
| Control | Default | Meaning |
|---|---|---|
| Sample rate | 44100 Hz | Direct generation rate; accepted range 8000–192000 Hz. |
| Envelope amount | 0.30 | Shared 0…1 depth/rate control used by parameterized envelopes. |
| Output peak | 0.95 | Final target peak normalization; valid >0…1. |
| Random seed | 0 | Positive = initialize Praat's RNG predictably; 0 = do not replace the current RNG state with a fixed seed. |
Validation and workload guards
Sample-rate range
Waveguide period guard
For the two waveguide models:
In Single-note mode, highestFundamental is the requested Frequency. In Melody demo it is 523.25 Hz.
Modal Nyquist guard
For modal methods, the highest template mode must remain below 95% of Nyquist:
The maximum ratios are 6.250 (Bell), 8.080 (Modal Plucked String), 13.344 (Struck Bar), and 2.917 (Circular Membrane).
Single-note workload guard — v1.1.2
Version 1.1.2 adds a render-size limit before Single-note generation:
renderedSamples ≤ 5,000,000
If the requested render exceeds this limit, the script stops and reports the maximum permitted Duration for the selected Sample rate. Melody demo is fixed at 3.8 seconds and is not subject to this additional size check.
Randomness and reproducibility
Randomness is used by:
- the initial delay-line state of both waveguide models;
- the continuous noise drive of Breath-driven Loop;
- the Poisson event times and random event amplitudes of Random Bursts.
The four modal models are deterministic when a deterministic envelope is selected. Random Bursts makes any model stochastic.
With Random seed > 0, the script initializes Praat's random generator predictably before synthesis. Repeating the same model and settings with the same positive seed reproduces the script's random sequence. With seed 0, the current RNG state is used.
Output and normalization
| Property | Behavior |
|---|---|
| Input | No input Sound required. |
| Channels | Mono. |
| Single-note duration | Requested Duration. |
| Melody duration | 3.8 s. |
| Sample rate | Details-page Sample rate. |
| Single-note name | <method_name>_<rounded frequency>Hz. |
| Melody name | <method_name>_melody. |
| Normalization | One unconditional target-peak operation on a non-silent final result: Scale peak: OutputPeak. |
There is no per-note normalization in Melody demo. The single final gain factor therefore preserves the relative levels created by the model, envelope, and note sequence.
Visualization and QC
The visualization compares the model's internal prediction with measurements from the generated Sound. For Melody demo, the first 261.63 Hz / 0.4 s note is used as the representative analysis note; Single-note mode uses the requested note.
Process strip
Waveguide methods show noise excitation → fractional delay → two-sample loss → damping feedback → envelope → output. Modal methods show impulse-like excitation → modal frequency bank → per-mode decay → envelope → summed output.
A — Model structure
- Waveguide: a loop diagram labels target period, integer + fractional delay, the
0.5(1+z^-1)loss stage, and Damping. - Modal: a time/frequency score draws every template mode; line thickness follows template amplitude and line length follows predicted T60, limited to the representative note duration.
B — Predicted decay
- Waveguide: the plot estimates loop decay from Damping, the two-sample averaging magnitude, and the fractional interpolation magnitude at F0.
- Modal: every template mode is plotted from its explicit exponential decay law.
C — Expected resonances vs measured spectrum
A Spectrum is measured from the representative generated note. Blue circles show the model template; red stems show measured magnitudes at the corresponding frequencies. Waveguides use the first eight harmonic locations; modal models use their exact ratio sets.
D — Measured output
The final normalized waveform is drawn over the complete output duration.
QC strip
The QC rows report model, representative F0, Sample rate, Damping, Envelope, target waveguide period or modal count/max ratio, Nyquist, and measured final Peak/RMS.