summaryrefslogtreecommitdiff
path: root/src/audio/synth.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/synth.cc')
-rw-r--r--src/audio/synth.cc13
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