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.
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.
Key Features:
- Entirely native Praat — no Python, external executables, plugins, or libraries.
- Continuous spectral gravity — smooth pitch-class attraction on a log-frequency axis.
- Optional quantised field — a stepped, harder tuned-grid colour.
- 10 pitch collections — major, minor, harmonic minor, whole-tone, octatonic, pentatonic, chromatic, and custom.
- 5 creative presets — from gentle colouring to a radical resonant grid.
- Mono and stereo — stereo channels are processed independently and recombined.
- Dry/Wet blending — interpolate between the source and the transformed spectrum.
- Explanatory Praat Picture visualisation — pitch-class field, applied gain curve, and input/output spectrum.
Quick start
- Select exactly one Sound object in Praat.
- Run
Pitch_Class_Spectral_Gravity.praat. - Choose a Root and Collection.
- Start with Preset = Tonal field.
- Keep Field shape = Continuous for the smooth default behaviour.
- Use Attraction width to decide how narrowly the spectrum gathers around the target pitch classes.
- Use Dry/Wet to blend the transformed result with the original.
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 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.
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.
Pitch collections
The chosen Root transposes the selected pitch-class pattern. Custom mode accepts pitch classes as numbers from 0 to 11.
| Collection | Character / use |
|---|---|
| Major | Diatonic seven-note field. |
| Natural minor | Diatonic minor field. |
| Harmonic minor | Minor collection with raised seventh. |
| Whole tone | Symmetrical six-note field with evenly spaced targets. |
| Octatonic 1 | Half-whole octatonic field. |
| Octatonic 2 | Whole-half octatonic field. |
| Pentatonic major | Open five-note major-oriented field. |
| Pentatonic minor | Open five-note minor-oriented field. |
| Chromatic | All 12 pitch classes; useful for pulling inharmonic energy toward the 12-TET grid rather than toward a key. |
| Custom | User-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.
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.
Controls
| Control | Function |
|---|---|
| Root | Transposes the selected pitch collection: C through B. |
| Collection | Selects the pitch-class set used as the tonal attractor field. |
| Custom pitch classes | Space-separated pitch classes from 0 to 11, used when Collection = Custom. |
| Preset | Sets Attraction strength, Attraction width, Non-target attenuation, and — for Quantised grid — Field shape. |
| Field shape | Continuous smooth field or stepped Quantised field. |
| Attraction strength | Scales the entire gain field from no attraction at 0% to the full requested field at 100%. |
| Attraction width | Gaussian width in semitones. Smaller values create narrower resonant regions around target pitch classes. |
| Non-target attenuation dB | Maximum cut assigned to regions far from the selected collection before Strength scaling. |
| Dry/Wet | 0% = original only; 100% = processed only. |
| Normalize output | When enabled, scales the result to a 0.99 peak. When disabled, the script does not silently rescale the output. |
| Play result | Plays the generated Sound after processing. |
| Draw visualization | Creates the explanatory Praat Picture display. |
| Advanced settings | Opens frequency-range, tuning, band-grid, target-emphasis, and range-preservation controls. |
Advanced settings
| Setting | Default | Function |
|---|---|---|
| Lowest frequency | 40 Hz | Lower boundary of the active spectral-gravity range. |
| Highest frequency | 16000 Hz | Upper boundary, automatically clamped to the Sound's Nyquist frequency. |
| Bands per octave | 24 | 12 / 24 / 36 / 48. Used only by the Quantised field shape. |
| Reference A4 | 440 Hz | Reference tuning used by the log-frequency pitch coordinate. |
| Target emphasis | +6 dB | Maximum boost around collection members before Strength scaling. |
| Preserve below range | On | Leaves frequencies below the analysis range at 0 dB gain. |
| Preserve above range | On | Leaves 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.
Technical behavior
- Processes one selected Sound and never modifies the original.
- Uses one whole-sound FFT / inverse-FFT pass per channel.
- Builds the log-frequency gain field once as a Matrix and performs a lookup for each spectral bin.
- Applies identical gain to real and imaginary spectrum components, preserving each bin's original phase angle during weighting.
- Stereo channels are processed independently with the same tonal field and then recombined.
- The selected analysis range is clamped safely to Nyquist.
- The Info window reports the gain range actually measured from the generated curve, rather than estimating it only from nominal pitch-class distances.
- With normalization off, Dry/Wet = 0% is not silently peak-corrected; peaks above 1.0 are reported instead.
Limitations
- Static field: the transform is applied to the entire Sound at once. It does not follow changing notes or trajectories through time.
- Phase preservation is not transient preservation: applying the same gain to real and imaginary components avoids intentional phase rotation, but sufficiently narrow spectral filtering can still ring in time.
- Radical settings intentionally thin the spectrum: very narrow Attraction width plus strong attenuation behaves more like a resonant comb than gentle tonal colouring.
- No spectral transport: non-target energy is attenuated; it is not physically moved into the nearest target band.
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.
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.