Signal processing
Guitar Chord Analysis
A Rust signal-processing pipeline classifies recorded acoustic-guitar chords from spectral peaks and music-theory templates.
Research prototype · batch matcher implemented
The classification problem
A recorded guitar chord contains fundamentals, overtones, repeated pitch classes, instrument resonances, pick noise, and a changing onset. This project tests a transparent music-theory classifier without a trained machine-learning model.
The controlled dataset contains 72 five-second mono recordings at 44.1 kHz: all 12 chromatic roots crossed with six chord qualities. The Rust repository contains the recordings, analysis code, templates, configuration, tests, and diagnostics.
From a waveform to pitch classes
hound reads each WAV file into normalised samples. rustfft computes the transform and the pipeline forms energy spectral density \(S_k=\lvert V_k\rvert^2\). It keeps positive-frequency maxima that pass percentile, prominence, height, octave-band, and spacing tests.
Each retained frequency is mapped to the nearest equal-tempered note using
Enharmonic spellings collapse to sharp pitch classes. A broad 110–115 Hz feature recurs across this guitar’s recordings, so the matcher removes that range rather than treating it as note evidence.
Whole-recording spectrum
Frequency content through time
A Hann-windowed short-time Fourier transform retains timing using 1,024-sample frames, a 512-sample hop, frequencies to 3 kHz, and decibel power. The Amaj7 view separates the pick onset from sustained bands. The current matcher still scores the full-recording spectrum; its sequence-boundary experiment is unfinished.
Time–frequency output
Template scoring and batch results
The repository constructs 72 templates from interval sets for six chord qualities. ChordMatcher scores filtered peaks using template notes, normalised amplitudes, repeated pitch classes, missing notes, extraneous-note penalties, and seventh-tone evidence. A result is Certain only when its score gap and two-candidate softmax confidence clear fixed thresholds; otherwise it is Ambiguous. Empty evidence returns NoMatch.
The maintained batch command returns 69 certain correct results. Gmin, Gsus2, and G#maj remain ambiguous, and the matrix leaves them unresolved rather than converting their best candidate into a pass.
Controlled batch evaluation
Analysis outputs
The tools write logs, Markdown candidate tables, and a CSV of component scores, pitch classes, and outcomes; certain matches can also produce SVG fretboards. Tests cover signal helpers, filtering, pitch conversion, templates, matcher terms, spectrogram dimensions, loading, logging, and diagram generation. These outputs expose why a classification passed or failed, but they do not replace evaluation on independent recordings.
Limitations
This prototype was evaluated on the same controlled library used to tune its heuristic weights and thresholds. It has not been tested across players, instruments, microphones, rooms, noise, inversions, or arbitrary voicings. It collapses enharmonic spellings, covers six qualities, and uses hand-tuned rules. The sequence detector over-segments its demonstrations and is neither a real-time recogniser nor a finished application.