Pitch-Class Spectral Gravity — Tonal Spectral Attraction

Impose a scale or pitch collection directly on the spectrum as a tonal attractor field. Target regions are preserved or emphasised; other frequencies are attenuated according to their distance from the nearest pitch-class member — without note tracking, pitch correction, Python, or external tools.

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

What this does

Pitch-Class Spectral Gravity turns a selected pitch collection into a periodic gain field on the log-frequency axis. Every spectral frequency is evaluated by its distance from the nearest member of the collection. Frequencies close to a target pitch class are retained or boosted; frequencies farther away are progressively attenuated.

What makes this different? This is not pitch correction. The script does not estimate F0, detect notes, move partials, or re-tune a melodic line. It colours the whole spectrum at once, so breath, scraping, metal, multiphonics, percussion, noise, and mixed pitched/unpitched material can acquire a tonal field while keeping their own identity.

Key Features:

Quick start

  1. Select exactly one Sound object in Praat.
  2. Run Pitch_Class_Spectral_Gravity.praat.
  3. Choose a Root and Collection.
  4. Start with Preset = Tonal field.
  5. Keep Field shape = Continuous for the smooth default behaviour.
  6. Use Attraction width to decide how narrowly the spectrum gathers around the target pitch classes.
  7. Use Dry/Wet to blend the transformed result with the original.
Good source material: sustained instrumental tones, cymbal resonance, breathy voice, bowed textures, multiphonics, metallic sounds, scraping, percussion, and other sounds containing both harmonic and inharmonic energy. These reveal the distinction between ordinary pitch shifting and whole-spectrum tonal colouring especially clearly.

How it works

1. A periodic field on the log-frequency axis

The selected Sound is converted to a Praat Spectrum. Instead of constructing many band-pass Sound objects, the script builds one gain curve on a dense logarithmic grid and applies it to the spectrum with a lookup for every FFT bin.

s = 69 + 12 log2(f / A4) pc = s mod 12

s is a MIDI-like semitone position and pc is its continuous pitch-class position around the octave. In Continuous mode the position is not snapped to a note.

2. Distance to the nearest collection member

For each spectral position, the script finds the shortest circular distance d, in semitones, to the nearest active pitch class.

w = exp(-d^2 / (2 sigma^2)) gain_dB = [emphasis * w - attenuation * (1 - w)] * strength

Attraction width is the Gaussian width sigma. A wide value creates broad harmonic colouring; a narrow value leaves only a tight neighbourhood around the selected pitch classes.

3. Complex-spectrum weighting

The same scalar gain is applied to both real and imaginary components of each FFT bin. The operation therefore changes magnitude without deliberately rotating the original spectral phase. The processed spectrum is then transformed back to Sound and mixed with the dry source.

Implementation. The effect operates on Praat's whole-sound Fourier Spectrum using a logarithmic pitch-class coordinate system. The gain field is sampled at 16 points per semitone.

Pitch collections

The chosen Root transposes the selected pitch-class pattern. Custom mode accepts pitch classes as numbers from 0 to 11.

CollectionCharacter / use
MajorDiatonic seven-note field.
Natural minorDiatonic minor field.
Harmonic minorMinor collection with raised seventh.
Whole toneSymmetrical six-note field with evenly spaced targets.
Octatonic 1Half-whole octatonic field.
Octatonic 2Whole-half octatonic field.
Pentatonic majorOpen five-note major-oriented field.
Pentatonic minorOpen five-note minor-oriented field.
ChromaticAll 12 pitch classes; useful for pulling inharmonic energy toward the 12-TET grid rather than toward a key.
CustomUser-defined pitch classes, e.g. 0 2 3 5 7 8 10.

5 Presets

Gentle colouring

Strength: 40%
Width: 0.60 st
Attenuation: 18 dB
Field: Continuous

Broad and subtle harmonic bias. Useful when the original spectrum should remain clearly recognisable.

Tonal field

Strength: 70%
Width: 0.35 st
Attenuation: 30 dB
Field: Continuous

The default balance between spectral identity and clearly audible pitch-class attraction.

Hard gravity

Strength: 90%
Width: 0.20 st
Attenuation: 40 dB
Field: Continuous

A much narrower field in which non-target spectral regions are strongly suppressed.

Radical (resonant grid)

Strength: 100%
Width: 0.10 st
Attenuation: 48 dB
Field: Continuous

A deliberately thin resonant comb around the target collection. Ringing can become part of the effect.

Quantised grid

Strength: 85%
Width: 0.30 st
Attenuation: 36 dB
Field: Quantised

A harder stepped colour based on a discretised log-frequency grid.

Custom preset: choosing Custom leaves the user-entered Strength, Width, Attenuation, and Field shape values untouched.

Field shapes

Continuous

The pitch-class coordinate remains continuous. Gain therefore changes smoothly with frequency. Internally, the field is represented at 16 points per semitone.

Use: smooth tonal colouring and the normal default behaviour.

Quantised to bands

The semitone position is first snapped to the selected number of bands per octave. Each band therefore holds one gain value and the field becomes a staircase.

Use: deliberately harder, grid-like spectral colour.

Chromatic is not necessarily neutral. With a chromatic collection every 12-TET semitone is a target, but frequencies between semitones still have a non-zero distance from the nearest target. This can pull noisy or inharmonic material toward the tempered grid without selecting a tonal centre.

Controls

ControlFunction
RootTransposes the selected pitch collection: C through B.
CollectionSelects the pitch-class set used as the tonal attractor field.
Custom pitch classesSpace-separated pitch classes from 0 to 11, used when Collection = Custom.
PresetSets Attraction strength, Attraction width, Non-target attenuation, and — for Quantised grid — Field shape.
Field shapeContinuous smooth field or stepped Quantised field.
Attraction strengthScales the entire gain field from no attraction at 0% to the full requested field at 100%.
Attraction widthGaussian width in semitones. Smaller values create narrower resonant regions around target pitch classes.
Non-target attenuation dBMaximum cut assigned to regions far from the selected collection before Strength scaling.
Dry/Wet0% = original only; 100% = processed only.
Normalize outputWhen enabled, scales the result to a 0.99 peak. When disabled, the script does not silently rescale the output.
Play resultPlays the generated Sound after processing.
Draw visualizationCreates the explanatory Praat Picture display.
Advanced settingsOpens frequency-range, tuning, band-grid, target-emphasis, and range-preservation controls.

Advanced settings

SettingDefaultFunction
Lowest frequency40 HzLower boundary of the active spectral-gravity range.
Highest frequency16000 HzUpper boundary, automatically clamped to the Sound's Nyquist frequency.
Bands per octave2412 / 24 / 36 / 48. Used only by the Quantised field shape.
Reference A4440 HzReference tuning used by the log-frequency pitch coordinate.
Target emphasis+6 dBMaximum boost around collection members before Strength scaling.
Preserve below rangeOnLeaves frequencies below the analysis range at 0 dB gain.
Preserve above rangeOnLeaves frequencies above the analysis range at 0 dB gain.

Visualisation

When Draw visualization is enabled, the script produces a Praat Picture display with three complementary views:

A — Pitch-class field

Shows the 12 pitch classes. Collection members are shaded, bars show their applied gain, and arrows indicate attraction direction toward the nearest target pitch class.

B — Applied gain curve

Shows the actual gain field across log frequency in dB. The caption identifies whether the field is Continuous or Quantised.

C — Spectrum, channel 1

Overlays long-term input and output spectra so the user can see where energy has been retained, emphasised, or removed.

The visualisation explains the transformation. It reports the active field, pitch classes, attraction settings, frequency range, A4 reference, and explicitly states that the process is spectral weighting rather than pitch correction.

Technical behavior

Limitations

FFT resolution is linear, not constant-Q. Low-frequency regions are therefore resolved more coarsely in semitone terms than they would be in a true CQT. For short sounds, a single low-frequency FFT bin can span a substantial musical interval.

Outputs

The script creates a new Sound named:

<original-name>_PCGravity

The output preserves the source sample rate, duration, and channel count. The original Sound remains unchanged.

Normalization: with Normalize output enabled, the processed result is scaled to a peak of 0.99. With normalization disabled, no automatic peak scaling is performed.

Applications

Tonalise noisy or inharmonic material

Use case: breath, bow noise, cymbal resonance, metallic scraping, field recordings, or percussion acquire a scale-related spectral bias without being converted into ordinary pitched notes.

Impose harmonic identity without F0 tracking

Use case: multiphonics, complex instrumental sounds, or mixed pitched/unpitched textures can be drawn toward a major, minor, octatonic, whole-tone, pentatonic, or custom field.

12-TET spectral gravity

Use case: choose Chromatic to pull between-note or inharmonic energy toward the 12-tone equal-tempered grid without imposing a key.

Resonant spectral grid

Use case: the Radical preset or Quantised grid can turn the collection into a deliberately narrow spectral scaffold, producing more extreme colour and possible ringing.