How projectm-visualizer/frontend-sdl-cpp works
Project type and purpose
• This is a desktop full-stack C++ application (“projectMSDL”), serving as an SDL2-based frontend for the projectM music visualization library.
• It captures audio input, feeds it into libprojectM, renders visuals in real time, and provides a GUI overlay plus system notifications.
File structure
• Top-level CMake files and scripts (CMakeLists.txt, cmake/*) define a cross-platform build system.
• src/ holds the core modules:
• AudioCapture (SDL and WASAPI backends)
• ProjectMWrapper (bridge to libprojectM)
• RenderLoop and FPSLimiter
• SDLRenderingWindow (window & OpenGL context)
• main.cpp (app entry point)
• src/gui/ contains the GUI windows and widgets (menus, dialogs, preset selector, toasts).
• src/notifications/ contains adapters to post system toast/playback control/quit notifications.
• src/resources/ holds shipped presets, desktop file, license.
• vendor/, vcpkg.json indicate dependency management; .github/ holds CI.
README for additional insights
• Lists external dependencies (SDL2, POCO, FreeType, libprojectM).
• Describes build & install via CMake.
• Mentions how the application uses configuration files and runtime arguments.
Main components & interactions
a. Components
1. Audio Capture Layer
• AudioCaptureSDL / AudioCaptureWASAPI
2. libprojectM Integration
• ProjectMWrapper → invokes projectM core for FFT + visual generation
3. Rendering Layer
• RenderLoop + FPSLimiter
• SDLRenderingWindow → OpenGL context
4. GUI Layer
• ProjectMGUI orchestrates windows (MainMenu, FileChooser, SettingsWindow, etc.)
5. Notification Layer
• DisplayToastNotification, PlaybackControlNotification, QuitNotification, UpdateWindowTitleNotification
6. Resources & Configuration
• presets, textures, projectMSDL.properties
7. External Dependencies
• SDL2, POCO, FreeType, libprojectM
b. Relationships & data flow
• Audio Capture → feeds audio samples → ProjectMWrapper
• RenderLoop + SDLRenderingWindow → draws visuals on screen
• GUI Layer → overlays UI, sends user commands → may affect ProjectMWrapper (e.g. change preset)
• Notification Layer → listens to events (track change, quit) → invokes OS notifications via POCO
• Resources loaded at startup (preset and texture paths)
c. Architectural patterns & principles
• Strategy pattern for pluggable AudioCapture backends
• Wrapper/facade around libprojectM
• Modular separation: capture → processing → rendering → UI → notifications
• CMake-driven dependency injection via FIND_PACKAGE and vcpkg
d. Key technologies
• C++17, CMake
• SDL2 for input, window, GL context
• OpenGL (via SDL2) for rendering visuals
• POCO for cross-platform notifications and filesystem
• FreeType for UI text (optional)
• libprojectM for FFT & visualization logic
Elements
• Audio data → ProjectMWrapper
• Frame commands → RenderLoop → SDLRenderingWindow
• UI actions → ProjectMWrapper or RenderLoop
• Events → Notification modules
• Core engine (blue)
• UI (green)
• Notifications (orange)
• External deps (gray)
• Rectangles for modules
• Clouds or parallelograms for external libs