diff options
| author | skal <pascal.massimino@gmail.com> | 2026-01-28 10:34:15 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-01-28 10:34:15 +0100 |
| commit | c384515c8ea933757c97886c3bf1554e2fd62b04 (patch) | |
| tree | 79f7047d10777210dfb31185adc9dda282d09387 /src/audio/synth.cc | |
| parent | f12b5ebc74825817df54677e261b92200bfac84a (diff) | |
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.
Diffstat (limited to 'src/audio/synth.cc')
| -rw-r--r-- | src/audio/synth.cc | 19 |
1 files changed, 7 insertions, 12 deletions
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 <math.h> #include <string.h> // 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 |
