SpectraScore – User Guide
Analyzes target sounds and generates microtonal orchestral scores by matching spectral characteristics to instrument combinations using harmonic voicing strategies.
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
- Pitch Detection:
To Pitch (ac)...extracts F0 via autocorrelation - Intensity:
To Intensity...measures mean dB → dynamic (pp/mf/ff) - Harmonicity:
To Harmonicity (cc)...extracts HNR (harmonic-to-noise ratio) - Spectrum:
To Spectrum→ centroid (brightness), spread (texture) - 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
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:
| Instrument | Code | Range (MIDI) | Transpose | Clef | Brightness (ff) |
|---|---|---|---|---|---|
| Bass Trombone | BTb | 28–60 | 0 | F | 600 Hz |
| Bassoon | Bn | 34–75 | 0 | F | 680 Hz |
| Contrabass | Cb | 28–67 | -12 | F | 520 Hz |
| Clarinet (B♭) | ClVv | 50–94 | +2 | G | 1500 Hz |
| Flute | Fl | 60–96 | 0 | G | 2200 Hz |
| Horn (F) | Hn | 34–77 | -7 | G | 850 Hz |
| Oboe | Ob | 58–91 | 0 | G | 1800 Hz |
| Trombone | Tbn | 40–72 | 0 | F | 680 Hz |
| Trumpet (C) | TpC | 52–82 | 0 | G | 2100 Hz |
| Viola | Va | 48–84 | 0 | C | 1200 Hz |
| Cello | Vc | 36–76 | 0 | F | 820 Hz |
| Violin | Vn | 55–103 | 0 | G | 1750 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
- In Praat, select exactly one Sound object (your target sound).
- Run script… →
SpectraScore.praat. - Choose instruments to enable (check/uncheck boxes).
- Set
voicing_strategyto Spectral for best results. - For microtones: set
min_harmonic = 7,microtone_precision = 12.5. - Set
max_combination_size(2–12 for fuller orchestration). - Click OK.
- The script prints analysis + MusicXML to the Info window.
- Copy the MusicXML output and save as
.musicxmlfile. - Import into Finale, Dorico, or Max/MSP bach.score.
Parameters (form fields)
| Parameter | Type | Default | Description |
|---|---|---|---|
| BTb, Bn, Cb, ... Vn | boolean | checked | Enable/disable each instrument in the search. Uncheck instruments you don't want to use. |
| max_combination_size | integer | 4 | Maximum number of simultaneous instruments (K). Set to 8–12 for full orchestration. Higher values increase search time. |
| allow_divisi | boolean | unchecked | If checked, allows the same instrument section to appear multiple times (e.g., Vn1 + Vn2). |
| loudness_overshoot_limit_(dB) | real | 6 | Maximum dB by which ensemble loudness can exceed target. Prevents over-orchestration. |
| voicing_strategy | optionmenu | Spectral |
Unison: all on root Octaves: spread by brightness Chord: root + 3rd + 5th + 8ve Spectral: match harmonics (recommended) |
| enable_microtones | boolean | checked | Calculate and encode microtonal cent deviations in MusicXML. |
| microtone_precision_(cents) | real | 12.5 | Quantization step. Use 12.5 for eighth-tones (tonedivision 8), 25 for quarter-tones, 50 for half-quarter-tones. |
| min_harmonic | integer | 7 | Minimum harmonic number for spectral voicing. Set to 7 for strong microtones; 1 for natural matching (may yield in-tune notes). |
| max_harmonic | integer | 16 | Maximum harmonic number. Higher harmonics = brighter, more microtonal voicing. |
Outputs
The script prints to the Info window:
- Target Analysis: F0, intensity, HNR, centroid, spread, spectral bands
- Search Progress: Shows combinations tested and scores at each K level
- Best Match: Lists selected instruments with final score
- Voicing Assignments: Shows which harmonic each instrument reinforces, with MIDI note + cent offset
- Microtonal Alter Values: Debug output showing
<alter>calculations - MusicXML Output: Complete MusicXML 3.1 score ready to copy/paste
MusicXML Structure
The generated score includes:
- One part per instrument with proper
<part-name> - Correct clef (
<sign>G/F/C</sign>) - Transposition for B♭/F instruments (
<transpose><chromatic>) - Whole-note duration (
<type>whole</type>) - Dynamic marking (
<dynamics><pp/mf/ff/>) - Microtones:
<alter>0.63</alter>(decimal semitones) +<accidental>quarter-flat</accidental>
Microtones in bach.score
To display microtones in Max/MSP bach.score:
- Set tonedivision to
8(eighth-tones) before importing MusicXML - Use
microtone_precision = 12.5in the script (12.5 cents = 1/8 tone) - Set
min_harmonic = 7to force higher harmonics with significant cent deviations - Import the MusicXML file into bach.score
- The
<accidental>tags will display as quarter-sharp/flat symbols - The
<alter>values control playback pitch
Accidental Symbols
The script automatically adds MusicXML accidentals based on cent deviation:
- 12.5–37.5 cents:
sharp-up/flat-down(small arrow) - 37.5–62.5 cents:
quarter-sharp/quarter-flat - 62.5–87.5 cents:
three-quarters-sharp/three-quarters-flat