Not Yet Another Spectrum Analyzer – Open-Source Real-Time FFT Analyzer

...and how to do so...
Post Reply New Topic
RELATED
PRODUCTS

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
Not Yet Another Spectrum Analyzer is a compiled version of the original open-source https://github.com/sylwekkominek/SpectrumAnalyzer (https://github.com/sylwekkominek/SpectrumAnalyzer) project available for free on the Microsoft Store. Unlike the Python-based implementation, this version uses PortAudio for microphone data acquisition while keeping the rest of the processing pipeline in C++.

The application captures audio samples from the system’s microphone, performs real-time FFT computation, and visualizes the frequency spectrum using OpenGL rendering.

Visualization parameters — including bar count, frequency ranges, color themes, and animation behavior — are configurable via text files located in the configuration directory:

C:\Users\{User}\Documents\NotYetAnotherSpectrumAnalyzer\config

Users can also create their own themes by copying the contents of advancedColorSettings.txt and backgroundColorSettings.txt from the configuration folder into ChatGPT and asking it to “Create something unique.”

Not Yet Another Spectrum Analyzer is useful for learning, signal analysis, experimentation, and entertainment.

The core of this project is the AudioSpectrumAnalyzer class, which manages the entire process using several parallel threads for real-time performance:
IMG_0514.png

samplesUpdater – collects audio data using PortAudio and places it into a queue.

fftCalculator – applies a window function and computes the FFT using the FFTW library. It uses Welch’s method with overlapping to increase the number of frames per second (FPS), which is crucial for smooth animation.

processing – processes FFT data, applies gain correction, peak hold, averaging and smoothing.

drafter – converts dBFS levels into vertex offsets sent to the GPU to render the bars.

flowController – monitors the current FPS and dynamically adjusts the amount of overlapping used in Welch’s method. This adaptive algorithm automatically increases or decreases overlap depending on hardware performance and the desired FPS set in config.py.

Why Welch’s method and overlapping are necessary

To accurately detect low frequencies (such as 20–50 Hz) at the commonly used sampling rate of 44,100 Hz, the application processes audio in chunks of 4096 samples.

This results in a frequency resolution of approximately 10.77 Hz for the FFT (calculated by dividing 44,100 by 4096). In simpler terms, the FFT measures energy in discrete frequency steps of about 10.77 Hz.

Processing 4096 samples at once means a new analysis frame is created roughly every 4096 ÷ 44,100 ≈ 93 milliseconds, which equals about 11 frames per second (FPS) — too low for smooth real-time visualization.

To improve responsiveness without sacrificing low-frequency resolution, the application uses overlapping windows based on Welch’s method. Instead of waiting for a completely new block of 4096 samples, it shifts the analysis window forward by a smaller step (for example, 512 or 1024 samples), reusing much of the previous data. This significantly increases the number of analysis frames per second — allowing for smooth 60 FPS animation while still analyzing long enough segments to preserve detail in the bass range.

Full documentation: https://sylwekkominek.github.io/SpectrumAnalyzer/ (https://sylwekkominek.github.io/SpectrumAnalyzer/)

Feel free to use the code or play with the compiled version.

IMG_0554.jpeg
IMG_0553.jpeg
IMG_0542.jpeg
You do not have the required permissions to view the files attached to this post.

Post

Looks nice.

Can I run it on audio files?

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
Thanks, it’s possible to run audio files, but the playback needs to be implemented in Python.
This file would require some modifications: https://github.com/sylwekkominek/Spectr ... oConfig.py (https://github.com/sylwekkominek/SpectrumAnalyzer/blob/main/audioConfig.py)

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
Quick update: I’ve added a new version of the app that now supports both logarithmic and linear measurements.

https://github.com/sylwekkominek/SpectrumAnalyzer (https://github.com/sylwekkominek/SpectrumAnalyzer)
IMG_0591.png
IMG_0592.png
IMG_0593.png
IMG_0594.png
IMG_0595.png
IMG_0596.png
IMG_0597.png
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “DIY: Build it and they will come”