Praat AudioTools · User Guide · v1.5.1

Spectral Noise Shaping

Corpus-driven random-phase spectral resynthesis. Learn spectral shapes and temporal envelopes from recorded sounds, then compose new stereo textures through random sampling, observed transitions, morphological replay, feature-directed migration, or spectral counterpoint.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 1.5.1 (2026) License: MIT License Repository: Praat AudioTools on GitHub

What it does

Spectral Noise Shaping analyses a folder of recordings and builds an ordered bank of level-independent spectral magnitude profiles. It also learns temporal RMS envelopes. The generator then reconstructs new audio by combining learned spectral magnitudes with random phases extracted from independently generated white-noise signals for the left and right channels.

Unlike a conventional playback, time-stretching, or granular sampler, the output does not directly reuse the source waveforms or their phases. The Generation mode determines how the learned spectral material unfolds over musical time, while the Texture preset determines its analysis/synthesis grain and degree of variation.

Conceptual distinction: the system extracts acoustic features from a corpus; it does not train a neural model. The term Markov-style refers to a first-order stochastic traversal of observed transitions and similarity-based jumps, not to an estimated full Markov transition matrix.

Five synthesis modes

Random cloud, Markov spectral walk, morphological replay, spectral migration, and spectral counterpoint.

Two independent stereo phases

The channels use distinct noise phases. In Counterpoint they can also follow distinct spectral paths.

Temporal morphology

Choose a corpus-mean envelope, the selected spectral trajectory's RMS, or a flat envelope.

Corpus-to-result inspection

Compare mean spectra, amplitude envelopes, intended and realised centroids, and the resulting waveform.

Quick start

1
Prepare a corpus folder. Use WAV, AIFF/AIF, or FLAC files containing the sonic material you want to explore. Subfolders are scanned recursively. Files shorter than 0.2 seconds are skipped.
2
Start the Praat script. Run Spectral_Noise_Shaping.praat from Praat AudioTools. The script first checks that Python and the required libraries are available.
3
Choose your corpus and mode. Enter Input_folder, or leave it blank to select a folder after submitting the form. The default Generation mode is Markov spectral walk.
4
Set Duration and texture. For an initial test, keep Duration = 3.0 seconds and Texture_preset = Manual. A named texture preset overrides the main form's Variation and Spectral continuity values.
5
Generate and inspect. Click OK (or Apply). Praat calls Python, checks for an explicit successful-completion marker, imports the stereo Sound, and optionally draws a corpus-to-result figure and plays the result.
First experiment: begin with a short corpus and try the same Seed in Random cloud, Markov spectral walk, and Morphological replay. Compare how each mode turns the same learned profiles into a different form of musical time. Set Seed = 0 for a new random result each run.
Dependencies: Python 3, NumPy, SciPy, and SoundFile must be available to the Python interpreter detected by Praat. Installation command: pip install numpy scipy soundfile. Processing time depends on corpus size, output duration, FFT settings, and computer performance; large corpora are not guaranteed to finish in seconds.

Generation modes

The Generation_mode menu contains eight choices representing five underlying synthesis algorithms. Spectral migration appears as four separately selectable directions.

Menu selectionHow it uses the corpusCompositional character
Random cloud (v1.4 classic)Randomly selects and blends two spectral frames at each hop, mixes them with the mean profile, and can apply spectral inertia.Textures that do not follow the corpus's original order.
Markov spectral walk defaultUsually follows observed frame-to-frame successors; otherwise jumps to spectrally similar states, with occasional unrestricted jumps.New paths that retain local connections to the corpus.
Morphological replayTraverses a selected source file's temporal sequence, including silence positions and RMS levels, at a chosen time stretch.Source-derived gestures and temporal shapes rebuilt with random phases.
Spectral migration: risingTraverses profiles towards increasingly high values of the selected feature.Dark-to-bright (Centroid) or tonal-to-noisy (Flatness) tendency.
Spectral migration: fallingTraverses the same feature in descending order.Bright-to-dark or noisy-to-tonal tendency.
Spectral migration: archMoves from lower to higher feature values, then returns.An arch-like trajectory.
Spectral migration: valleyMoves from higher to lower feature values, then returns.A valley-like trajectory.
Spectral counterpointBuilds independent stochastic walks for left and right; blends their spectral shapes using Stereo coupling.Interacting stereo timbral trajectories rather than phase decorrelation alone.
Important: Variation = 0 largely collapses the spectral profiles towards the corpus mean, so a sophisticated path may no longer be clearly audible. To hear a mode's path behaviour, use moderate-to-high Variation. Spectral_continuity is interpreted differently across modes; it is not a universal time-stretch control.

Texture presets

Texture presets are complete starting snapshots for Chunk size, Hop length, N fft, Variation, and Spectral continuity. They affect the sound's spectral time resolution and the amount and smoothness of variation.

Texture presetChunk / Hop / FFTVariationContinuityIntended starting character
Manual default2048 / 512 / 20480.700.75Use the values from the main dialog; the analysis grid starts at 2048 / 512.
Stable portrait4096 / 512 / 40960.100.95Relatively stable spectral identity, near the corpus mean.
Granular flutter1024 / 256 / 10240.850.20Fine, rapid spectral activity and more varied texture.
Diffuse cloud2048 / 512 / 20480.700.50A middle ground between dispersed events and perceptible continuity.
Slow wash8192 / 1024 / 81920.250.95Broader, smoother spectral motion with restrained variation.

At 44.1 kHz, the chunk lengths 1024, 2048, 4096, and 8192 correspond to approximately 23, 46, 93, and 186 ms respectively. These presets are proposed creative starting points; the script's comments explicitly state that they have not been established through systematic listening tests.

Precedence: a named preset replaces the Variation and Spectral continuity values typed into the main form. With Manual, those form fields are used. If you open Advanced settings, the dialog displays the effective preset values and your edits there take precedence. The Standards button restores the chosen preset (or the Manual form values) and resets the other advanced settings.

Main controls and defaults

Control in PraatDefaultMeaning
Input_folderBlankCorpus folder; if left blank, a folder chooser opens after the form.
Generation_modeMarkov spectral walkChoose one of the eight menu entries described above.
Texture_presetManualChoose a complete texture snapshot, or retain manual parameters.
Duration3.0 sOutput duration in seconds. Must be positive.
Seed00 = new random generator seed; positive integer = reproducible result with identical input and settings.
Variation0.700–1. Blend between mean spectral shape and mode-specific profiles. Replaced by a named texture preset unless overridden in Advanced.
Spectral_continuity0.750–1. Controls spectral inertia, likelihood of following observed successors, or permitted local deviations, depending on mode.
EnvelopeAutoAuto: Follow trajectory for Replay, Learned mean for other modes. Explicit choices: Learned mean, Follow trajectory, Flat.
Corpus_weightingEqual per fileEqual: choose source files with equal probability when sampling; By duration: prefer longer files / more represented frames. The latter is the v1.4-style choice.
Show_advanced_settingsOffOpens a second dialog before generation for fine controls.
Draw_visualizationOnDraw a comparative figure in Praat's Picture window.
Play_resultOnPlay the generated Sound after import.

Envelope modes

Auto

Uses Follow trajectory in Morphological replay; uses Learned mean in other modes.

Learned mean

Applies the average of individually peak-normalised file RMS envelopes, each resampled to 200 points.

Follow trajectory

Applies frame RMS levels associated with the selected path. In Replay this carries the source's temporal gaps and gesture.

Flat

No learned RMS contour is imposed. The output still receives the final fades and peak normalisation.

Advanced settings

Enable Show_advanced_settings to open a second Praat dialog. It shows the effective Variation and Continuity values, and permits manual override of the analysis grid and mode-specific parameters.

Advanced controlStarting valueFunction / constraint
VariationEffective form/preset value0–1; Advanced overrides the main form or selected preset.
Spectral continuityEffective form/preset value0–1; interpretation depends on the generation mode.
N fftPreset Chunk size (Manual: 2048)Canonical spectral frequency grid. Minimum 64; need not be identical to Chunk size after an Advanced edit.
Chunk sizePreset value (Manual: 2048)Analysis and synthesis frame length in samples. Must be a power of two, at least 64, and at least twice Hop length.
Hop lengthPreset value (Manual: 512)Advance between neighbouring frames. Must be at least 1 sample.
Sample rate44100 HzTarget analysis and output sample rate; minimum 8000 Hz.
Max profiles20000Hard limit on retained active spectral frames; minimum 100. The engine uses per-file decimation when needed.
Replay stretch00 = automatically fit the initially selected source's timeline to Duration. 2 = half-speed traversal (2 output seconds per source second); positive values only.
Migration featureCentroid (dark–bright)Either spectral Centroid or Flatness (tonal–noisy); applies to all four migration directions.
Stereo coupling0.30Counterpoint only: 0 = independent spectral paths, 1 = the right spectral shape follows the left. Noise phases remain independent.
Replay time: when a nonzero Replay stretch is shorter than the requested output duration, the engine may move to another randomly selected source file after reaching the end of the current one. In a highly decimated corpus, very short events and silences are represented at the retained timeline resolution, not sample for sample.

A corpus with more readable, usable files than Max profiles is rejected with a clear message, because at least one timeline slot per file must be reserved. The cap applies to retained spectral profiles, not to the size of a file while it is temporarily loaded for analysis.

How the engine works: five stages

  1. Scan and load. Read metadata for WAV/AIFF/FLAC files recursively; skip sources shorter than 0.2 s. During analysis, load files one by one, resample as required, and peak-normalise each file to 0.95. For multichannel material, combine channel magnitude powers rather than arbitrarily selecting one channel or cancelling out-of-phase channels.
  2. Analyse and learn. Analyse overlapping Hann-windowed frames, create unit-RMS spectral magnitude profiles, preserve frame order and links to successive frames, and learn RMS envelopes. If needed, retain an order-preserving subset under the hard Max profiles cap. Morphological replay additionally stores a time-aligned timeline including silent slots.
  3. Construct a spectral path. Select, transition between, replay, order, or independently traverse the learned profiles according to Generation mode. Variation controls how strongly those profiles replace the mean spectral shape.
  4. Resynthesise and shape. Generate independent left/right white-noise phases, impose the intended magnitude spectrum on each frame, inverse-transform and overlap-add. Apply the chosen RMS contour (smoothed over approximately 20 ms), then a short fade-in/out and a single global peak normalisation towards 0.90, preserving stereo balance.
  5. Save and measure. Write a stereo floating-point WAV, compute comparative QC data, and write an explicit completion marker only after the required stages succeed. Praat imports the Sound, draws the optional figure, and removes temporary files.
Output: Praat imports a Sound named spectral_noise_shaped_random, spectral_noise_shaped_walk, spectral_noise_shaped_replay, spectral_noise_shaped_migration, or spectral_noise_shaped_counterpoint, according to the active synthesis algorithm. All modes render stereo audio.

Visualization and quality-control metrics

With Draw_visualization enabled, Praat produces a corpus-to-result comparison rather than the older waveform/spectrogram-only display. The figure contains a title and settings strip, a corpus and metrics summary, four plots, and a result summary.

PlotWhat is shownHow to read it
Spectral characterNormalised corpus-mean magnitude (blue) versus rendered-output mean (red), on a logarithmic frequency axis.Compares overall spectral character; it does not measure whether source events occurred in their original order.
Temporal shapeTarget RMS envelope (blue) versus actual output RMS (red), over normalised time.Shows how closely the amplitude contour was realised.
Spectral trajectoryIntended spectral centroid versus realised output centroid over seconds. Counterpoint shows distinct traces for left and right.Reveals whether the time-varying spectral path was acoustically realised.
Generated stereo resultWaveform of the resulting stereo Sound.Shows the final amplitude shape and distribution of activity through time.

Metrics in the figure

MetricInterpretationLimits
Spectral similarityCosine similarity between average corpus and output magnitude spectra, computed using the same analysis window/FFT pipeline.High similarity means similar average spectra, not matching temporal organisation. The figure presents it as a percentage.
Envelope similarityCosine similarity of target and output RMS envelopes.Measures resemblance of overall contours; not an exact waveform match.
Temporal structureRatio of output to corpus slow-scale spectral movement. Around 1 means a similar amount of movement; values above 1 indicate more movement.The ratio is capped at 2 and is reported as n/a when the corpus is too static or the comparison is not meaningful. It is not a measure of event-order fidelity.
Path fidelity rCorrelation between intended and realised spectral-centroid trajectories.Ranges from -1 to 1 when defined. It may be n/a for nearly constant intended paths. In Counterpoint it is reported separately for L and R.
L–R centroid correlationCorrelation between realised left/right centroid trajectories in Counterpoint.Measures similarity of spectral motion between channels, not overall stereo width or phase correlation; reported as n/a where not meaningful.
Do not maximise every metric. A low spectral similarity may be musically useful if the selected mode visits a distinctive part of the corpus. Counterpoint may intentionally reduce L–R centroid correlation. The plots and listening should guide interpretation together.

The Python engine exports temporary profile, envelope, trajectory and summary CSV files for Praat. The summary CSV includes validity flags for optional QC metrics, so an undefined value is distinguished from a legitimate correlation of -1. Temporary files are normally deleted after the Praat figure is drawn.

Compositional approaches

Timbral portrait

Try Random cloud with Stable portrait, or reduce Variation manually. Listen for the corpus's overall spectral identity without its original gestures.

Source gesture without source phase

Use Morphological replay with Envelope = Auto. Adjust Replay stretch and Duration to reshape time while keeping the selected file's temporal contour.

Statistical exploration

Use Markov spectral walk, then vary Spectral continuity to move between locally connected paths and more disruptive jumps.

Directed timbral form

Choose Spectral migration rising, falling, arch or valley, and compare Centroid with Flatness as the organising feature.

Spectral stereo dialogue

Choose Spectral counterpoint. Move Stereo coupling from 0 towards 1 to progress from independent timbral trajectories to shared spectral motion.

Fair corpus exploration

Use Equal per file when recordings differ greatly in length. Use By duration when the distribution of recorded time should influence selection.

Musical descriptors such as “smooth”, “fluttery”, and “dark–bright” describe intended tendencies, not guaranteed perceptual outcomes. The actual character depends on the recorded corpus and the selected mode.

FAQ and troubleshooting

Praat cannot find Python or reports missing dependencies.

Install Python 3 and numpy, scipy, and soundfile in the interpreter Praat can call. On Windows the script probes python, py and python3; on other systems it tries python3, python and py. The dependency probe runs before the main settings form.

Praat cannot find praat_spectral_gen.py.

The Praat script first looks for py/praat_spectral_gen.py inside plugin_AudioTools under the Praat preferences directory, and otherwise looks for praat_spectral_gen.py in Praat's current default directory. Make sure the Python engine is installed at one of those locations.

What do “Chunk size must be a power of 2” and “at least 2 x Hop length” mean?

Choose a power-of-two Chunk size (for example 1024, 2048, 4096, or 8192) and keep Chunk size ≥ 2 × Hop length. A named Texture preset selects a validated combination; Advanced values are checked before the engine starts.

Why do the main Variation and Continuity fields seem to have no effect?

When a named Texture preset is selected, it explicitly replaces those two values. Select Manual to use the main form values, or open Advanced settings to override the effective preset values there.

Does Morphological replay reproduce the original recording?

No. It follows the selected source's ordered spectral and RMS timeline, including represented silence positions, but each output frame is reconstructed from learned magnitudes and random noise phases. Decimation, frame resolution, smoothing, and the chosen settings can alter fine details.

Why are there two different-looking stereo channels?

All modes use independent white-noise phases for L and R. In Random, Walk, Replay and Migration, the underlying spectral paths are shared. In Counterpoint, the paths may differ; Stereo coupling = 1 matches their spectral magnitudes, not their noise phases.

“Max profiles” error or slow analysis on a large corpus?

Max profiles places a hard cap on retained active spectral profiles, with per-file decimation where needed. If the corpus contains more usable files than the cap, the script stops with an explanation. A file is still loaded in memory during its analysis, so huge individual recordings can require substantial RAM. Lower the corpus size or change the cap in Advanced as appropriate.

Why is a metric shown as n/a?

Some metrics are mathematically uninformative for a nearly static spectral trajectory or for inadequate active material. In v1.5.1 the engine exports validity flags rather than using -1 to stand for a missing measurement.

Python did not complete, but an output WAV exists.

Praat requires both a WAV and the explicit done.ok marker produced after successful processing. A partial WAV does not count as success. If generation fails, the script reports information from the engine's stats and Python log.

Where are the generated files?

The finished stereo Sound is imported into Praat's Objects list. Intermediate WAV and CSV files are created in a temporary directory and normally removed after import and optional visualization. Save or export the Sound from Praat if you want to retain the audio as a file.