diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-07 15:34:46 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-07 15:34:46 +0100 |
| commit | a9a151a4fdcd46f4737abe98c654c1ec619ef425 (patch) | |
| tree | 33d0bf801552cd21a9dd008d32c79cbe6c4c3e72 /doc/PEAK_FIX_SUMMARY.md | |
| parent | a0dd0a27c4d6831fb2fb5ad81283f36512ef16ef (diff) | |
docs: Reorganize documentation with tiered hierarchy for context optimization
Major documentation reorganization to reduce AI agent context size by ~58%
and establish sustainable maintenance practices.
## File Moves (Root → doc/)
- Move COMPLETED.md (new), HANDOFF*.md, *_ANALYSIS.md, *_SUMMARY.md to doc/
- Keep only 5 essential files in root: CLAUDE.md, GEMINI.md, PROJECT_CONTEXT.md, TODO.md, README.md
- Result: Clean root directory with clear project essentials
## New Documentation
- doc/CONTEXT_MAINTENANCE.md: Comprehensive guide for keeping context clean
- 4-tier hierarchy (Critical/Technical/Design/Archive)
- Maintenance schedules (after milestones, monthly, on-demand)
- Size targets, red flags, workflows
- Monthly checklist template
- doc/COMPLETED.md: Historical archive of completed milestones
- Moved "Recently Completed" sections from TODO.md and PROJECT_CONTEXT.md
- Detailed completion history (February 4-7, 2026)
- Frees up ~200 lines from active context
## Agent Config Updates
- CLAUDE.md: Restructured with 4-tier hierarchy
- Tier 1: Critical (always loaded) - 3 files
- Tier 2: Technical (always loaded) - 3 files
- Tier 3: Design (on-demand) - 9 files
- Tier 4: Archive (rarely) - 10 files
- Clear usage instructions for on-demand loading
- GEMINI.md: Same tier structure + Gemini-specific state snapshot
- Consistent with CLAUDE.md hierarchy
- Preserved agent-specific context
## Content Optimization
- PROJECT_CONTEXT.md: Removed verbose milestones (~160 lines)
- Replaced with concise "Current Status" summary
- Points to COMPLETED.md for history
- TODO.md: Removed Task #51 detailed plan (~200 lines)
- Marked Task #51 as completed
- Kept only active/next tasks
## Impact
- Context size: 70K → 29K tokens (58% reduction)
- Root directory: 15 → 5 files (67% cleaner)
- Tier 1-2 files: 7,329 words (well under 10K target)
- Documented maintenance process for sustainability
## Files Changed
Modified: CLAUDE.md, GEMINI.md, PROJECT_CONTEXT.md, TODO.md
New: doc/COMPLETED.md, doc/CONTEXT_MAINTENANCE.md
Moved: 10 technical docs from root to doc/
Diffstat (limited to 'doc/PEAK_FIX_SUMMARY.md')
| -rw-r--r-- | doc/PEAK_FIX_SUMMARY.md | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/doc/PEAK_FIX_SUMMARY.md b/doc/PEAK_FIX_SUMMARY.md new file mode 100644 index 0000000..cf42233 --- /dev/null +++ b/doc/PEAK_FIX_SUMMARY.md @@ -0,0 +1,78 @@ +# Audio Peak Measurement Fix Summary + +## Issues Found and Fixed + +### Issue #1: Peak Measured at Wrong Time (❌ FIXED) +**Problem:** Peak was measured when audio was written to ring buffer (~400ms before playback), causing visual effects to trigger 400ms early. + +**Solution:** +- Added `get_realtime_peak()` to AudioBackend interface +- Implemented real-time peak measurement in audio callback when samples are actually played +- Updated main.cc and test_demo.cc to use `audio_get_realtime_peak()` instead of `synth_get_output_peak()` + +**Files Modified:** +- src/audio/audio_backend.h +- src/audio/miniaudio_backend.h/cc +- src/audio/mock_audio_backend.h/cc +- src/audio/wav_dump_backend.h/cc +- src/audio/jittered_audio_backend.h/cc +- src/audio/audio.h/cc +- src/main.cc +- src/test_demo.cc +- src/tests/test_audio_backend.cc + +### Issue #2: Peak Decay Too Slow (❌ FIXED) +**Problem:** Peak decay rate of 0.95 per callback meant visual effects stayed bright for ~6 seconds after a drum hit, causing constant flashing. + +**Root Cause Analysis:** +- Decay rate: 0.95 per callback +- Callback interval: ~128ms +- Time to decay to 10%: **~5.76 seconds** (45 callbacks) +- Result: Screen stays white for 6+ seconds after each drum hit + +**Solution:** +- Changed decay rate from 0.95 to 0.7 +- New decay timing: + - 50% intensity: ~256ms (2 callbacks) + - 10% intensity: ~1.15 seconds (9 callbacks) +- Result: Quick flash with smooth fade, proper visual sync + +**Decay Comparison:** +``` +Old (0.95): ████████████████████████████ (6 seconds to fade) +New (0.7): ████ (1 second to fade) +``` + +**File Modified:** +- src/audio/miniaudio_backend.cc (line 164) + +## Verification + +✅ All 27 tests pass +✅ demo64k builds successfully +✅ test_demo builds successfully +✅ Peak decay timing verified mathematically +✅ Audio-visual sync should now be accurate + +## Testing Instructions + +Run test_demo to verify the fix: +```bash +./build/test_demo +``` + +Expected behavior: +- Screen should flash white on drum hits (every ~0.5 seconds) +- Flash should fade quickly (~1 second) +- No constant white screen +- Audio and visual should be synchronized + +## Known Build Issues (Pre-existing) + +The following tests have linker errors (unrelated to peak measurement fix): +- test_effect_base (missing WebGPUTestFixture) +- test_post_process_helper (missing main) +- test_texture_manager (missing main) +- test_demo_effects (missing main) + +These appear to be incomplete test implementations and should be addressed separately. |
