How dhananjayanrajan/atmostream works
1. Atmostream is a dual-edition desktop audio player. The repository contains a native C++/GTK application as the main product and a Bash-based “Lite” edition that reuses the same configuration and state concepts but drives external tools from shell scripts.
2. The C++ edition is organized around a controller-centric architecture. main.cpp starts GTK, sets process/runtime defaults, and hands control to ApplicationController, which owns startup, wiring, lifecycle, and periodic UI refreshes.
3. The C++ codebase uses dependency inversion heavily. src/interfaces/ defines the contracts, src/core/ provides concrete services, src/features/ contains self-contained feature modules, src/ui/ provides reusable windows/dialogs, and src/platform/ contains OS-specific integration. Feature code depends on interfaces, not concrete implementations.
4. The central runtime data path is audio playback. AudioEngine wraps three mpv-backed streams: narration/main, ambience, and noise. PipeWireManager builds the downstream audio graph, including low-pass filtering, sidechain compression, and optional noise generation, then routes everything to the system sink.
5. The application’s audio behavior is intentionally layered. The main track carries speech, ambience ducks under narration through PipeWire sidechain control, and the noise layer is filtered to stay unobtrusive. Volume hierarchy is enforced in the controller/service layer so noise never exceeds ambience, and ambience never exceeds main.
6. Persistent state is isolated in StateManager and stored as JSON under the user data directory. It handles resume data, bookmarks/markers, favorites, presets, settings, and statistics. Writes are atomic, and older bookmark formats are migrated on read.
7. Configuration is separate from state and is loaded by ConfigLoader. The app merges plain-text config files from local, system, and user locations, then uses them for channel maps, source pools, defaults, thresholds, and fallback URLs.
8. Source acquisition is its own subsystem. SourcesManager and the Librivox browser deal with YouTube-facing selection and validation, while LauncherDialog provides the GTK UI for browsing channels and videos. The C++ edition fetches playable URLs and metadata via yt-dlp-style flows rather than embedding a browser.
9. UI is split into tray, mini player, launch dialogs, and feature panels. TrayManager is the primary shell, MiniPlayer is a floating overlay, VolumePanel exposes mixer controls and safe-listening limits, and the various feature panels are standalone dialogs that can be shown or hidden from the tray menu.
10. Platform integration is explicit and separate from business logic. mpris2.cpp exposes the app on the desktop session bus for media controls, hotkeys.cpp captures global X11 media keys, and safe_listening.h models device detection and conservative output-volume limits.
11. Feature modules are mostly independent vertical slices under src/features/. Each folder bundles its own logic and panel for a specific capability such as binaural beats, cinematic DSP presets, voice profiles, timers, favorites, stats, quick EQ, bookmarks, drift detection, auto-ambience, noise generation, and source browsing.
12. The Bash Lite edition mirrors the same domain concepts with a simpler execution model. bash/bin/atmostream-lite sources modular scripts for core lifecycle, audio setup, UI rendering, input handling, state save, source selection, MPRIS-style command forwarding, and cleanup. It runs external mpv processes, manages PipeWire links from shell, and falls back from TUI to a single-line status display when terminal capabilities are limited.
13. The main architectural boundary between editions is control plane versus audio plane. In C++, the control plane is in-process and GUI-driven; in Bash, it is script-driven and terminal-driven. In both cases, the audio plane is still built around mpv plus PipeWire plus Calf LV2 plugins, so the user-visible feature set stays aligned.
14. tests/ contains focused checks for core services and panel construction, which reinforces the repo’s modular design: service contracts can be validated independently from the UI shell, and panels can be instantiated without relying on the whole application.
Main entry points: feature_coordinator.cpp Feature Coord · application_controller.cpp App Controller · ui_context.cpp UI Context · app_startup.cpp Startup
Components 34
C++ Edition
Native GTK desktop application and its layered subsystems.
- main · Starts GTK, sets runtime defaults, and enters the controller-driven app.
src/main.cpp - App Controller · Owns startup, wiring, lifecycle, and periodic refresh for the native app.
src/application_controller.cpp - Startup · Builds the initial application services and connects the runtime pieces.
src/controller/app_startup.cpp - Audio Control · Enforces playback layering and volume hierarchy across the audio stack.
src/controller/audio_controller.cpp - Feature Coord · Coordinates feature modules and their activation within the app.
src/controller/feature_coordinator.cpp - Panel Manager · Opens, hides, and tracks feature panels and dialogs.
src/controller/panel_manager.cpp - Session Manager · Tracks active session flow and restores runtime context.
src/controller/session_manager.cpp - Timer Ctrl · Coordinates pomodoro and sleep-timer behavior.
src/controller/timer_controller.cpp - Tray Ctrl · Drives the tray shell and user-visible app commands.
src/controller/tray_controller.cpp - Audio Engine · Wraps the narration, ambience, and noise streams backed by mpv.
src/core/audio/audio_engine.cpp - PipeWire · Builds downstream filtering, sidechain compression, and system sink routing.
src/core/audio/pipewire.cpp - Config Loader · Merges local, system, and user config files into runtime defaults.
src/core/config/config_loader.cpp - State Manager · Stores JSON state for resume data, bookmarks, favorites, presets, settings, and stats.
src/core/state/state_manager.cpp - Sources · Resolves playable source URLs and metadata through provider flows.
src/core/sources/sources.cpp - UI Context · Provides shared UI wiring and context for windows and panels.
src/ui/ui_context.cpp - Tray · Primary tray window and menu entry point for the native edition.
src/ui/tray/tray_manager.cpp - Mini Player · Floating compact player for quick playback control.
src/ui/mini_player/mini_player.cpp - Volume Panel · Exposes mixer controls and safe-listening limits.
src/ui/volume_panel/volume_panel.cpp - Launcher · GTK dialog for browsing channels and videos before playback.
src/ui/launcher_dialog/launcher_dialog.cpp - Platform · Implements session-bus media control, global hotkeys, and conservative output limits.
src/platform/mpris2.cpp - Binaural · Generates binaural beats and its panel.
src/features/binaural/binaural_generator.cpp - Cinematic · Encapsulates cinematic DSP presets and controls.
src/features/cinematic/cinematic_panel.cpp - Voice Profile · Models voice-profile behavior and panel controls.
src/features/voice_profile/voice_profile_panel.cpp - Bookmarks · Manages chapters and playback bookmarks.
src/features/bookmarks/playback_panel.cpp - Favorites · Tracks saved favorites and related panel UI.
src/features/favorites/favorites_manager.cpp - Stats · Collects usage statistics and displays the stats panel.
src/features/stats/stats_collector.cpp - Quick EQ · Provides fast equalizer controls and presets.
src/features/quick_eq/quick_eq.cpp - Timers · Bundles pomodoro and sleep timer implementations.
src/features/timers/pomodoro_timer.cpp - Drift Detect · Detects playback drift and related anomalies.
src/features/drift_detection/drift_detector.cpp - Noise Gen · Generates unobtrusive background noise and its panel.
src/features/noise_generator/noise_generator_panel.cpp - Auto Ambience · Adjusts ambience from time-of-day context.
src/features/auto_ambience/time_of_day_ambience.cpp - Librivox Browser · Binds source browsing and validation to the launcher flow.
src/features/sources/librivox_browser.cpp
Lite Edition
Shell-driven edition that reuses the same audio/state concepts.
- lite entry · Sources modular shell libraries and starts the Lite runtime.
bash/bin/atmostream-lite - core.sh · Lite runtime lifecycle and shared shell coordination.
bash/lib/core.sh
Connections 35
- main → App Controller: starts · Main hands control to the application controller.
- App Controller → Startup: bootstraps · Controller delegates service wiring and startup.
- App Controller → Audio Control: coordinates · Keeps playback and volume rules consistent.
- App Controller → Feature Coord: enables · Activates feature modules.
- App Controller → Panel Manager: manages · Opens and closes feature panels.
- App Controller → Session Manager: tracks · Maintains runtime session state.
- App Controller → Timer Ctrl: drives · Routes timer behavior through the controller.
- App Controller → Tray Ctrl: exposes · Connects the app to tray actions.
- Startup → Config Loader: loads · Startup reads merged configuration.
- Startup → State Manager: restores · Startup hydrates persisted state.
- Audio Control → Audio Engine: uses · Controller commands the audio engine.
- Audio Engine → PipeWire: routes · Audio engine feeds PipeWire graph construction.
- Audio Control → Platform: limits · Applies safe-listening and device constraints.
- Feature Coord → Binaural: loads · Coordinates feature modules.
- Feature Coord → Cinematic: loads · Coordinates feature modules.
- Feature Coord → Voice Profile: loads · Coordinates feature modules.
- Feature Coord → Bookmarks: loads · Coordinates feature modules.
- Feature Coord → Favorites: loads · Coordinates feature modules.
- Feature Coord → Stats: loads · Coordinates feature modules.
- Feature Coord → Quick EQ: loads · Coordinates feature modules.
- Feature Coord → Timers: loads · Coordinates feature modules.
- Feature Coord → Drift Detect: loads · Coordinates feature modules.
- Feature Coord → Noise Gen: loads · Coordinates feature modules.
- Feature Coord → Auto Ambience: loads · Coordinates feature modules.
- Panel Manager → UI Context: composes · Panel manager builds UI surfaces in the shared context.
- UI Context → Tray: hosts · Shared UI context includes the tray shell.
- UI Context → Mini Player: hosts · Shared UI context includes the mini player.
- UI Context → Volume Panel: hosts · Shared UI context includes the volume panel.
- UI Context → Launcher: hosts · Shared UI context includes the source launcher.
- Launcher → Sources: queries · Launcher feeds source discovery and validation.
- Sources → Librivox Browser: browses · Source acquisition includes Librivox-facing browsing.
- State Manager → Config Loader: separates · Persistent state is distinct from loaded configuration.
- Tray Ctrl → Tray: drives · Tray controller manipulates the tray shell.
- Platform → Tray Ctrl: integrates · Desktop integration supports controller commands and shortcuts.
- lite entry → core.sh: sources · Lite entrypoint assembles runtime from shell modules.