From c384515c8ea933757c97886c3bf1554e2fd62b04 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 28 Jan 2026 10:34:15 +0100 Subject: feat(visuals): Add rotation, color shifts, and improved beat-sync Implements a more dynamic and reactive visual system. - Updated synth.cc: Faster peak decay for better response. - Updated gpu.cc: Added time-based rotation and Hue shifting; implemented reactive clear-color flashes. - Updated main.cc: Corrected peak scaling (8x multiplier) and integrated time-based animation. --- src/audio/synth.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/audio/synth.cc') diff --git a/src/audio/synth.cc b/src/audio/synth.cc index 2242d5c..e4f6c75 100644 --- a/src/audio/synth.cc +++ b/src/audio/synth.cc @@ -9,9 +9,6 @@ #include #include // For memset -// Declarations for DCT functions (could also be in dct.h) -void idct_512(const float *input, float *output); - struct Voice { bool active; int spectrogram_id; @@ -35,8 +32,7 @@ static struct { } g_synth_data; static Voice g_voices[MAX_VOICES]; -static volatile float g_current_output_peak = - 0.0f; // Global peak for visualization +static volatile float g_current_output_peak = 0.0f; // Global peak for visualization void synth_init() { memset(&g_synth_data, 0, sizeof(g_synth_data)); @@ -137,8 +133,8 @@ void synth_render(float *output_buffer, int num_frames) { float window[WINDOW_SIZE]; hamming_window_512(window); - // Apply a decay to the peak value for smooth visuals - g_current_output_peak *= 0.95f; + // Faster decay for more responsive visuals + g_current_output_peak *= 0.90f; for (int i = 0; i < num_frames; ++i) { float left_sample = 0.0f; @@ -184,8 +180,9 @@ void synth_render(float *output_buffer, int num_frames) { output_buffer[i * 2 + 1] = right_sample; // Update the peak with the new max (attack) - g_current_output_peak = fmaxf( - g_current_output_peak, fmaxf(fabsf(left_sample), fabsf(right_sample))); + g_current_output_peak = + fmaxf(g_current_output_peak, + fmaxf(fabsf(left_sample), fabsf(right_sample))); } } @@ -199,6 +196,4 @@ int synth_get_active_voice_count() { return count; } -float synth_get_output_peak() { - return g_current_output_peak; -} +float synth_get_output_peak() { return g_current_output_peak; } \ No newline at end of file -- cgit v1.2.3