Genetic Recomposer — User Guide
An offline evolutionary audio-recomposition tool that searches for ways to segment, rearrange, crossfade, and punctuate a source recording. A genetic algorithm selects the most promising results according to measurable onset activity, spectral resemblance, and rhythmic-envelope regularity.
What this tool does
Genetic Recomposer uses the selected Praat Sound as a pool of reusable sound segments. Each candidate result is built by selecting segments from that pool, optionally changing their order, inserting short silences, and joining them with crossfades. Unlike a fixed-effect processor, the tool evaluates many candidate recompositions and evolves the parameters used to make them.
The generated audio comes from real segments of the source. It is not instrument recognition, note transcription, neural audio synthesis, or a system that learns musical form in the human sense. Genetic selection seeks higher numerical fitness under the chosen preset; it does not guarantee an aesthetically superior result.
Quick start
- Open Praat and select one Sound object (speech, instrumental material, a texture, or a field recording).
- Choose Run script… and open
Genetic_Recomposer.praat. - Choose a Preset. For a first experiment, try Granular Shimmer or Subtle Texture.
- Set
Target_duration_s(default 8.0 seconds). With a preset selected, its own strength, population, generation, and texture settings take precedence over the corresponding form entries. - Optionally set
Random_seedto a positive integer if you want to repeat an experiment. Set it to0for a non-repeatable random starting point. - Use Custom if you want the remaining form values to be used directly. For faster tests, start with a smaller population or fewer generations.
- Run the script. Praat reports each generation's minimum, average, and maximum fitness in the Info window.
- Find the final Sound in the Objects list, named
GA_Recombine_followed by the chosen preset name. It plays automatically whenPlay_resultis enabled.
Parameters and controls
| Form parameter | Default | Purpose |
|---|---|---|
Preset | Custom | Chooses a musical profile and the weights used by the genetic search. |
Target_duration_s | 8.0 s | Requested final length; must be at least 0.2 s. |
Effect_strength | 6 | 1–10. Scales the allowed segment-length, crossfade, and silence-probability ranges. |
Pop_size | 10 | Number of candidate genomes evaluated in each generation (minimum 2). |
Generations | 10 | Number of evaluation and evolution rounds (minimum 1). |
Random_seed | 0 | 0 = non-repeatable starting point; positive integer = deterministic random initialization and generation, subject to Praat RNG compatibility. |
Min_seg_ms | 20 ms | Lower reference bound for segment lengths before effect-strength scaling. |
Max_seg_ms | 180 ms | Upper reference bound for segment lengths before effect-strength scaling. |
Max_crossfade_ms | 6 ms | Upper reference bound for crossfade length; effective overlaps can be reduced for safety. |
Max_silence_prob | 0.25 | Upper reference bound for silence insertion probability (0–1); scaled by effect strength. |
Draw_visualization | On | Draws source and result, evolution, best genome, segment map, and spectrogram. |
Play_result | On | Plays the finished Sound after processing. |
Preset precedence: Presets set their own effect strength, population, generation count, crossfade limit, silence-probability limit, and fitness weights. Some also set segment limits. Target_duration_s, Random_seed, visualization, and playback remain independently configurable. Use Custom when you need direct control of all the exposed numerical settings.
Each genome samples and evolves values within these effective ranges. Therefore the parameters displayed in the form are not necessarily the exact values used by the winning recomposition; check the Info window or the genome visualization for those.
Preset styles
Presets provide different musical goals by changing both the transformation ranges and the relative importance of the three fitness measures.
| Preset | Character and suggested material | Strength | Population / generations | Fitness emphasis |
|---|---|---|---|---|
| Custom | Use the values entered in the form; useful for controlled experiments. | Form value | Form values | Balanced across three measures |
| Subtle Texture | Gentler rearrangement; drones, sustained tones, ambience. | 3 | 8 / 8 | Spectral similarity |
| Granular Shimmer | Active yet relatively coherent granulation; voices, strings, piano. | 5 | 12 / 12 | Onsets and spectral similarity |
| Glitch / Stutter | Abrupt fragments and rhythmic interruption; percussion, speech. | 8 | 10 / 10 | Onset density |
| Extreme Fragmentation | Dense, highly discontinuous recomposition; experimental sound design. | 10 | 15 / 15 | Strongest onset emphasis |
| Rhythmic Loops | Recurrence in the amplitude envelope; phrases and pulse-based recordings. | 6 | 12 / 12 | Envelope regularity |
The exact preset settings are:
| Preset | Max crossfade | Max silence probability | Segment limits changed by preset? |
|---|---|---|---|
| Custom | Form value | Form value | No |
| Subtle Texture | 8 ms | 0.15 | No |
| Granular Shimmer | 12 ms | 0.20 | No |
| Glitch / Stutter | 3 ms | 0.45 | No |
| Extreme Fragmentation | 2 ms | 0.50 | 10–80 ms |
| Rhythmic Loops | 8 ms | 0.10 | 50–250 ms |
How the genetic algorithm works
- Initialization: Generate a population of eight-parameter genomes inside valid bounds.
- Synthesis: Build one candidate Sound from each genome using the same synthesis random seed within that generation.
- Evaluation: Measure all three fitness components for every candidate. Their weighted sum determines the candidate's score.
- Selection: Use two small tournaments to choose the parents of each offspring.
- Crossover: Each of the eight genes is inherited independently from one of the two parents (uniform crossover).
- Mutation and repair: Some genes receive Gaussian perturbations. Values are then clamped and linked minimum/maximum pairs are repaired.
- Best-ever retention: Keep the strongest genome and its synthesis seed encountered during the search. The next generation also receives that genome, and the final audio is regenerated with its recorded seed.
The algorithm uses a fixed internal mutation probability of 0.15 per gene. This is an implementation detail, not a user-adjustable form control. There is likewise no form control for an independent elite count.
The eight-gene genome
| Gene | Meaning | Musical consequence |
|---|---|---|
segMinMs | Minimum segment length in the candidate's source pool | Smaller values allow finer fragmentation. |
segMaxMs | Maximum segment length | Larger values can preserve longer gestures. |
segBias | Length-distribution bias (−0.8 to +0.8) | Negative favors shorter segments; positive favors longer segments. |
reorderProb | Probability of drawing a random pool segment (0–1) | Higher values increase jumps in the source order. |
crossfadeMs | Requested overlap at joins | Controls transition softness, within safe bounds. |
silenceProb | Probability of inserting a rest after a segment | Controls gaps, interruption, and density. |
silenceMin | Minimum inserted-silence length | Lower end of rest durations. |
silenceMax | Maximum inserted-silence length | Upper end of rest durations. |
Segment choices
A genome creates a pool of consecutive source segments whose durations follow its minimum, maximum, and bias settings. To build the output, the script repeatedly selects from this pool until the target length is reached. Segments can be reused as often as needed.
At reorderProb = 0, selection follows the pool sequentially (after a randomly chosen starting segment), wrapping around if necessary. As the value rises, local jumps increase and there is a growing probability of drawing an unrelated segment. Thus a high value means more randomized selection, not a literal percentage of output segments that have been swapped.
Silence and crossfades
Silence insertion is optional for each selected segment. The script evolves both the probability of a rest and its duration limits. The genome's actual silence lengths are constrained by internal bounds.
When the segments are joined, Praat uses Concatenate with overlap where a usable crossfade is available. The requested overlap may be shortened to fit the shortest included part. Very short or non-overlapping joins use brief edge fades where appropriate. The final sound is trimmed or padded to the target length, given a short start/end fade, and peak-scaled to 0.95.
Requested versus applied crossfade: the winning genome reports its requested crossfade; actual overlap can be smaller because of short segments or inserted silence. Do not interpret the reported genome parameter as a sample-accurate record of every join.
How fitness is measured
Every candidate is evaluated with all three measures below. Higher scores indicate better agreement with the selected preset's numerical goals. Each component is limited to 0–1, and preset weights sum to 1.
| Preset | Onsets | Spectral | Regularity |
|---|---|---|---|
| Custom | 0.34 | 0.33 | 0.33 |
| Subtle Texture | 0.10 | 0.70 | 0.20 |
| Granular Shimmer | 0.35 | 0.40 | 0.25 |
| Glitch / Stutter | 0.70 | 0.10 | 0.20 |
| Extreme Fragmentation | 0.80 | 0.05 | 0.15 |
| Rhythmic Loops | 0.25 | 0.25 | 0.50 |
1. Onset density
Praat measures an intensity envelope for the candidate. A frame counts as a detected event when its intensity increases by at least 3.5 dB compared with the previous frame and passes a noise floor defined relative to that candidate's own maximum intensity. The onset count is divided by output duration.
The resulting rate is scaled by a preset-dependent saturation threshold: 8 + 32 × w_onset onsets per second, then clipped to 1. Consequently, a preset strongly emphasizing onset density demands a higher event rate for the maximum score.
2. Spectral similarity
The input and each candidate are divided into six equal-duration analysis regions. In each active region, the script compares spectral centroid and spectral spread. Differences are normalized relative to the source values and combined across regions into a similarity score.
Near-silent regions are handled separately: a quiet region on both sides counts as a match; a quiet region on only one side counts as a mismatch. This avoids treating meaningless spectral measurements from silence as reliable evidence.
Because the input and output can have different durations, the six-region comparison reflects their relative progress through time. It is not a note-by-note or beat-aligned similarity test.
3. Envelope regularity
The script computes normalized autocorrelation of the candidate's intensity envelope at several delays derived from that genome's typical segment duration. It uses the strongest positive correlation as its regularity score. High values suggest repeated envelope patterns; they do not, by themselves, establish musical meter or phrasing.
Audio and stereo handling
The script preserves the source's audio channels when extracting and reassembling segments. It does not automatically turn mono recordings into synthetic stereo.
For analysis only, multichannel material is normally downmixed to mono. If that mix loses more than about 20 dB relative to the strongest individual channel (for example, because two channels have opposing phase), the script instead analyzes the strongest channel. The same analysis-channel decision is used when evaluating candidates. This prevents accidental phase cancellation from making all fitness scores uninformative.
Very quiet or empty source material is not suitable for the search. Praat rejects sources shorter than 0.07 s or effectively silent sources before running the genetic algorithm.
Reading the visualization
With Draw_visualization enabled, Praat draws a multi-panel overview:
| Panel | What it shows | What to look for |
|---|---|---|
| Original waveform | The source Sound. | Duration and amplitude pattern before recomposition. |
| GA Result | The winning recomposition waveform. | Events, silences, and the resulting dynamic shape. |
| Evolution | Minimum, mean, and maximum fitness across generations, plus the population spread. | Whether the search finds occasional stronger candidates, and how much variation remains. |
| Best genome | Normalized bars for the eight genes. | The transformation settings favored by selection. |
| Segment pool | Source regions and how frequently they were reused in the result. | Repeated fragments and underused source material. |
| Playback map | Approximate output position versus original source position; inserted silences are marked separately. | Repetitions, changes of source order, and rests. |
| Result spectrogram | Time-frequency view of the resulting Sound. | Spectral changes and fragment boundaries. |
| Summary | Winning genome, fitness, weights, seed, and output duration. | Information needed to compare and document runs. |
To retain the picture, use Praat's Picture-window export functions after the visualization has been drawn.
Musical applications
Subtle transformation of a drone
Start with Subtle Texture on a sustained instrumental tone or ambience. The strong spectral weight encourages recombinations that remain relatively close to the input's overall spectral trajectory while introducing new internal motion.
Glitch from speech or percussion
Try Glitch / Stutter for a high-onset result. Use Extreme Fragmentation when you want a more discontinuous material pool and more aggressive event-density selection.
Recurrent pulse from a phrase
Try Rhythmic Loops on clearly articulated phrases or percussion. Inspect whether the candidate exhibits recurring amplitude-envelope patterns; the results may be rhythmic without following the source's original beat structure.
Controlled comparisons
Use Custom and a positive Random_seed to compare settings in a reproducible setup. Change one control at a time and save promising output Sounds for later arrangement in your DAW.
Troubleshooting
Pop_size and Generations, and initially test a short target duration. Every candidate in every generation receives the full fitness evaluation.Max_crossfade_ms or allow longer segments for smoother transitions.Random_seed, the same Sound, the same parameters, and a compatible up-to-date Praat installation. With a seed of 0 the initialization is intentionally unpredictable.Scope and limitations
- One source recording: the tool recombines segments of the selected Sound rather than combining multiple source files.
- Sound-based objectives: fitness measures onset density, spectral resemblance, and amplitude-envelope regularity. It does not explicitly evaluate phrasing, harmonic logic, tension, expression, or listener preference.
- Stochastic search: the winning score refers to a particular genome and synthesis seed. A high-scoring genome is not guaranteed to perform equally well under every possible random realization.
- Fixed-duration output: material is repeated, trimmed, or padded as needed to achieve the target duration. It need not preserve source chronology or original rhythm.
- No change to pitch or sample rate: there is no explicit time-stretch, phase-vocoder, pitch-shift, or spectral-generation stage.