Stochastic Time Folding — User Guide
Iterative time-domain processing that alternates stochastically between recursive past/present/future folding and uniform amplitude scaling. Each pass uses a new temporal offset, while an adaptive probability threshold evolves across the sequence.
What this does
Stochastic Time Folding processes one selected Sound through a sequence of stochastic passes. Every pass draws a temporal offset and makes one probability decision for the complete Sound:
The FOLD branch combines the current sample with material ahead of it and with already-processed material behind it. Repeating this operation over several iterations creates a cumulative temporal diffusion whose geometry changes from pass to pass.
Quick start
- Select exactly one Sound object containing at least three samples.
- Run
Stochastic_Time_Folding.praat. - Choose Default, Gentle Folds, Aggressive Folds, Micro Glitch, or Custom.
- For Custom, set the iteration count, threshold behavior, fold-divisor range and amplitude range.
- Leave Debug_output enabled if you want per-pass peak/RMS diagnostics in the Info window.
- Run. The result is named
<source>_folded_<preset>.
One processing iteration
For iteration k, the script determines four values before applying any Sound Formula:
- the current adaptive threshold;
- one random fold divisor and its derived forward/backward distances;
- one random
probMaskin 0…1; - one random
iterAmpGainfrom the amplitude range.
The chosen branch is then applied across every channel and every sample of the Sound for that iteration.
Probability interpretation
Because probMask is uniformly distributed between 0 and 1, the current threshold is the probability that a given iteration will take the FOLD branch. For example, threshold 0.7 corresponds to a 70% FOLD probability for that pass.
FOLD branch
Let D be the forward distance, B the backward distance, and A the effective averaging divisor.
Where both temporal references are inside the Sound:
At samples where either reference would fall outside the Sound, the sample is left unchanged for that pass.
Recursive left-to-right behavior
Praat evaluates the Sound Formula from earlier samples toward later samples. Consequently:
- future[n+D] still contains the value from before that sample is processed in the current pass;
- processedPast[n−B] has already been modified by the current pass.
The backward path therefore creates a recursive within-pass cascade rather than a three-tap feed-forward average from a frozen snapshot.
Averaging divisor
Values below 3 therefore have the same effective DSP value of 3. Larger values attenuate the folded contribution more strongly.
AMP branch
The alternative branch applies one uniform gain to the complete Sound:
The same gain is used for all samples and channels during that iteration. Consecutive AMP passes therefore multiply their gains cumulatively.
The amplitude range is internally reordered when necessary, so reversed Custom minimum/maximum values remain valid.
Adaptive threshold evolution
The initial value is clamped to the canonicalized threshold limits:
From iteration 2 onward:
The threshold can therefore move upward or downward from one pass to the next. The limits themselves are sorted and clamped to the probability interval 0…1.
Fold distance
One divisor is drawn for every iteration:
The forward delay in seconds is approximately:
Because the form values are divisors, a smaller divisor produces a larger temporal offset and a larger divisor produces a shorter offset.
The distance pair is internally sorted, so reversed Custom minimum/maximum entries are accepted. Both forward and backward offsets are clamped to at least one sample.
Presets
| Preset | Iterations | Initial threshold | Variation | Limits | Fold divisors | Amplitude | Avg / Back div |
|---|---|---|---|---|---|---|---|
| Default | 6 | 0.50 | 0.20–0.20 | 0.10–0.90 | 3–12 | 0.70–1.20 | 3 / 2 |
| Gentle Folds | 4 | 0.40 | 0.10–0.15 | 0.15–0.85 | 5–15 | 0.90–1.10 | 3 / 2 |
| Aggressive Folds | 9 | 0.60 | 0.25–0.35 | 0.05–0.95 | 2–10 | 0.50–1.50 | 3 / 2 |
| Micro Glitch | 12 | 0.55 | 0.15–0.25 | 0.10–0.90 | 2–6 | 0.60–1.40 | 3 / 3 |
Named presets overwrite the processing values shown in this table. They do not overwrite Scale_peak, Debug_output, Draw_visualization, or Play_result.
Parameters & effective limits
| Parameter | Default | Exact behavior |
|---|---|---|
| Preset | Default | Default, Gentle, Aggressive, Micro Glitch, or Custom. |
| Fold_iterations | 6 | Natural number of complete-buffer stochastic passes. |
| Initial_threshold | 0.5 | Initial FOLD-branch probability, clamped to the effective threshold limits. |
| Threshold_var_min / max | 0.2 / 0.2 | Magnitude range for the random positive-or-negative threshold step. |
| Threshold_limit_min / max | 0.1 / 0.9 | Internally sorted and clamped to 0…1. |
| Fold_distance_min / max | 3 / 12 | Divisor range used to derive the per-iteration forward offset. |
| Amplitude_min / max | 0.7 / 1.2 | Uniform gain range for AMP iterations; internally sorted. |
| Fold_average_divisor | 3 | Division applied to the three-term FOLD sum; effective minimum is 3. |
| Fold_backward_divisor | 2 | Forward distance is divided by this value to derive the backward offset; result is at least one sample. |
| Scale_peak | 0.96 | Maximum final sample peak; the result is attenuated only when it exceeds this value. |
| Debug_output | On | Report branch, peak, RMS and gain change for every iteration. |
| Draw_visualization | On | Draw source/result waveforms, threshold evolution, fold distances and summary. |
| Play_result | On | Play the completed Sound. |
Channels, duration & sample rate
The selected Sound is copied directly and the Formula operates on its existing channel rows.
- Channel count: preserved.
- Duration: preserved.
- Sample rate: preserved.
- Time domain: preserved.
- Original Sound: unchanged.
The same per-iteration threshold, branch decision, fold distances and AMP gain are shared across all channels, while each channel's sample values are processed independently.
Final peak ceiling
After all iterations, the script measures the ordinary absolute sample extremum:
This is an attenuate-only safety ceiling, not target normalization. A result whose peak is below the default 0.96 remains below 0.96, so cumulative AMP attenuation remains audible.
Digital silence is left untouched.
Visualization
The v0.5 Picture view contains:
- Original waveform.
- Folded waveform.
- Threshold evolution — the actual threshold stored for each iteration.
- Fold distances — the actual forward distance in milliseconds selected for each iteration.
- Summary bar — preset, source, iterations, threshold limits, divisors, amplitude range and output name.
Waveform scale
The Original and Folded panels each use Praat's automatic waveform range. They are therefore not a shared-amplitude-scale comparison.
Threshold panel
The plotted points show the actual threshold values used by the stochastic branch decision. The dotted horizontal references represent the entered threshold-limit values.
Fold-distance panel
Each bar is the actual selected forward fold distance converted to milliseconds. The shorter backward distance is not drawn separately.
Output behavior
- Name:
<source>_folded_<preset>. - Duration: unchanged.
- Sample rate: unchanged.
- Channels: preserved.
- Randomness: threshold direction/magnitude, fold divisor, FOLD/AMP branch choice, and AMP gain.
- Random seed: no user control.
- Final level: attenuated only when peak exceeds Scale_peak.
- Playback: optional through Play_result.