Perceptual Fugue — User Guide
A fugue-inspired stereo construction engine that turns one source into recurring, transposed, reversed, augmented, fragmented, and overlapping entries. Each voice keeps a fixed spatial signature while its musical material changes with the section.
What this does
Perceptual Fugue builds a fixed five-section timeline from one selected Sound. It is best described as a fugue-inspired polyphonic audio construction, not as an automatic implementation of strict classical fugue rules. The source acts as the subject; derived materials include answer transpositions, an octave-lower subject, counter-subject material, a half-length head motif, optional retrograde, optional 2× augmentation, and stretto entries.
After the musical timelines are assembled, each voice receives a fixed stereo signature built from inter-channel delay, level asymmetry, optional far-side low-pass filtering, reverb/reflections, and a shared mid-band identity anchor. The final output is stereo.
Quick start
- Select exactly one mono or stereo Sound in Praat.
- Run
Perceptual_Fugue.praat. - Start with Classical Fugue, the default preset.
- Keep Varispeed + PSOLA compensation unless you specifically want the PitchTier method or the legacy varispeed-only behavior.
- Set an analysis range that brackets the source pitch when using PSOLA-based methods.
- Enable Draw_visualization to see the actual entry score, output waveforms, spectrogram, and summary.
- Click OK. The output is named
source_perceptual_fugue, peak-normalized to 0.99, and played automatically.
[9 + (voices−1)×stretto_compression] × source_duration. A separate absolute tail allocation is then added so fixed reverb/reflection delays are not cut off. The tail setting does not set reverb time.Form & presets
Current form
| Parameter | Default | Actual behavior |
|---|---|---|
| Preset | Classical Fugue | Custom or one of four fixed strategies. Presets override voices, interval, stretto, retrograde, augmentation, base ITD/ILD, and shadow cutoff. |
| Answer_interval | Fifth up | Fifth = 2^(7/12), fourth = 2^(5/12), octave = 2, tritone = 2^(6/12). |
| Number_of_voices | 3 | Clamped to 3–4. |
| Stretto_compression | 0.75 | Clamped to 0.2–1.0. Lower values place stretto entries closer together. |
| Include_retrograde | yes | If off, the counter-subject becomes an amplitude-modulated subject and the middle-entry “retrograde” becomes an unchanged subject copy. |
| Include_augmentation | yes | If on, the middle V3 subject and the pedal drone use 2× duration Manipulation resynthesis. If off, ordinary-duration copies are used. |
| Transposition_method | Varispeed + PSOLA compensation | Three distinct algorithms; see below. |
| Pitch_floor / Pitch_ceiling | 50 / 800 Hz | Must satisfy floor < ceiling. Used by Manipulation-based pitch/duration processing. |
| Exposition_ITD_ms | 3.0 ms | Base delay used by V1/V2; V3 uses 0.33× this value and V4 uses 0. |
| Exposition_ILD_factor | 4.0 | Base V1/V2 level ratio. Values below 1 are inverted automatically so V1 remains left-biased and V2 right-biased. |
| Shadow_cutoff_Hz | 500 Hz | Far-side Hann low-pass cutoff for V1/V2. Capped automatically to 0.95×Nyquist. |
| Ild_law | Constant power | Constant-energy direct-path ratio or legacy near-side boost. |
| Tail_allocation_seconds | 1.5 s | Timeline room after the last musical entry; raised automatically if shorter than the longest internal delay/reverb requirement. |
| Speed_mode | Balanced | Sets varispeed resample precision: 50 / 20 / 10 for Full / Balanced / Fast. |
| Draw_visualization | yes | Draws the score-driven spatial overview after rendering. |
Preset strategies
| Preset | Voices / interval | Stretto | Spatial base | Retro / Aug |
|---|---|---|---|---|
| Classical Fugue | 3 / fifth | 0.75 | 3.0 ms, ILD 4.0, shadow 500 Hz | on / on |
| Spectral Fugue | 4 / tritone | 0.50 | 4.0 ms, ILD 5.0, shadow 400 Hz | on / on |
| Chamber Fugue | 3 / fifth | 0.85 | 2.0 ms, ILD 2.5, shadow 800 Hz | on / off |
| Stretto Study | 4 / fifth | 0.40 | 3.5 ms, ILD 4.5, shadow 450 Hz | on / on |
Presets do not override the transposition method, pitch range, ILD law, tail allocation, speed mode, or visualization toggle.
Transposition methods
1. Varispeed + PSOLA compensation
First moves pitch and duration together by overriding sampling frequency and resampling. Then a Manipulation/DurationTier stretch compensates the duration so the whole subject returns to its intended length. The pitch-analysis range is scaled by the transposition ratio, with internal safety limits. Because the compensation still depends on pitch tracking, polyphonic, noisy, or percussive material can produce artifacts.
2. PitchTier
Creates a Manipulation from the source, multiplies PitchTier frequencies by the requested ratio, replaces the tier, and resynthesizes. Duration is preserved by construction. This is most appropriate when a reliable monophonic/voiced pitch track exists.
3. Varispeed only — legacy
Keeps the v2.3 sound intentionally. The resampled result is forced back to the original duration: upward transpositions are followed by padded silence, while downward transpositions are truncated. It therefore does not preserve the complete subject.
Materials & formal timeline
Let S be the source duration. The script creates a subject and several derived materials before building 3 or 4 mono voice timelines.
| Material | Construction | Nominal role |
|---|---|---|
| subject | Source mono copy with 5 ms raised-cosine edge fades | Dux / final statement |
| answer | Subject transposed by selected answer ratio | Comes |
| subjectLow | Subject ×0.5 pitch | Lower-register entry |
| answerLow | Subject ×(answer ratio ×0.5); only for four voices | V4 lower answer |
| counterSubject | Retrograde subject when retrograde is enabled; otherwise amplitude-modulated subject | Counter-subject material |
| headMotif | First 50% of subject | Episode fragment |
| headMotifT1 / T2 | Head motif transposed by answerRatio and answerRatio² | Episode fragments |
| augSubject | 2× duration subject when augmentation is enabled; otherwise subject copy | Middle-entry V3 |
| pedalDrone | 2× duration subjectLow when augmentation is enabled; otherwise ordinary subjectLow copy | Pedal |
Five sections
Actual placement logic
The construction is richer than a simple “S → A → S” summary. The current score visualization is generated from the same placement log used while these entries are built.
I. Exposition: V1 subject at 0, V1 counter-subject at S, then filtered support at 2S; V2 answer at S and counter-subject at 2S; V3 subjectLow at 2S; optional V4 filtered support at 2S.
II. Episode: four half-subject fragments move between V1 and V2 at quarter-S offsets, while V3 carries a quiet low-passed subjectLow support.
III. Middle entries: V1 retroSubject at 4S and counter-subject one S later; V2 receives the answer transposed by the answer ratio again; V3 receives augSubject; optional V4 receives answerLow.
IV. Stretto: subject-family entries enter at compression×S intervals in V1–V4, with additional counter-subject entries in V1 and V2.
V. Pedal/cadence: V3 pedalDrone begins at the stretto end; V2 adds filtered answer support; V1 gives a final subject one S later; optional V4 adds filtered answerLow support. A raised-cosine cadence fade occupies the last 0.5S of musical time and reaches zero.
Spatial processing
Before spatialization, each voice timeline is multiplied by 1 / number_of_voices. Each mono voice is then copied to L/R and processed with its own fixed parameter set.
Direct-path ILD law
This keeps the direct stereo-path energy constant relative to a duplicated mono center while changing the L/R ratio. It does not calibrate the energy of the complete spatial chain: filtering, wet signal, reflections, identity anchor, and V3 polarity inversion still alter the final result. The alternative legacy law simply boosts the declared near side by the factor.
Per-voice signatures
| Voice | Direct cue | Shadow | Reverb / reflections / anchor | Special behavior |
|---|---|---|---|---|
| V1 Dux | Right delayed by base ITD; left-biased ILD | Right low-pass at Shadow_cutoff | RT 0.35 s; reverb coefficient 0.12; reflection gain 0.20; anchor 0.08 | Strongly left-biased, but not hard-panned |
| V2 Comes | Left delayed by base ITD; right-biased mirror ILD | Left low-pass | RT 0.35 s; reverb coefficient 0.12; reflection gain 0.20; anchor 0.08 | Strongly right-biased, but not hard-panned |
| V3 Third | Right delayed by 0.33×base ITD; ILD factor 1.3 | None | RT 0.50 s; reverb coefficient 0.35; reflection gain 0.15; anchor 0.10 | Right channel polarity inverted deliberately; poor mono compatibility is expected |
| V4 Fourth | No ITD; unity ILD | None | RT 0.80 s; reverb coefficient 0.60; reflection gain 0.10; anchor 0.12 | Centered direct/shared-wet field with side-assigned reflections; not a physically diffuse-field model |
Processing order inside each voice
- ITD-style delay: delay the designated far/lagging channel.
- ILD: constant-energy direct-path law or legacy near-side boost.
- Spectral shadow: V1/V2 far side receives Praat
Filter (pass Hann band)from 0 Hz to the cutoff with 100 Hz smoothing. - Polarity: V3 right channel is multiplied by −1.
- Reverb bus: taps at 0.25×RT, 0.5×RT (×0.65), and 1.0×RT (×0.35), then low-pass-smoothed. The form does not expose these fixed per-voice values.
- Early/late reflections: early taps at 0.2×RT and 0.4×RT; a late filtered tap at 1.0×RT. They are assigned to opposite/same sides according to voice delay direction.
- Identity anchor: a 500–3000 Hz Hann-band copy of the mono voice is added equally to both channels.
1 − coefficient, so the coefficient controls the dry/wet construction but should not be interpreted as a measured percentage of output energy.Mixing, normalization & mono report
The stereo voices are summed channel-by-channel with additive formulas. The result is renamed source_perceptual_fugue and then processed with Scale peak: 0.99.
Section_intensity_dB control was removed because an intensity scaling immediately followed by peak normalization was contradictory.Mono-fold diagnostic
Because V3 deliberately inverts its right-channel polarity, the script measures what happens when the final stereo output is folded to mono.
The 0–200% figure is not “energy retained.” It is referenced to the energy expected from an uncorrelated L/R pair. The normalized correlation is reported separately on the standard −1…+1 scale. If either channel is effectively silent, correlation is reported as undefined.
The script uses its mono-fold ratio as a practical warning heuristic: below 60% it reports substantial cancellation; 60–95% reports some cancellation; at or above 95% it reports little cancellation on that material. These are tool-specific report thresholds, not a general broadcast or mastering standard.
Visualization
The current v2.6.3 visualization is a process-oriented overview. It does not contain the old L−R-difference panel described by earlier documentation.
1. Entry score
One row is drawn per active voice. Crucially, the blocks are no longer maintained as a separate hand-written diagram: every timeline placement is logged at the same time the fragment is inserted, and the score reads that placement log. Block lengths therefore use the actual duration of each placed fragment, including changes caused by Retrograde/Augmentation settings.
Vertical section lines mark Exposition, Episode, Middle entries, Stretto, and Pedal. The cadence-fade region and the post-music tail allocation are shaded separately.
2. Left and right waveforms
Separate waveform panels use a shared amplitude scale so channel-level differences remain visually comparable. Section boundaries are overlaid.
3. Spectrogram
The spectrogram is calculated from the already-extracted left channel, because Praat’s spectrogram operation used here is mono-only. It covers 0–5000 Hz and carries the same formal boundaries.
4. Summary
The final compact panel reports preset, source, voice count, answer interval, output duration, and the five-part formal sequence.
Limits & interpretation
- Fugue terminology is structural and compositional. The engine uses subject/answer, episodes, stretto, retrograde, augmentation, and pedal-like construction, but it does not analyze or enforce species counterpoint, tonal answer rules, harmonic legality, or a complete classical fugue grammar.
- Pitch-dependent resynthesis matters. Both the default compensation method and the PitchTier method rely on Praat Manipulation. Clearly pitched monophonic material is generally easier for the tracker than noisy, percussive, or polyphonic material.
- “Inversion” in V3 is polarity inversion only. The melodic interval directions are not inverted.
- Spatial cues are synthetic. There is no HRTF, ear model, room geometry, or individualized localization calibration.
- V4 is not a diffuse-field simulator. Its direct/shared wet components are centered; reflections are side-assigned. “Centered reverberant field” is the intended description.
- Mono compatibility is intentionally imperfect. V3’s right-channel polarity inversion can cancel strongly on fold-down; the script measures and reports this instead of hiding it.
- Tail allocation is scheduling space. It prevents fixed internal delays from being clipped; increasing it beyond the needed decay adds silence rather than lengthening the reverb algorithm.
Applications
Compositional transformation
Turn a short pitched gesture into a longer form whose repeated identity is distributed across register, time, and stereo signatures.
Spatial counterpoint studies
Compare how fixed left/right/center-reverberant signatures interact with recurring musical materials and stretto density.
Analysis and teaching
Use the score-driven visualization to relate scheduled entries to the rendered stereo waveform and spectrogram.