Spectral Anticipation

The next note is heard before it arrives: spectral tuning turns each melodic event into a prediction, and each prediction into a lasting resonance.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Library: Praat AudioTools Category: CDP Version: 0.2.1 (2026) Script license: MIT CDP engines: LGPL-2.1-or-later

The musical idea: the future becomes audible

A melodic phrase unfolds in time: a note is heard, and only later does its successor arrive. Spectral Anticipation changes this order. For each adjacent pair of usable melodic events, it takes sound material from the earlier event and uses Praat's estimate of the later event's fundamental frequency to control CDP Tune to Pitch (Hz).

The transformed material sounds before the next note arrives. With sustained-cloud presets, that spectral prediction then crossfades into a CDP Freeze of the already tuned sound. It continues as the melody moves forward, joining later predictions in an accumulating, spatially distributed cloud. After the unaltered phrase ends, the processed cloud decays slowly.

The preceding sound anticipates the next pitch; when the predicted note finally arrives, its anticipation becomes part of the harmonic memory.

This differs from Frozen Canon. Frozen Canon sustains pitches after they have appeared in the source melody. Spectral Anticipation retunes the current event toward the following event, so its pitch relationship is predictive rather than retrospective. The two instruments share the embedded CDP Freeze infrastructure, but organize musical time differently.

How the instrument works

The entire instrument runs from one Praat script. Praat analyzes events and F0, chooses material, schedules voices, manages stereo/multichannel rendering, applies the shared decay, and draws the optional Picture. Its bundled CDP engine performs the spectral tuning and, when enabled, the sound extension. No Python is required.

CDP stage one

Tune to Pitch (Hz)

The registry process sp_tune_1 receives Pitch = F0 of the next event, with Focus = 1 and Clarity = 1. Focus and Clarity are fixed, not preset parameters. The operation spectrally reorganizes source material toward the target; it does not simply replay the next note.

CDP stage two

Freeze of the tuned material

The separate freeze process extends the processed excerpt with zero pitch shift and zero amplitude cut. It freezes the tuned sound, never the untreated original. In the Short Anticipation preset the entire Freeze stage is disabled.

The acoustic result is source-dependent. Tune to Pitch guides spectral components toward a harmonic target; it does not guarantee a clean, isolated sine tone or an exact perceived pitch for every source. The timbre, attacks, and stability of the input matter.

Anticipation becomes resonance

Each successfully rendered event pair creates a voice with two phases. Phase A (anticipation) is a naturally timed excerpt of the earlier event, spectrally tuned to the next event's F0 and placed just before its arrival. Phase B (resonance) sustains the tuned material from around that arrival, allowing future-oriented voices to overlap. The original phrase remains audible during its normal duration.

Illustrative timeline: a 10-second phrase with a 15-second shared cloud tail 0 sE2E310 s25 s OriginalVoice 1Voice 2Voice 3 Unaltered melody AAA Predictions enter before their target notesShared resonance decay after the phrase
Original phraseA: spectral anticipationB: sustained resonanceShared decay
This is a conceptual score, not a plot of an actual render. In the software, entry times, usable event pairs, crossfades, and voice durations are computed from the selected Sound. The final source event has no successor and creates no new anticipation.

One shared decay, applied only to the processed cloud

The processed voices remain at their rendered levels until the source phrase ends, then follow a common exponential curve toward approximately -60 dB by the output boundary, with a short terminal fade. The source is not lengthened or given this envelope. Its amplitude envelope is not imposed on the processed voices.

Phrase duration = T
Cloud tail = T × Cloud_decay_factor
Total output duration = T × (1 + Cloud_decay_factor)
Example: T = 10 s, factor = 1.5 → 10 s melody + 15 s tail = 25 s total.

In the Short Anticipation preset, the decay factor is zero. This deliberately disables both Freeze sustain and the extended tail, so the instrument behaves like its original short-anticipation concept.

Event pairs, stable pitch, and the meaning of "next"

Praat finds candidate events from pitch jumps and voiced restarts, or accepts onset times from a selected PointProcess. The script measures a median F0 over a stable portion after each onset, rather than trusting the attack frame. Each accepted event needs enough voiced Pitch frames to support the estimate.

Pairs are formed only between adjacent original events whose pitch estimates are both reliable. If E2 has no valid F0, the script will not silently invent an E1 → E3 prediction: the missing event breaks adjacency. This detail preserves the instrument's musical proposition.

E1 (source timbre) → F0(E2) (spectral target)
E2 (source timbre) → F0(E3) (spectral target)
E3 (source timbre) → F0(E4) (spectral target)

When there are more usable pairs than Maximum_anticipations, the script favors the largest F0 interval changes, with timing used as a small tie-breaker, and renders the retained pairs in chronological order. The source and target indices do not change when other pairs are omitted. Invalid or too-short excerpts are skipped or reported rather than silently retargeted.

Why the sustain is more stable in v0.2.1. CDP Freeze receives an interior region of the tuned excerpt selected for adequate energy and relatively steady local level and spectral centroid. The script skips the initial Freeze build-up, aligns the sustained sound to the anticipation within approximately one target-pitch period, and adjusts crossfade gains using measured correlation. These measures reduce, but cannot rule out, audible discontinuities on difficult inputs.

Stereo and multichannel composition

Output_format is independent of the selected preset. Every voice carries both its anticipation and, if successfully generated, its sustained resonance into the chosen channel layout.

Default · 2 channels

Stereo

Always returns a two-channel Sound. Earlier anticipation/resonance voices are placed toward the left, later voices toward the right, using equal-power panning across the sequence. The original mono working phrase is added identically to both channels.

Alternative · up to 16 channels

Multichannel

Places one processed voice per channel until the channel limit is reached; additional voices are assigned round-robin. The original mono working phrase is present in every output channel. With 5 rendered anticipations and a channel limit of 6, the output contains 5 channels.

Multichannel routing is a set of independent output channels, not a pre-assigned surround loudspeaker geometry. Monitor the channels using suitable audio hardware or a compatible DAW. For a conventional two-speaker test, select Stereo.

Input channel handling: for stereo or multichannel source files, Praat makes a mono working copy for analysis, tuning, and the shared original layer. It does not preserve the input's stereo image in the processed result. The selected source Sound itself remains unchanged.

Getting started

Installation. Save Spectral_Anticipation.praat as an independent script in plugin_AudioTools/CDP/. The script includes internal/cdp_engine.praat and uses the existing CDP_Processes.tsv, CDP_Parameters.tsv and bundled platform engine (including the Windows binaries). No separate SoundLoom or Python installation is required when the compatible embedded engine is available. Praat 6.4 or newer is required.
  1. Select one Sound in Praat, preferably a clearly articulated monophonic phrase with at least two stable pitches. Minimum source duration: 0.35 seconds.
  2. Optional: select a PointProcess as well. Its points specify candidate event onsets in the Sound's own time domain. Praat still measures the F0 from the Sound itself.
  3. Run Spectral_Anticipation.praat. Start with Spectral Cloud for the full anticipation-to-resonance idea, or with Short Anticipation to isolate the predictive phase.
  4. Choose Stereo or Multichannel. Use Stereo for immediate auditioning; use Multichannel when you want independently editable voices and an identical original layer in each channel.
  5. Listen and inspect the Picture. A new Sound appears in Praat. With visualization enabled, the Picture shows measured events, the prediction map, sustained voice lanes, the shared decay, and the rendered waveforms.
  6. Compare presets with the same source. Alter event density, anticipation timing, and tail duration while keeping spectral Focus and Clarity fixed at 1.

Compositional presets

Presets control how many anticipation pairs are rendered, how early their tuned material appears, their relative processed level, the Freeze variation, and the length of the cloud. They never change Focus = 1, Clarity = 1 or the next-event pitch target. The output format is chosen separately.

PresetMax. anticipationsAnticipation fractionCloud decay factorProcessed levelFreeze randomness
Custom60.501.500.650.04
Short Anticipation60.5000.65Not used
Transparent Future40.350.800.400.02
Spectral Cloud60.501.500.650.04
Dense Foreknowledge100.702.000.550.06
Deep Suspension50.802.500.600.03
Sparse Prophecy30.401.500.650.02

Short Anticipation

Only the initial tuned anticipations. They end at the target-note onset; no CDP Freeze and no post-phrase tail. In Multichannel, this retains the earlier v0.1 audio behavior for the same event selection. Stereo uses the newer panning layout.

Transparent Future

Fewer voices, quieter spectral predictions, and a shorter after-resonance. The original phrase remains prominent.

Spectral Cloud

The principal balance: anticipation, CDP Freeze sustain, and a tail lasting 1.5 times the source duration.

Dense Foreknowledge

Up to ten anticipations, earlier entries, a longer tail, and more sensitive automatic event detection (0.15 s gap, 1.2-semitone jump).

Deep Suspension

Long anticipation periods and a 2.5-times-source decay tail; emphasizes lingering spectral expectations.

Sparse Prophecy

Up to three stronger transitions; automatic detection uses a 0.35 s minimum event gap and a 2.5-semitone pitch-jump threshold.

Custom

Uses the form's manual values, initially set to the default full-cloud configuration. No external preset file is required.

These values define potential voices, not guaranteed voice counts. Fewer may render when pitches are unreliable or excerpts are too short. The musical labels describe intended behavior, not the listening result of every possible recording. All presets retain the form's Original_level, selected pitch range, crossfade, and output format.

Controls and output options

ControlFunction
PresetCustom plus six named presets. Musical settings are independent of Output_format.
Maximum_anticipationsMaximum number of adjacent event pairs processed; default 6, maximum 16. If necessary, selects the most prominent pitch changes.
Anticipation_fractionFraction of the interval between neighboring onsets allocated to anticipation (0, 1]; default 0.5. The source excerpt may be shorter than the requested window.
Pitch_floor_Hz, Pitch_ceiling_HzPitch-analysis range; defaults 140 and 1500 Hz. The ceiling must exceed the floor and stay below 45% of the sample rate.
Pitch_jump_semitonesAutomatic pitch-event threshold, default 1.5 semitones.
Min_event_gap_sMinimum temporal separation of automatically detected events, default 0.20 s.
Freeze_window_msRequested sustained-region window, default 160 ms; accepted range 40–600 ms, constrained by the tuned excerpt.
Freeze_delay_msNominal CDP Freeze iteration delay, default 45 ms; limited relative to the selected region.
Freeze_randomnessCDP iteration-delay randomness, default 0.04; range 0–1. Pitch shift and amplitude cut stay zero.
Crossfade_msTransition duration between anticipation and sustained resonance, default 60 ms; range 10–500 ms, bounded by the individual anticipation length.
Original_level, Processed_levelRelative gains for original and processed sounds, defaults 0.85 and 0.65; both constrained to 0–1.
Cloud_decay_factorPost-phrase cloud tail divided by phrase duration, default 1.5; allowed 0–4. Zero disables sustain. Total output is limited to 180 s.
Output_formatStereo (default) or Multichannel.
Maximum_channelsMaximum processed-cloud channels in Multichannel mode, default 6, up to 16. Excess voices are routed round-robin.
Draw_visualizationCreates an optional measured/computed Praat Picture; enabled by default.
Play_resultAuditions the finished Sound when supported by the output configuration; enabled by default.

CDP settings that do not vary

Tune to Pitch (Hz): Pitch = measured F0(Ei+1); Focus = 1; Clarity = 1.
Freeze (when enabled): Pitch shift = 0; Amp cut = 0; Gain = 1; reproducible per-voice seed.

Result objects

ModePraat Sound suffixOutput channels
Stereo_SpectralAnticipation_ST2
Multichannel_SpectralAnticipation_MCMinimum of successful anticipations and Maximum_channels, up to 16

The renderer preserves the Sound's original time-domain start, returns a new Sound without altering the source, and applies an attenuation-only final peak guard when the result exceeds 0.95. If a CDP stage fails, the script reports an error instead of silently returning a misleading result.

Reading the compositional visualization

With Draw_visualization enabled, the script draws an approximately 8-inch Praat Picture after audio rendering. The image is a diagnostic/compositional score computed from the events and completed Sound of the current run; it does not change the audio.

Panel A

Phrase and events

Original waveform, detected or supplied onsets, selected source events, and measured F0 labels.

Panel B

Anticipation map

Each Ei → Ei+1 relationship, target pitch, predictive time window, and transition to resonance.

Panel C

Spectral cloud lanes

One lane per rendered voice, showing anticipatory onset, sustained continuation, and stereo pan or multichannel assignment.

Panel D

Shared decay

The processed-cloud envelope: flat during the phrase, followed by the configured exponential decay.

Panel E

Rendered output

Waveforms measured from the finished stereo or multichannel Sound, with compact labeling for larger channel counts.

A summary strip identifies source duration, preset, successful anticipations, sustained voices, rendering format, tail duration, and related output measurements. Voice lanes show actual rendered durations; a sustain that could not be generated is not represented as a completed long resonance.

Technical and listening notes

Future-pitch mapping, not musical prediction

The script operates offline and can inspect the entire selected recording. "Anticipation" is a compositional time relationship, not a real-time model predicting an unknown future performance.

Robustness of F0

Noise, rapid ornamentation, weak fundamentals, or genuinely polyphonic input can produce rejected or inaccurate pitch estimates. PointProcess marks improve onset control but do not replace pitch measurement.

Sustaining a spectral target

CDP Freeze repeats a chosen tuned excerpt with controlled iteration variation. It is not a perfectly stationary partial-tracking oscillator; some internal movement, beating, or timbral modulation may remain.

Transition improvements in v0.2.1

The current version adds energy-and-stability-based Freeze selection, a steady-state starting offset, phase alignment, and correlation-aware crossfading. These are engineering measures rather than a guarantee of artefact-free output.

Scope of verification: This page documents the supplied v0.2.1 script and its exposed controls. It does not claim listening validation of every preset or source, or cross-platform testing of the underlying CDP executables.