summaryrefslogtreecommitdiff
path: root/doc/AUDIO_LIFECYCLE_REFACTOR.md
AgeCommit message (Collapse)Author
18 hoursfeat(audio): Implement AudioEngine and SpectrogramResourceManager (Task #56 ↵skal
Phase 1) Implements Phase 1 of the audio lifecycle refactor to eliminate initialization order dependencies between synth and tracker. New Components: 1. SpectrogramResourceManager (src/audio/spectrogram_resource_manager.{h,cc}) - Centralized resource loading and ownership - Lazy loading: resources registered but not loaded until needed - Handles both asset spectrograms and procedural notes - Clear ownership: assets borrowed, procedurals owned - Optional cache eviction under DEMO_ENABLE_CACHE_EVICTION flag 2. AudioEngine (src/audio/audio_engine.{h,cc}) - Unified audio subsystem manager - Single initialization point eliminates order dependencies - Manages synth, tracker, and resource manager lifecycle - Timeline seeking API for debugging (!STRIP_ALL) - Clean API: init(), shutdown(), reset(), seek() Features: - Lazy loading strategy with manual preload API - Reset functionality for timeline seeking - Zero impact on production builds - Debug-only seeking support Testing: - Comprehensive test suite (test_audio_engine.cc) - Tests lifecycle, resource loading, reset, seeking - All 20 tests passing (100% pass rate) Bug Fixes: - Fixed infinite recursion in AudioEngine::tracker_reset() Integration: - Added to CMakeLists.txt audio library - No changes to existing code (backward compatible) Binary Size Impact: ~700 bytes (within budget) Next: Phase 2 (Test Migration) - Update existing tests to use AudioEngine Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
19 hoursdocs: Add lazy loading and on-demand strategy to audio refactorskal
Updated AUDIO_LIFECYCLE_REFACTOR.md to support lazy loading instead of eager "load all at init" approach. Key changes: - Lazy loading with 1-2s pre-warming lookahead (recommended) - On-demand decompression for compressed assets (future) - Cache eviction policy for long demos (optional) - Async background loading (post-MVP enhancement) Benefits over eager loading: - Instant startup (no upfront loading delay) - Memory efficient (only load active + upcoming samples) - No trigger stutter (pre-warming prevents load-on-access) - Spreads load cost over time Example timeline: t=0.0s: Load 0 samples (instant) t=0.0s: Pre-warm 3-5 samples for next 2s t=1.0s: Pre-warm 2-3 more samples By t=10s: Only ~10 samples loaded (not all 19) Addresses concern about "load all samples at init" being too costly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
19 hoursdocs: Add SpectrogramResourceManager to audio refactor planskal
Updated AUDIO_LIFECYCLE_REFACTOR.md to explicitly address asset/procedural spectrogram handling and AssetManager relationship. Key additions: - SpectrogramResourceManager component separates resource loading from sequencing - Clear ownership rules: AssetManager owns assets, ResourceManager owns procedurals - Unified interface for both asset and procedural spectrograms - Reduces Tracker responsibility to pattern sequencing only - FAQ section answering common questions about dependencies and caching Architecture change: AudioEngine → { Synth, Tracker, ResourceManager } ResourceManager → { AssetManager, ProceduralGenerator } This addresses the concern about coupling between tracker, synth, and assets. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
19 hoursdocs: Add Audio Lifecycle Refactor plan (Task #56)skal
Created comprehensive design document for refactoring the tracker-synth relationship to eliminate initialization order dependencies. Proposed solution: AudioEngine class that manages both synth and tracker as private members, providing order-independent initialization and clear ownership semantics. Three options analyzed: - Option A: Unified AudioEngine (recommended) - Option B: Registration Handle System - Option C: Reference-Counted Resources Estimated effort: 2-3 weeks with incremental migration path. Binary size impact: ~500 bytes (acceptable). See doc/AUDIO_LIFECYCLE_REFACTOR.md for complete design rationale, implementation plan, and decision matrix. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>