diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-26 10:09:34 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-26 10:09:34 +0100 |
| commit | 8c5e41724fdfc3be24e95f48ae4b2be616404074 (patch) | |
| tree | 052d8512b43ff4d41af66d71f5fa8dc7de0f609a /src/audio/audio_engine.cc | |
| parent | 26627e8b9fee3fb3b2ec6314fc5cf45620769fcb (diff) | |
P1 — correctness bugs:
- tracker.cc: move delete[] loop before pool reset so guard condition is valid
- audio_engine: replace tracker_reset() with tracker_init() in reset()/seek()
so synth IDs are re-registered after synth_init() clears spectrogram slots
- spectrogram_resource_manager: set spec.version in load_procedural() (was UB)
P2 — minor bugs:
- synth.cc: move pan clamp unconditionally before debug-only block
- gen.cc: remove dead `freq` variable in generate_note_spectrogram()
- tracker.cc: remove duplicate g_sample_synth_cache clear loop
P3 — cleanup:
- Replace hardcoded 32000.0f with RING_BUFFER_SAMPLE_RATE (5 sites)
- audio.cc: extract clip_samples() helper, remove duplicated clip loops
- audio_engine: inline update_silent(), remove no-op prewarm_for_time_range()
- Remove stale comments: stdio.h include, NEW: labels, CACHING block, NOTE:
- Move TODO(timing) drift notes from source to TODO.md
handoff(Gemini): audio review implemented, 36/36 tests passing
Diffstat (limited to 'src/audio/audio_engine.cc')
| -rw-r--r-- | src/audio/audio_engine.cc | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/audio/audio_engine.cc b/src/audio/audio_engine.cc index d11303c..8e47eac 100644 --- a/src/audio/audio_engine.cc +++ b/src/audio/audio_engine.cc @@ -3,7 +3,6 @@ #include "audio_engine.h" #include "util/debug.h" -#include <algorithm> #include <cstring> void AudioEngine::init() { @@ -49,7 +48,7 @@ void AudioEngine::reset() { } synth_init(); // Re-init synth (clears all state) - tracker_reset(); + ::tracker_init(); // Re-register all spectrograms (synth slots now clean) resource_mgr_.reset(); // Clear sample-to-synth mapping @@ -171,23 +170,18 @@ void AudioEngine::seek(float target_time) { // 1. Reset synth state (clear all active voices) synth_init(); - // 2. Reset tracker state - tracker_reset(); + // 2. Re-init tracker: re-registers all spectrograms with now-clean synth slots + ::tracker_init(); // 3. Clear sample-to-synth mapping (will be re-registered on demand) for (int i = 0; i < MAX_SPECTROGRAM_RESOURCES; ++i) { sample_to_synth_id_[i] = -1; } - // 4. Pre-warm samples for target time range - const float prewarm_start = std::max(0.0f, target_time - 1.0f); - const float prewarm_end = target_time + 2.0f; - prewarm_for_time_range(prewarm_start, prewarm_end); - - // 5. Simulate tracker up to target time (without audio) + // 4. Simulate tracker up to target time (without audio) const float dt = 0.1f; for (float t = 0.0f; t < target_time; t += dt) { - update_silent(t); + tracker_update(t, 0.0f); } // 6. Final update at exact target time @@ -200,22 +194,4 @@ void AudioEngine::seek(float target_time) { #endif } -void AudioEngine::prewarm_for_time_range(float start_time, float end_time) { - // TODO: Scan tracker score for patterns in this time range - // and pre-load their samples. For now, this is a placeholder. - // The proper implementation requires access to g_tracker_score - // and pattern data to determine which samples will be needed. - -#if defined(DEBUG_LOG_AUDIO) - DEBUG_AUDIO("[AudioEngine] Pre-warming samples for t=%.2f-%.2f\n", start_time, - end_time); -#endif -} - -void AudioEngine::update_silent(float music_time) { - // Update tracker without triggering audio (for fast-forward/seeking) - // This is a placeholder - proper implementation requires tracker support - // for silent updates. For now, we just update normally. - tracker_update(music_time, 0.0f); -} #endif /* !defined(STRIP_ALL) */ |
