Segment Mixer — Stereo Composite from Multiple Sounds
Builds a new stereo composite from multiple selected Sounds. Every source is converted to mono and brought to one working sample rate; the left channel takes a segment from the beginning of each file, while the right channel takes a segment from the end, a fixed offset, or a random legal position. The file sequence can be repeated for multiple cycles.
What this does
Segment Mixer creates two parallel mono montages from the same selected source set and then combines them into a stereo Sound:
Quick start
- Select at least two Sound objects.
- Run
Segment_Mixer.praat. - Choose Custom or one of the five named presets.
- Set segment duration, fade time, attenuation divisor and repeat cycles.
- Choose the right-channel strategy: End of file, Fixed offset, or Random.
- For Fixed offset, set the requested start position in seconds.
- Run the script. The result is a new stereo Sound.
Source preparation
Selection and processing order
The script stores the selected Sounds in Praat's selected#("Sound") array and processes that array from index 1 to N. Each repeat cycle traverses the same array in the same order.
Mono working copies
Every selected Sound is copied. Sources with more than one channel are converted to mono; mono sources remain mono working copies.
Common sample rate
The working sample rate is the sampling frequency of the first Sound in the stored selection array:
Every other working Sound whose sample rate differs is resampled to targetSR with Praat precision 50.
Zero-based internal domains
After mono conversion/resampling, every private working Sound is shifted so its start time is 0. This makes all extraction coordinates literal 0…duration seconds even when an original Sound had a non-zero xmin.
Left and right extraction
For each file and each cycle, the effective extracted duration is:
A source shorter than the requested segment therefore contributes its entire duration.
Left channel
The left channel always uses the beginning of each source.
Right strategy 1 — End of file
Because extractDuration never exceeds the file duration, this is the final legal segment of the source.
Right strategy 2 — Fixed offset
The requested offset is used when the full segment fits. Otherwise it is moved backward to the final legal start position:
This means a fixed offset beyond the usable range does not shorten the segment; it becomes the last full legal segment instead.
Right strategy 3 — Random
Attenuation & segment-edge fades
Attenuation divisor
Both left and right excerpts first receive:
The form requires only a positive divisor:
- divisor > 1 attenuates;
- divisor = 1 leaves gain unchanged;
- 0 < divisor < 1 amplifies.
Effective fade duration
The public Fade_time_s must be positive and cannot exceed half the requested Segment_duration_s. A shorter source can still produce a shorter extracted segment, so the script applies a second per-segment clamp:
The fade is linear, not cosine
Each extracted segment receives two multiplicative ramps:
They are linear amplitude ramps. The segment begins at zero, reaches unity after the effective fade-in, and falls to zero over the final effective fade.
Repeat cycles & ordering
The main renderer is nested:
Total segment positions per channel are therefore:
The source-file order itself is not shuffled between cycles. The sequence repeats exactly; only Random right-channel extraction can choose different source positions on later cycles.
Five named presets + Custom
| Preset | Segment | Fade | Divisor | Cycles | Right strategy | Fixed offset |
|---|---|---|---|---|---|---|
| Quick Collage | 150 ms | 30 ms | 1.2 | 4 | Random | 0.10 s |
| Slow Morph | 500 ms | 100 ms | 1.0 | 2 | End | 0.10 s |
| Random Scatter | 200 ms | 40 ms | 1.3 | 5 | Random | 0.10 s |
| Stereo Spread | 300 ms | 50 ms | 1.1 | 3 | End | 0.10 s |
| Dense Layers | 100 ms | 20 ms | 1.5 | 8 | Random | 0.10 s |
| Custom defaults | 250 ms | 50 ms | 1.1 | 3 | End | 0.10 s |
Parameters & limits
| Parameter | Default | Exact behavior |
|---|---|---|
| Preset | Custom | Custom plus five named configurations. |
| Segment_duration_s | 0.25 | Positive requested segment duration. Shorter files contribute their whole duration. |
| Fade_time_s | 0.05 | Must be >0 and <= requested segment duration / 2; further clamped to half the actual extracted duration. |
| Attenuation_divisor | 1.1 | Any positive value. Divides every L/R segment before fades. |
| Repeat_cycles | 3 | Integer >=1. |
| Right_part_strategy | End of file | End, Fixed offset, or Random. |
| Right_fixed_offset_s | 0.10 | Must be >=0 only when Fixed offset is active. |
| Draw_visualization | On | Draw L/R segment maps, stereo output waveform, file legend and summary. |
| Play_result | On | Play the final stereo Sound. |
Output duration
Left and right always use the same extractDuration for a given file occurrence, so their assembled durations match.
This is the intended temporal construction, subject only to sample-grid rounding in extraction/concatenation.
Final peak safety
After the two complete mono sequences are combined into stereo, the script measures the Sinc70 absolute extremum across the result.
This is an attenuate-only safety ceiling, not target normalization. A mix peaking at 0.40 remains at 0.40. A mix peaking above 0.99 is globally attenuated to the 0.99 target.
Visualization
The v0.4.4 Picture view contains five functional regions:
- Left segment map: one colored bar per rendered segment occurrence; file identity determines the bar color.
- Right segment map: same file identity colors, with the actual chosen R strategy positions.
- Output stereo waveform: L and R are extracted and drawn explicitly as separate mono plots on one shared amplitude scale.
- File legend: color swatches with display-sanitized source names.
- Summary: preset, file/cycle/segment counts, right strategy, segment/fade settings, attenuation divisor, target sample rate, output duration and RMS.
Reading the segment maps
Color identifies the source file. Inside every colored segment bar, a neutral horizontal tick shows the normalized midpoint of the extracted source region:
The left map therefore places all ticks near the file starts; the right map reveals End, Offset, or the actual Random positions selected during rendering. Light vertical dividers mark cycle boundaries.
Waveform scale
The final L and R waveform panels share the same amplitude range, derived from the larger of their two sample peaks with 8% headroom. Their displayed levels are directly comparable.
Output behavior
- Name:
stereo_mix_<N>files_<C>x_<preset>_<strategy>. - Channels: always stereo.
- Source channels: all selected inputs are folded to mono before extraction.
- Sample rate: first working Sound's sample rate.
- Joins: sequential butt concatenation of individually edge-faded segments; no overlap.
- Randomness: only the Random right strategy; no user seed.
- Final gain: attenuate-only Sinc70 ceiling at 0.99.
- Original Sounds: unchanged and re-selected together with the result at the end.