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.

Author: Shai CohenAffiliation: Department of Music, Bar-Ilan University, IsraelLicense: MIT LicenseRepository: Praat AudioTools

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.

Processing chain
Input Sound → segment pool → candidate recompositions ↓ sound-based fitness evaluation ↓ selection → crossover → mutation ↓ best candidate + its seed ↓ reconstructed final Sound

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.

What evolves? The algorithm evolves a set of eight parameters for making a recomposition, not a symbolic musical score. Each candidate has its own segment sizes, ordering behavior, crossfade, and silence settings.

Quick start

  1. Open Praat and select one Sound object (speech, instrumental material, a texture, or a field recording).
  2. Choose Run script… and open Genetic_Recomposer.praat.
  3. Choose a Preset. For a first experiment, try Granular Shimmer or Subtle Texture.
  4. 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.
  5. Optionally set Random_seed to a positive integer if you want to repeat an experiment. Set it to 0 for a non-repeatable random starting point.
  6. Use Custom if you want the remaining form values to be used directly. For faster tests, start with a smaller population or fewer generations.
  7. Run the script. Praat reports each generation's minimum, average, and maximum fitness in the Info window.
  8. Find the final Sound in the Objects list, named GA_Recombine_ followed by the chosen preset name. It plays automatically when Play_result is enabled.
A useful first comparison: Run the same Sound with Subtle Texture, Glitch / Stutter, and Rhythmic Loops. These presets place very different weights on preserving spectral features, producing onsets, and creating recurring envelope patterns.
Processing is offline. Candidates are synthesized and analyzed during the search. There is no live audition of every individual or interactive playback from each generation. Longer outputs, larger populations, and more generations take more time.

Parameters and controls

Form parameterDefaultPurpose
PresetCustomChooses a musical profile and the weights used by the genetic search.
Target_duration_s8.0 sRequested final length; must be at least 0.2 s.
Effect_strength61–10. Scales the allowed segment-length, crossfade, and silence-probability ranges.
Pop_size10Number of candidate genomes evaluated in each generation (minimum 2).
Generations10Number of evaluation and evolution rounds (minimum 1).
Random_seed00 = non-repeatable starting point; positive integer = deterministic random initialization and generation, subject to Praat RNG compatibility.
Min_seg_ms20 msLower reference bound for segment lengths before effect-strength scaling.
Max_seg_ms180 msUpper reference bound for segment lengths before effect-strength scaling.
Max_crossfade_ms6 msUpper reference bound for crossfade length; effective overlaps can be reduced for safety.
Max_silence_prob0.25Upper reference bound for silence insertion probability (0–1); scaled by effect strength.
Draw_visualizationOnDraws source and result, evolution, best genome, segment map, and spectrogram.
Play_resultOnPlays 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.

Effective search bounds (strength = Effect_strength / 10): minimum segment = Min_seg_ms × (1 − 0.3 × strength) maximum segment = Max_seg_ms × (1 + 0.3 × strength) maximum crossfade = Max_crossfade_ms × (1 + 0.5 × strength) maximum silence probability = Max_silence_prob × strength

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.

PresetCharacter and suggested materialStrengthPopulation / generationsFitness emphasis
CustomUse the values entered in the form; useful for controlled experiments.Form valueForm valuesBalanced across three measures
Subtle TextureGentler rearrangement; drones, sustained tones, ambience.38 / 8Spectral similarity
Granular ShimmerActive yet relatively coherent granulation; voices, strings, piano.512 / 12Onsets and spectral similarity
Glitch / StutterAbrupt fragments and rhythmic interruption; percussion, speech.810 / 10Onset density
Extreme FragmentationDense, highly discontinuous recomposition; experimental sound design.1015 / 15Strongest onset emphasis
Rhythmic LoopsRecurrence in the amplitude envelope; phrases and pulse-based recordings.612 / 12Envelope regularity

The exact preset settings are:

PresetMax crossfadeMax silence probabilitySegment limits changed by preset?
CustomForm valueForm valueNo
Subtle Texture8 ms0.15No
Granular Shimmer12 ms0.20No
Glitch / Stutter3 ms0.45No
Extreme Fragmentation2 ms0.5010–80 ms
Rhythmic Loops8 ms0.1050–250 ms
What “Rhythmic Loops” means: the preset rewards periodic similarity in the intensity envelope. It does not detect meter, infer a beat grid, or guarantee seamless loops. It can nevertheless produce useful rhythmic repetition through segment reuse.

How the genetic algorithm works

  1. Initialization: Generate a population of eight-parameter genomes inside valid bounds.
  2. Synthesis: Build one candidate Sound from each genome using the same synthesis random seed within that generation.
  3. Evaluation: Measure all three fitness components for every candidate. Their weighted sum determines the candidate's score.
  4. Selection: Use two small tournaments to choose the parents of each offspring.
  5. Crossover: Each of the eight genes is inherited independently from one of the two parents (uniform crossover).
  6. Mutation and repair: Some genes receive Gaussian perturbations. Values are then clamped and linked minimum/maximum pairs are repaired.
  7. 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.
Interpreting the evolution graph: The best score within a generation need not improve every time. Random synthesis seeds differ between generations, and candidates are reevaluated. The script separately records the best-scoring candidate encountered overall and uses its genome and seed for the final output.

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

GeneMeaningMusical consequence
segMinMsMinimum segment length in the candidate's source poolSmaller values allow finer fragmentation.
segMaxMsMaximum segment lengthLarger values can preserve longer gestures.
segBiasLength-distribution bias (−0.8 to +0.8)Negative favors shorter segments; positive favors longer segments.
reorderProbProbability of drawing a random pool segment (0–1)Higher values increase jumps in the source order.
crossfadeMsRequested overlap at joinsControls transition softness, within safe bounds.
silenceProbProbability of inserting a rest after a segmentControls gaps, interruption, and density.
silenceMinMinimum inserted-silence lengthLower end of rest durations.
silenceMaxMaximum inserted-silence lengthUpper 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.

Fitness = w_onset × OnsetScore + w_spectral × SpectralSimilarity + w_regular × EnvelopeRegularity
PresetOnsetsSpectralRegularity
Custom0.340.330.33
Subtle Texture0.100.700.20
Granular Shimmer0.350.400.25
Glitch / Stutter0.700.100.20
Extreme Fragmentation0.800.050.15
Rhythmic Loops0.250.250.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.

What does a fitness of 0.8 mean? It means that this candidate scores highly under the current weighted measurements. It does not mean “80% musical quality,” and numbers from different presets are not directly comparable as general aesthetic judgments.

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:

PanelWhat it showsWhat to look for
Original waveformThe source Sound.Duration and amplitude pattern before recomposition.
GA ResultThe winning recomposition waveform.Events, silences, and the resulting dynamic shape.
EvolutionMinimum, mean, and maximum fitness across generations, plus the population spread.Whether the search finds occasional stronger candidates, and how much variation remains.
Best genomeNormalized bars for the eight genes.The transformation settings favored by selection.
Segment poolSource regions and how frequently they were reused in the result.Repeated fragments and underused source material.
Playback mapApproximate output position versus original source position; inserted silences are marked separately.Repetitions, changes of source order, and rests.
Result spectrogramTime-frequency view of the resulting Sound.Spectral changes and fragment boundaries.
SummaryWinning genome, fitness, weights, seed, and output duration.Information needed to compare and document runs.
Reading the playback map: It is a guide to the source material selected during recomposition. Joining segments with overlap can shift their actual sample-level onset positions, so the map should not be treated as sample-accurate timing data for crossfaded joins.

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

Input rejected as too short or silent. Use at least 0.07 s of meaningful audio. Very short clips may not provide enough material or valid intensity measurements. Entirely silent input cannot be meaningfully recomposed.
The result is much too fragmented. Try Subtle Texture, lower the strength using Custom, increase the minimum segment length, or reduce the silence probability. Bear in mind that presets override several form values.
The result sounds too much like the source. Try Glitch / Stutter or Extreme Fragmentation. For Custom, consider increasing effect strength or reducing segment length. A spectrum-preserving fitness objective can favor relatively familiar results.
The output is not rhythmically regular. Try Rhythmic Loops with material that has a clear amplitude pattern. The regularity measure detects envelope recurrence, not beat grids or guaranteed loop closure.
The process is too slow. Use Custom, lower Pop_size and Generations, and initially test a short target duration. Every candidate in every generation receives the full fitness evaluation.
A crossfade seems smaller than requested. This can be intentional: the script reduces overlap if a selected segment or silence is too short. Lower Max_crossfade_ms or allow longer segments for smoother transitions.
Fitness scores do not rise every generation. This is expected. Each generation uses a new synthesis seed, and the curve shows that generation's population, not only the best candidate ever found. The best-ever candidate is tracked independently.
Repeated runs are not identical. Verify a positive 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.
Warning about a synthesis iteration cap. Some genomes produced too few usable segments to reach the requested duration naturally, and were padded with trailing silence. Try a shorter crossfade or a wider segment range if the warning recurs.

Scope and limitations