From 3cba52f4ae1af0e90a6e72a5f96bfbbf22c5745a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20J=C3=A4rvisalo?= Date: Tue, 15 Jul 2025 17:23:03 +0300 Subject: [PATCH] =?UTF-8?q?Turhaksi=20j=C3=A4=C3=A4nyt=20if=20ehto=20pois.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3156cf0..208b136 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,20 +184,15 @@ int __cdecl main(int argc, char* argv[]) compute_fft(fft_input, fft_output); // Normalize output - for (int i = 0; i < (FFT_SIZE / 2); i++) - { - //maximum = max(fft_output[i], maximum); - //fft_output[i] = fft_output[i] / maximum; - if (i < (FFT_SIZE / 4)) // Limit uniform fft size. High frequencys contain nothing interesing. - { - float gain = 50.0f; - float alpha = 0.15f; // "Hidastaa" FFT:n piikkejä - float threshhold = 0.05f; // Alin arvo mikä päästetään shaderille (vähentää "noisea") - float x_t = fft_output[i] * gain; - // Exponential smoothing kaava - // s(t) = alpha*x(t)+(1-alpha)*s(t-1) - fft_uniform[i] = (x_t < threshhold) ? 0.f : alpha*(x_t) + (1-alpha)*fft_uniform[i]; - } + for (int i = 0; i < (FFT_SIZE / 4); i++) + { + float gain = 50.0f; + float alpha = 0.15f; // "Hidastaa" FFT:n piikkejä + float threshhold = 0.05f; // Alin arvo mikä päästetään shaderille (vähentää "noisea") + float x_t = fft_output[i] * gain; + // Exponential smoothing kaava + // s(t) = alpha*x(t)+(1-alpha)*s(t-1) + fft_uniform[i] = (x_t < threshhold) ? 0.f : alpha*(x_t) + (1-alpha)*fft_uniform[i]; } syncs[0] = (float)playCursor / (SU_SAMPLE_RATE * SU_CHANNEL_COUNT * SU_SAMPLE_SIZE); // Aika sekunteina.