- Printing spectral histograms of incoming audio to console
- Basic pitch detection and chord guessing algorithms
Started as an excuse to learn and implement the (simplest version of the) FFT. Uses SDL2 to record audio and performs FFT on it. Then interprets and/or visualizes FFT results.
VISUALIZER OPTIONS
Scaled Spectrum
- Fixed semilog
- Fixed linear
- Fixed log-log
- Adaptive semilog
- Adaptive linear
- Adaptive log-log
Wrapped Spectrum (Spectral Guitar Tuner)
- Fixed
- Adaptive
Music Algorithms
- Pitch recognition (automatic tuner)
- Chord Guesser
"Plots" a spectral histogram to the console with linear, semilog, or log-log scaling. And repeat.
Uses GetConsoleScreenBufferInfo()
to find console dimensions and scale graph accordingly. Uses system("cls")
to refresh the console between frames. Which is not great, but eh.
Guitar tuner mode is semilog scaling that wraps around at the octave. i.e., The coefficient of 55Hz (A1) adds to 110Hz (A2), 220Hz (A3) etc. Octave-marking information is thus effectively discarded, but information of flatness or sharpness is retained. Logic explained in YouTube Video.
This performs pitch detection by identifying peaks in the FFT and finding the "approximate HCF" (i.e., fundamental frequency corresponding to an arbitrary subset of harmonics) using continued fractions. Tuner display is a needle-and-dial type, but the needle stays fixed and the dial moves, to prevent erratic needle motions near quarter-tone points.
This attempts to name a chord by assigning pitch names to spectral spikes. Hit-or-miss, but often guesses something at least close-sounding.