How alexkay/spek works
Project type and purpose
• Spek is a native desktop application written in C++.
• Purpose: perform acoustic spectrum analysis of audio files, using FFmpeg for decoding and wxWidgets for GUI.
File structure
• Top-level:
• src/ – C++ source: core engine, FFT, pipeline, UI, platform abstraction
• po/ – translations
• tests/ – unit and performance tests
• dist/ – packaging scripts for Debian, FreeBSD, macOS, Windows
• build scripts: autogen.sh, configure.ac, Makefile.am
• Naming conventions reveal modules: “spek-audio”, “spek-fft”, “spek-pipeline”, “spek-window”, etc.
README for architecture clues
• Dependencies: FFmpeg (decoding) + wxWidgets (GUI)
Main components and interactions
a. External libraries
• FFmpeg libavcodec/libavformat – audio decoding
• wxWidgets – cross-platform GUI, event loop
b. Core engine modules (src/)
• AudioDecoder (spek-audio.cc/h)
• FFTProcessor (spek-fft.cc/h)
• Utils (spek-utils): file I/O, format detection
c. UI modules
• MainWindow (spek-window.cc/h)
• SpectrogramView (spek-spectrogram.cc/h)
• Ruler / Artwork (spek-ruler, spek-artwork)
• PreferencesDialog (spek-preferences-dialog) + Preferences backend
• EventDispatcher (spek-events)
d. Platform abstraction
• spek-platform: file paths, config location (XDG_CONFIG_HOME), thread primitives
e. Assets & configuration
• web/ (man pages), INSTALL.md, MANUAL.md
f. Testing
• tests/test-*.cc, tests/perf.cc verify decoding, FFT, pipeline, utils
Relationships and data flow
• User opens audio file → MainWindow sends request to Pipeline
• Pipeline calls AudioDecoder → raw PCM frames
• PCM frames → FFTProcessor → power spectrum data
• Bitmap → SpectrogramView → rendered in MainWindow
• Preferences feed into Pipeline (window size, function) and PaletteManager
• EventDispatcher routes UI events (file open, prefs change)
Architectural patterns and design principles
• MVC-like separation:
• Model = core engine (decoder, FFT, pipeline)
• View = SpectrogramView + MainWindow
• Controller = EventDispatcher + UI dialogs
• Modular design: each functionality in its own cc/h pair
• Cross-platform abstraction layer isolates OS-specific code
• Build system: autoconf/automake enables multi-platform packaging
• Internationalization with gettext (po/)
Final checklist
• All major components (decoding, FFT, pipeline, palette, UI, platform)
• External services/libraries (FFmpeg, wxWidgets)
• Version/build system note (Autotools)