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/synth.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/synth.cc')
| -rw-r--r-- | src/audio/synth.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/audio/synth.cc b/src/audio/synth.cc index 0866bda..45ced59 100644 --- a/src/audio/synth.cc +++ b/src/audio/synth.cc @@ -6,7 +6,6 @@ #include "audio/dct.h" #include "util/debug.h" #include <math.h> -#include <stdio.h> // For printf #include <string.h> // For memset #if !defined(STRIP_ALL) @@ -169,6 +168,11 @@ void synth_trigger_voice(int spectrogram_id, float volume, float pan, return; } + if (pan < -1.0f) + pan = -1.0f; + else if (pan > 1.0f) + pan = 1.0f; + #if defined(DEBUG_LOG_SYNTH) // VALIDATION: Check volume and pan ranges if (volume < 0.0f || volume > 2.0f) { @@ -177,9 +181,8 @@ void synth_trigger_voice(int spectrogram_id, float volume, float pan, } if (pan < -1.0f || pan > 1.0f) { DEBUG_SYNTH( - "[SYNTH WARNING] Invalid pan=%.2f (clamping) for spectrogram_id=%d\n", + "[SYNTH WARNING] Invalid pan=%.2f for spectrogram_id=%d\n", pan, spectrogram_id); - pan = (pan < -1.0f) ? -1.0f : 1.0f; } if (start_offset_samples < 0) { DEBUG_SYNTH("[SYNTH WARNING] Negative start_offset=%d, clamping to 0\n", @@ -210,8 +213,7 @@ void synth_trigger_voice(int spectrogram_id, float volume, float pan, memset(v.overlap_buf, 0, sizeof(v.overlap_buf)); v.fractional_pos = 0.0f; // Initialize fractional position for tempo scaling - v.start_sample_offset = - start_offset_samples; // NEW: Sample-accurate timing + v.start_sample_offset = start_offset_samples; v.active_spectral_data = g_synth_data.active_spectrogram_data[spectrogram_id]; @@ -242,7 +244,6 @@ void synth_render(float* output_buffer, int num_frames) { if (!v.active) continue; - // NEW: Skip this sample if we haven't reached the trigger offset yet if (v.start_sample_offset > 0) { v.start_sample_offset--; continue; // Don't produce audio until offset elapsed |
