Segment Mixer — Stereo Composite from Multiple Sounds

Creates stereo composites from multiple selected Sound objects. LEFT channel uses beginning segments, RIGHT channel uses end/offset/random segments. Supports multiple repeat cycles for longer compositions.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.2 (2025) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script creates stereo composite tracks from multiple selected Sound objects. For each source file, the script extracts a segment from the beginning and places it in the left channel. A second segment is extracted from the right channel source using one of three strategies: end of file, fixed offset, or random position. All segments are concatenated sequentially, with optional fading and attenuation, and the process can be repeated in cycles to build longer compositions.

Use case: Quickly assemble a stereo collage from a folder of sounds — left channel always starts from the beginning of each file, right channel draws from elsewhere. Perfect for creating ambient textures, soundscape compositions, or experimental stereo fields where the left-right relationship is deliberately asymmetric.

Key Features:

Processing pipeline: (1) Convert all selected sounds to mono, resample to common sample rate (first file's rate). (2) For each file in order, repeat for specified cycles. (3) Extract beginning segment for left channel. (4) Extract segment from right channel based on chosen strategy. (5) Apply attenuation (divide by divisor) and cosine fades at segment boundaries. (6) Concatenate to left/right buffers. (7) Combine to stereo, scale peak to 0.99.

Quick start

  1. In Praat, select multiple Sound objects (2 or more).
  2. Run script…Segment_Mixer.praat.
  3. Choose a preset from the dropdown (6 options).
  4. Or select "Custom" and adjust Segment_duration_s, Fade_time_s, Attenuation_divisor, Repeat_cycles.
  5. Select Right channel strategy (End / Offset / Random).
  6. If using Fixed offset, set Right_fixed_offset_s.
  7. Click OK — script processes all files and creates output stereo_mix_Nfiles_Xx.
Quick tip: Start with Stereo Spread preset (L=start, R=end) for dramatic stereo contrast. Quick Collage uses short segments (150 ms) for dense, granular textures. Slow Morph (500 ms segments, no attenuation) for smooth, gradual transitions. Enable Draw_visualization to see the colour-coded segment map — each source file gets a unique hue.
Important: Select at least two Sound objects before running. All sounds are converted to mono and resampled to the first sound's sample rate. Segment duration cannot exceed any source file's duration — if a file is shorter than segment_duration_s, the entire file is used. Fade time must be ≤ half of segment duration. The script concatenates segments without gaps — use fades to smooth transitions.

Right Channel Strategies

End of file Strategy 1

Extracts the last segment_duration_s seconds from each source file. If the file is shorter than the segment, extracts from 0.

Effect: Left channel = beginning, Right channel = ending. Creates a dramatic stereo contrast — start vs. finish of each sound.

Fixed offset Strategy 2

Extracts from offset seconds into the file. If offset + duration exceeds file length, offset is adjusted backwards.

Effect: Consistent offset across all files. Use for syncopation or aligning specific moments (e.g., 0.5s into each drum hit).

Random Strategy 3

Extracts from a uniformly random position within each file (where the segment fits).

Effect: Unpredictable, varied right channel content. Ideal for generative collages and experimental textures.

For each segment extraction:
  • Left: start = 0, end = min(segment_duration, file_duration)
  • Right (End): start = max(0, file_duration - segment_duration), end = file_duration
  • Right (Offset): start = min(offset, file_duration - segment_duration), end = start + segment_duration
  • Right (Random): start = uniform(0, max(0, file_duration - segment_duration)), end = start + segment_duration

6 Presets

PresetSegment (ms)Fade (ms)AttenuationCyclesRight strategyCharacter
Quick Collage150301.24RandomDense, granular texture from many short segments.
Slow Morph 5001001.0 (no atten)2EndSmooth, gradual transitions, preserves amplitude.
Random Scatter 200401.35RandomUnpredictable, scattered stereo field.
Stereo Spread 300501.13EndDramatic L=start / R=end contrast.
Dense Layers 100201.58RandomVery dense, highly attenuated, busy texture.
Custom useruseruseruseruserFull manual control.
Attenuation divisor: Each segment's amplitude is divided by this value. With 4 segments and divisor=1.2, the cumulative gain (if all segments aligned) would be 4×(1/1.2) ≈ 3.33 before scaling. The final output is peak-normalised to 0.99, so attenuation prevents clipping during concatenation.

Parameters

Core parameters

ParameterRangeDefaultDescription
Segment_duration_s>0, ≤ shortest file0.25Length of each extracted segment (seconds).
Fade_time_s >0, ≤ segment/20.05Cosine fade duration at segment boundaries (prevents clicks).
Attenuation_divisor ≥1.01.1Divide each segment's amplitude by this value to prevent clipping buildup.
Repeat_cycles ≥13Number of times to loop through all selected files.

Right channel parameters

ParameterOptions / RangeDescription
Right_part_strategy End of file / Fixed offset / RandomDetermines where to extract the right channel segment from each source file.
Right_fixed_offset_s ≥0For Fixed offset strategy, the start position in seconds.

Applications

Ambient / Soundscape Composition

Use case: Create evolving stereo textures from field recordings, synth pads, or drones.

Settings: Slow Morph preset (500 ms segments, End strategy, 2 cycles). Left channel = beginnings (attacks), right channel = endings (decays/releases).

Granular / Glitch Collage

Use case: Dense, stuttering textures from percussion or speech.

Settings: Quick Collage or Dense Layers (100–150 ms segments, Random strategy, 4–8 cycles). The short segments create a granular, pointillistic texture.

Stereo Contrast / Call-and-Response

Use case: Two different versions of the same material in left and right ears.

Settings: Stereo Spread preset. Left = starts, right = ends. Works well with spoken word (beginning vs. end of each sentence) or drum loops (attack vs. tail).

Generative / Algorithmic Composition

Use case: Randomly assembled compositions from a corpus of sounds.

Settings: Random Scatter preset (Random strategy). Each run produces a different stereo output because right channel positions are randomised. Use with a large selection of sounds for endless variation.

Workflow: Field recording collage

Source: 10–20 short field recordings (birds, water, footsteps, wind).
Settings: Random Scatter preset, segment=200 ms, cycles=3, attenuation=1.3.
Result: A dense, unpredictable stereo texture where each ear hears different moments from the same recordings. Great for installation or background ambience.

Workflow: Drum loop stereo widening

Source: Multiple drum loops (same tempo, different patterns).
Settings: Stereo Spread preset, segment=300 ms, cycles=2.
Result: Left channel = attack of each loop, right channel = decay/tail. Creates a wide, call-and-response stereo image.

Workflow: Voice → stutter / glitch

Source: Single spoken word recording (duplicated multiple times in Praat selection).
Settings: Quick Collage preset, segment=80 ms, cycles=8, Random strategy.
Result: The voice is chopped into tiny fragments and randomly rearranged in the right channel — classic glitch/stutter effect.

Troubleshooting:
Clicking between segments: Increase fade_time_s (ensure it's at least 10–20 ms). Cosine fades eliminate clicks.
Output is too quiet: Reduce attenuation_divisor (closer to 1.0) or increase segment duration. The script normalises peak to 0.99, so quiet output indicates sparse segments or low input levels.
Right channel sounds wrong / out of sync: Check strategy — End of file extracts the ending, which may sound very different from the beginning. Use Fixed offset with offset=0 for identical L/R content.
Files have different sample rates: The script resamples all sounds to match the first file's rate. This may affect pitch slightly.
Visualisation colours repeat: Colours are assigned by file index using a sine-wave hue mapping. With many files, colours may appear similar — the segment map still clearly shows segment order.

Visualization details

When Draw_visualization is enabled, the script generates a Praat picture with:
  • Output waveform: Stereo mix (blue curve)
  • Left channel segment map: Colour-coded bars, each bar = one segment. Colour indicates source file (hue cycles through files).
  • Right channel segment map: Same format, using the chosen strategy.
  • File legend: Colour swatches with file numbers.
  • Stats panel: Total segments, final duration, fade time.
The segment map is particularly useful for debugging — you can see exactly which file contributed to each segment and how the right channel positions differ.
```