summaryrefslogtreecommitdiff
path: root/src/tests/test_jittered_audio.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-07 14:00:23 +0100
committerskal <pascal.massimino@gmail.com>2026-02-07 14:00:23 +0100
commita6a7bf0440dbabdc6c994c0fb21a8ac31c27be07 (patch)
tree26663d3d65b110fca618d6fa33c83f7a8d1e362a /src/tests/test_jittered_audio.cc
parentda1d4e10731789191d8a23e60c3dd35217e6bdb0 (diff)
feat(audio): Add SilentBackend, fix peak measurement, reorganize backends
## Critical Fixes **Peak Measurement Timing:** - Fixed 400ms audio-visual desync by measuring peak at playback time - Added get_realtime_peak() to AudioBackend interface - Implemented real-time measurement in MiniaudioBackend audio callback - Updated main.cc and test_demo.cc to use audio_get_realtime_peak() **Peak Decay Rate:** - Fixed slow decay (0.95 → 0.7 per callback) - Old: 5.76 seconds to fade to 10% (constant flashing in test_demo) - New: 1.15 seconds to fade to 10% (proper visual sync) ## New Features **SilentBackend:** - Test-only backend for testing audio.cc without hardware - Controllable peak for testing edge cases - Tracks frames rendered and voice triggers - Added 7 comprehensive tests covering: - Lifecycle (init/start/shutdown) - Peak control and tracking - Playback time and buffer management - Integration with AudioEngine ## Refactoring **Backend Organization:** - Created src/audio/backend/ directory - Moved all backend implementations to subdirectory - Updated include paths and CMakeLists.txt - Cleaner codebase structure **Code Cleanup:** - Removed unused register_spec_asset() function - Added deprecation note to synth_get_output_peak() ## Testing - All 28 tests passing (100%) - New test: test_silent_backend - Improved audio.cc test coverage significantly ## Documentation - Created PEAK_FIX_SUMMARY.md with technical details - Created TASKS_SUMMARY.md with complete task report Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tests/test_jittered_audio.cc')
-rw-r--r--src/tests/test_jittered_audio.cc13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/tests/test_jittered_audio.cc b/src/tests/test_jittered_audio.cc
index f880c74..8afb8c0 100644
--- a/src/tests/test_jittered_audio.cc
+++ b/src/tests/test_jittered_audio.cc
@@ -6,7 +6,7 @@
#if !defined(STRIP_ALL)
#include "audio/audio.h"
-#include "audio/jittered_audio_backend.h"
+#include "audio/backend/jittered_audio_backend.h"
#include "audio/synth.h"
#include "audio/tracker.h"
#include <assert.h>
@@ -118,17 +118,6 @@ void test_jittered_audio_with_acceleration() {
// Sleep to simulate frame time
std::this_thread::sleep_for(std::chrono::milliseconds(16));
-
- // Progress indicator (every 30 frames for shorter test)
- if (frame % 30 == 0) {
- printf(
- " Frame %d: music_time=%.2fs, tempo=%.2fx, consumed=%d frames, "
- "underruns=%d\r",
- frame, music_time, tempo_scale,
- jittered_backend.get_total_frames_consumed(),
- jittered_backend.get_underrun_count());
- fflush(stdout);
- }
}
printf("\n");