Dramaturgical Structure Composer — User Guide

Section-level algorithmic recomposition for fixed-media sound. The script detects structural sections from spectral novelty, classifies their broad texture, reorganizes them with form archetypes, and can add looping, silence, time stretching, transformed recalls, texture-aware crossfades, and a macro tension arc.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 5.4.1 (2026) License: MIT License Repo: Praat AudioTools
Contents:

What this does

Dramaturgical Structure Composer works at the level of musical form rather than as a continuous audio effect. It first partitions the source into sections, measures each section, constructs a new formal order, optionally inserts structural operations, and then assembles the resulting timeline.

The source material itself remains recognizable in ordinary reordered sections. More substantial changes occur only where an operation explicitly transforms content — principally time stretching and material recall. The overall result can therefore range from a lightly reorganized version of the input to a strongly recomposed structure.

Input channels are preserved. Analysis uses a mono fold where Praat requires mono analysis, but the actual sections are extracted from the original Sound. Stereo and other multichannel inputs retain their channel structure through reordering, recall, silence insertion, and channel-by-channel time stretching.

What does “dramaturgical” mean here?

In this tool, dramaturgy means shaping large-scale relationships between sections: accumulation, contrast, recurrence, interruption, return, climax, and release. The script does not claim to infer a narrative meaning from the recording. Instead, it converts measurable properties — loudness, spectral centroid, harmonicity, and section boundaries — into formal decisions.

The structural idea is:
source analysis → section identities → form archetype → optional operations → output timeline.

Quick start

  1. Select exactly one Sound object. The input must be at least 20 seconds long.
  2. Run Dramaturgical_Structure_Composer.praat.
  3. Set the section-duration range and the relative Novelty_threshold.
  4. Choose a Strategy: Conservative, Dramatic, or Radical.
  5. Choose a Reorder_mode: None, Arch, Contrast, Rondo, Narrative, or Random swap.
  6. Choose Fixed or Texture-aware crossfades and Digital zero or Noise tail silence.
  7. Enable or disable looping, long silence, time stretching, material recall, and the tension arc.
  8. Optionally enter a positive Random_seed for a reproducible stochastic run. A value of 0 uses an unpredictable seed.
  9. Run the script. The result is named <source>_dramat_<Strategy>_<Reorder>.

Section detection

The current script uses spectral novelty only to create section boundaries. It does not run a separate silence detector.

Novelty curve

A mono analysis copy is converted to a spectrogram up to min(5000 Hz, Nyquist). Every 0.1 seconds, the script samples 100 frequency bins and compares the current frame with the previous one in the log-power domain:

novelty[i] = mean over 100 bins of | ln(P_i + 1e-10) - ln(P_(i-1) + 1e-10) | normalizedNovelty[i] = novelty[i] / peak(novelty)

Novelty_threshold therefore operates on a relative 0–1 curve, not on absolute spectral power. A boundary is accepted only at a local novelty maximum above the threshold and only when it is more than Min_section_duration_s from the preceding accepted boundary.

Minimum and maximum duration

A final novelty boundary is removed if it would leave an ending fragment shorter than the minimum duration. Long spans are then split so that the entire source remains covered. The script aims to keep every piece at or below Max_section_duration_s, but the minimum duration wins when the two constraints conflict.

Up to 200 detected sections are supported. If that cap is reached, the script reports it rather than silently discarding source material.

Texture classification

Each detected section is measured on a mono analysis copy. The stored audio section itself remains in the original channel format.

FeatureMeasurement
Spectral centroidPraat Spectrum Get centre of gravity: 2.
HarmonicityTo Harmonicity (cc), 75 Hz floor; mean HNR in dB.
RMSRoot-mean-square level of the section.

Classification is hierarchical: the first matching rule wins.

ClassRule
TonalMean HNR > Harmonicity_threshold_dB (default 5 dB).
QuietRMS < 12% of the loudest detected section.
BrightCentroid above the effective high threshold.
DarkCentroid below the effective low threshold.
MidNone of the previous rules matched.

The nominal centroid thresholds are 500 Hz and 3000 Hz, but they are automatically reduced for low sample rates so they remain meaningful below Nyquist.

Texture distance

The Contrast archetype uses a distance that combines category difference, centroid difference, and RMS difference:

distance = 0.4 × categoryDifferent + 0.3 × |centroid1-centroid2| / 5000 + 0.3 × |rms1-rms2| / max(rms1,rms2)

categoryDifferent is 0 for the same texture class and 1 for different classes; the numeric texture codes themselves are not treated as a metric.

Form archetypes

None

Keeps the detected sections in their original chronological order. Optional operations may still alter the timeline.

Arch

Sorts sections by RMS, places the loudest section near Arc_peak_position, then places successively quieter sections alternately to the left and right of that peak position. The result is an energy-based arch ordering; it is not a literal mirror of the source.

Contrast

Starts with the section having the lowest spectral centroid. It then greedily chooses the unused section with the greatest texture distance from the previous one.

Rondo

Selects one refrain section using a salience score:

refrainScore = 0.55 × normalized RMS + 0.45 × normalized positive HNR

The remaining sections stay in their original relative order as episodes, producing A B A C A D ... A. With N detected sections, the form can contain up to 2N - 1 items before additional operations.

Narrative

Sorts all sections from lowest to highest spectral centroid, then appends one additional copy of the darkest section. The appended return is initially unprocessed; any later stochastic operation is planned separately.

Random swap

Starts from the original order and performs between 1 and floor(formLength/2) random swaps. With a positive Random_seed, the swaps are reproducible.

Structural operations

After the form order is created, each enabled operation type receives at most one probabilistic planning attempt. The Strategy controls those probabilities and parameter ranges.

StrategyLoopSilenceStretchRecallMax operationsStretch range
Conservative0.200.150.200.2530.7–1.4×
Dramatic0.400.350.400.4040.4–2.5×
Radical0.600.500.500.6040.25–4.0×

Loop

A random form position is chosen. The operation is accepted only if that source section lasts between 15 and 60 seconds. The section then appears 2 or 3 times total at that position. Added loop copies are plain copies, even if the original position is also stretched.

Long silence

The insertion point is the highest-RMS form position before the end of the form. Its duration begins at 3 seconds and grows according to the RMS drop into the following section:

silenceDuration = 3 + max(0, peakRMS-nextRMS) / max(globalMaxRMS, 0.001) × strategySilenceRange

The strategy silence range is 2 s, 8 s, or 20 s for Conservative, Dramatic, and Radical respectively.

Time stretch

The script preferentially selects a non-Quiet position and randomly chooses a faster or slower factor from the Strategy range. Praat Manipulation/DurationTier overlap-add resynthesis is applied. Multichannel material is split, each channel receives the same duration factor, and the channels are recombined in their original order.

Material recall

A source position from earlier in the form is chosen and a transformed copy of its underlying section is inserted after a later form position. The recall:

Noise-tail silence

When Silence_mode = Noise tail from source, the script takes the final 2 seconds of the input, applies a 0–400 Hz Hann-band low-pass filter, scales the template to a 0.02 sample peak, repeats it as needed, trims it to the requested silence duration, and applies short edge fades. This creates a very low-level source-derived floor rather than digital zero.

Crossfades & assembly

The completed timeline is assembled sequentially. In Fixed short mode, the requested crossfade is 30 ms. In Texture-aware mode, the requested duration depends on the adjacent texture pair.

JointRequested crossfade
Tonal → Tonal1.5 s
Tonal → other0.8 s
other → Tonal0.6 s
Quiet involved0.15 s
Bright/Mid → Quiet0.01 s
Silence → anything1.5 s
anything → Silence0.08 s
Mid → Mid0.4 s
Dark ↔ Bright0.05 s
Other combinations0.3 s

Every requested crossfade is then limited to 40% of the shorter adjacent item. If the safe overlap is 2 ms or less, or if either item is too short, the script uses a butt concatenation instead.

Crossfades reduce the total duration because adjacent items overlap in time. The output duration is therefore not simply the sum of item durations.

Tension arc

When enabled, the tension arc is a multiplicative envelope applied to the entire assembled output. It ranges from 0.3 at the ends to 1.0 at the selected peak position:

shape(x) = x/peak if x <= peak = 1-(x-peak)/(1-peak) if x > peak gain(x) = 0.3 + 0.7 × shape(x)^Arc_exaggeration

Arc_exaggeration > 1 makes intermediate values lower and therefore increases the contrast between the edges and the peak. It does not normalize individual sections.

Parameters & defaults

ParameterDefaultMeaning
Min_section_duration_s8Minimum accepted section duration.
Max_section_duration_s90Target maximum section duration; long spans are split.
Novelty_threshold0.25Relative threshold on the peak-normalized novelty curve; clamped to 0–1.
Harmonicity_threshold_dB5.0Mean HNR threshold for the Tonal class.
StrategyDramaticOperation probabilities and stretch/silence ranges.
Reorder_modeContrastNone, Arch, Contrast, Rondo, Narrative, or Random swap.
Crossfade_modeTexture-awareFixed 30 ms or texture-pair lookup.
Silence_modeNoise tail from sourceDigital zero or source-derived low-level noise floor.
Allow_loopingOnEnables stochastic loop planning.
Allow_long_silencesOnEnables post-peak silence insertion.
Allow_time_stretchingOnEnables one stochastic stretch operation.
Allow_material_recallOnEnables one transformed recall operation.
Recall_lowpassOnApplies the fixed 2500 Hz recall low-pass.
Recall_reverseOnPermits the 35% recall-reversal probability.
Apply_tension_arcOnApplies the macro envelope after assembly.
Arc_peak_position0.65Peak position; internally constrained to 0.01–0.99.
Arc_exaggeration1.5Exponent controlling arc contrast.
Random_seed00 = unpredictable; positive = reproducible stochastic choices.
Draw_visualizationOnDraws the structural transformation.
Play_outputOnPlays the completed result.

Visualization

The Picture window is organized as Source → Dramaturgical form map → Output → Summary.

The Source and Output waveform panels use a shared amplitude scale.

Output behavior & limits