SpectraScore – User Guide

Analyzes target sounds and generates microtonal orchestral scores by matching spectral characteristics to instrument combinations using harmonic voicing strategies.

Category: Spectral Analysis / Orchestration Praat Script: SpectraScore.praat
Contents:

What this does

SpectraScore is a lightweight spectral orchestration tool inspired by IRCAM's Orchidée and Orchidea systems. It analyzes a target sound's acoustic properties (pitch, loudness, timbre, harmonicity) and automatically searches through combinations of orchestral instruments to find the best timbral match. The script extracts fundamental frequency via autocorrelation, measures intensity for dynamic assignment (pp/mf/ff), calculates spectral centroid (brightness) and spread (texture), and analyzes harmonic energy distribution across six frequency bands. Using this spectral fingerprint, it searches through 1 to K instrument combinations (K=2–12), scoring each based on weighted distance between target and combined instrument timbres, with smart heuristics to avoid doubling the same section unless divisi is allowed and to prevent dynamic overshooting. The output is a complete MusicXML score with proper transpositions, clefs, and whole-note durations, where instruments can be voiced in unison, distributed across octaves, arranged as chords, or—most powerfully—assigned to specific harmonics in a spectral orchestration strategy that matches each instrument's natural brightness to reinforce particular overtones of the target sound. The system supports full microtonal tuning with configurable precision (quarter-tones, eighth-tones, or finer), calculating exact cent deviations for each harmonic and encoding them in MusicXML with both <alter> values and <accidental> symbols for compatibility with notation software like bach.score, Finale, or Dorico, making it invaluable for composers exploring spectral orchestration, timbre-matching, computer-assisted composition, or anyone wanting to analyze a sound and receive an instant, musically meaningful orchestral transcription that captures its essence.

Orchestration Theory

SpectraScore implements a simplified version of target-matching orchestration pioneered by IRCAM. The theoretical foundation:

Core Principle

Orchestral instruments have characteristic spectral signatures defined by their centroid (brightness), spread (spectral width), and harmonic structure. By measuring these features in a target sound and comparing them to a database of instrument timbres, we can find instrument combinations that approximate the target.

Analysis Pipeline

  1. Pitch Detection: To Pitch (ac)... extracts F0 via autocorrelation
  2. Intensity: To Intensity... measures mean dB → dynamic (pp/mf/ff)
  3. Harmonicity: To Harmonicity (cc)... extracts HNR (harmonic-to-noise ratio)
  4. Spectrum: To Spectrum → centroid (brightness), spread (texture)
  5. Band Energy: Six frequency bands (50–10000 Hz) capture energy distribution

Distance Metric

Each instrument combination is scored using weighted Euclidean distance:

score = |centroid_target - centroid_inst| / 2000 
      + |spread_target - spread_inst| / 1000
      + 0.5 × |odd_even_target - odd_even_inst|

Lower scores indicate better matches. The search explores all combinations from K=1 to max_combination_size.

Spectral Mixing

For combinations, spectra are linearly mixed (averaged), and descriptors are recomputed. This approximates acoustic superposition without requiring convolution.

Voicing Strategies

SpectraScore offers four orchestration approaches:

1. Unison

All instruments play the root note (fundamental frequency). Simple doubling for reinforcement.

2. Octaves

Instruments are distributed across octaves based on their brightness:

  • Dark instruments (centroid < 500 Hz): octave below root
  • Medium instruments (500–1200 Hz): root octave
  • Bright instruments (centroid > 1200 Hz): octave above root

3. Chord

Harmonic voicing based on ensemble size:

  • 2 instruments: root + perfect fifth (P5)
  • 3 instruments: root + P5 + octave
  • 4+ instruments: root + major third + P5 + octave

4. Spectral (Recommended)

True spectral orchestration: Each instrument is assigned to reinforce a specific harmonic (H1–H16) based on matching its natural brightness to that harmonic's frequency.

Example: For F0 = 116 Hz:

  • H7 = 814 Hz → matches Cello (centroid ~580 Hz) → assigns note with microtonal tuning
  • H11 = 1280 Hz → matches Violin (centroid ~1250 Hz) → -49 cents
  • H13 = 1513 Hz → matches Flute (centroid ~1600 Hz) → -41 cents
For microtones: Set min_harmonic = 7. Low harmonics (H1–H6) are nearly in tune with 12-TET, while H7+ have significant cent deviations.

Instrument Database

Twelve orchestral instruments with realistic ranges, transpositions, and timbre statistics for three dynamics:

InstrumentCodeRange (MIDI)TransposeClefBrightness (ff)
Bass TromboneBTb28–600F600 Hz
BassoonBn34–750F680 Hz
ContrabassCb28–67-12F520 Hz
Clarinet (B♭)ClVv50–94+2G1500 Hz
FluteFl60–960G2200 Hz
Horn (F)Hn34–77-7G850 Hz
OboeOb58–910G1800 Hz
TromboneTbn40–720F680 Hz
Trumpet (C)TpC52–820G2100 Hz
ViolaVa48–840C1200 Hz
CelloVc36–760F820 Hz
ViolinVn55–1030G1750 Hz

Brightness values are spectral centroids at ff dynamic. The database includes centroid, spread, and odd/even harmonic ratios for pp, mf, and ff.

Quick start

  1. In Praat, select exactly one Sound object (your target sound).
  2. Run script…SpectraScore.praat.
  3. Choose instruments to enable (check/uncheck boxes).
  4. Set voicing_strategy to Spectral for best results.
  5. For microtones: set min_harmonic = 7, microtone_precision = 12.5.
  6. Set max_combination_size (2–12 for fuller orchestration).
  7. Click OK.
  8. The script prints analysis + MusicXML to the Info window.
  9. Copy the MusicXML output and save as .musicxml file.
  10. Import into Finale, Dorico, or Max/MSP bach.score.

Parameters (form fields)

ParameterTypeDefaultDescription
BTb, Bn, Cb, ... VnbooleancheckedEnable/disable each instrument in the search. Uncheck instruments you don't want to use.
max_combination_sizeinteger4Maximum number of simultaneous instruments (K). Set to 8–12 for full orchestration. Higher values increase search time.
allow_divisibooleanuncheckedIf checked, allows the same instrument section to appear multiple times (e.g., Vn1 + Vn2).
loudness_overshoot_limit_(dB)real6Maximum dB by which ensemble loudness can exceed target. Prevents over-orchestration.
voicing_strategyoptionmenuSpectral Unison: all on root
Octaves: spread by brightness
Chord: root + 3rd + 5th + 8ve
Spectral: match harmonics (recommended)
enable_microtonesbooleancheckedCalculate and encode microtonal cent deviations in MusicXML.
microtone_precision_(cents)real12.5Quantization step. Use 12.5 for eighth-tones (tonedivision 8), 25 for quarter-tones, 50 for half-quarter-tones.
min_harmonicinteger7Minimum harmonic number for spectral voicing. Set to 7 for strong microtones; 1 for natural matching (may yield in-tune notes).
max_harmonicinteger16Maximum harmonic number. Higher harmonics = brighter, more microtonal voicing.

Outputs

The script prints to the Info window:

MusicXML Structure

The generated score includes:

Microtones in bach.score

To display microtones in Max/MSP bach.score:

  1. Set tonedivision to 8 (eighth-tones) before importing MusicXML
  2. Use microtone_precision = 12.5 in the script (12.5 cents = 1/8 tone)
  3. Set min_harmonic = 7 to force higher harmonics with significant cent deviations
  4. Import the MusicXML file into bach.score
  5. The <accidental> tags will display as quarter-sharp/flat symbols
  6. The <alter> values control playback pitch
Why H7+? Low harmonics (H1–H6) are nearly just-intonation perfect: H1=0¢, H2=0¢, H3≈+2¢, H4=0¢, H5=-14¢, H6=+2¢. Higher harmonics have strong deviations: H7=-31¢, H11=-49¢, H13=-41¢, H14=+31¢, making them ideal for microtonal orchestration.

Accidental Symbols

The script automatically adds MusicXML accidentals based on cent deviation: