this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

back to 1024 and cleaner, for now

alice 50f5ee5c 80447180

+8 -60
+5 -55
src/ext/fft.c
··· 222 222 _samples[i] = 2.0f * sqrtf(out[i].r * out[i].r + out[i].i * out[i].i) * scaling * fAmplification; 223 223 } 224 224 } 225 + float fFFTSmoothingFactor = 0.9; 226 + for ( int i = 0; i < FFT_SIZE; i++ ) 227 + { 228 + _samples[i] = _samples[i] * fFFTSmoothingFactor + (1 - fFFTSmoothingFactor) * _samples[i]; 229 + } 225 230 226 231 return true; 227 232 } 228 - 229 233 230 234 double tic_api_fft(tic_mem* memory, s32 freq) 231 235 { 232 236 return fftData[freq]; 233 237 } 234 - 235 - // float fFFTSmoothingFactor = 0.9f; // higher value, smoother FFT 236 - // static float fftDataSmoothed[FFT_SIZE] = {0}; // Initialize the array with zeros 237 - // static const float fPeakMinValue = 0.01f; 238 - // static const float fPeakSmoothing = 0.995f; 239 - // static float fPeakSmoothValue = 0.0f; 240 - 241 - // double tic_api_fft(tic_mem* memory, s32 freq/*, bool bPeakNormalization, bool bSmoothing*/) 242 - // { 243 - // u32 interval = FFT_SIZE / 256 / 2; // the 2 is to discard super high frequencies, they suck 244 - // freq = freq * interval; 245 - // freq = fmin(freq, FFT_SIZE); 246 - // freq = fmax(freq, 0); 247 - 248 - // bool bPeakNormalization = true; 249 - // bool bSmoothing = true; 250 - 251 - // if (bPeakNormalization) { 252 - // float peakValue = fPeakMinValue; 253 - // for (int i = freq; i < freq + interval; ++i) { 254 - // float val = 2.0f * sqrtf(fftBuf[i].r * fftBuf[i].r + fftBuf[i].i * fftBuf[i].i); 255 - // if (val > peakValue) { 256 - // peakValue = val; 257 - // } 258 - // } 259 - // if (peakValue > fPeakSmoothValue) { 260 - // fPeakSmoothValue = peakValue; 261 - // } 262 - // if (peakValue < fPeakSmoothValue) { 263 - // fPeakSmoothValue = fPeakSmoothValue * fPeakSmoothing + peakValue * (1 - fPeakSmoothing); 264 - // } 265 - // if (fPeakSmoothValue > 0.0f) { 266 - // fAmplification = 1.0f / fPeakSmoothValue; 267 - // } else { 268 - // fAmplification = 1.0f; 269 - // } 270 - // } 271 - 272 - // static const float scaling = 1.0f / (float)FFT_SIZE; 273 - // float res = 0; 274 - // for (int i = freq; i < freq + interval; ++i) { 275 - // float val = 2.0f * sqrtf(fftBuf[i].r * fftBuf[i].r + fftBuf[i].i * fftBuf[i].i) * scaling * fAmplification; 276 - // if (bSmoothing) { 277 - // if (i < FFT_SIZE) { 278 - // fftDataSmoothed[i] = fftDataSmoothed[i] * fFFTSmoothingFactor + (1 - fFFTSmoothingFactor) * val; 279 - // res += fftDataSmoothed[i]; 280 - // } 281 - // } else { 282 - // res += val; 283 - // } 284 - // } 285 - 286 - // return res; 287 - // }
-3
src/ext/fft.h
··· 1 1 #pragma once 2 - // #define FFT_SIZE 2048 3 - // #define FFT_SIZE 1024 4 - #define FFT_SIZE 256 5 2 #include <stdbool.h> 6 3 7 4
+1 -1
src/fftdata.c
··· 2 2 float fPeakMinValue = 0.01f; 3 3 float fPeakSmoothing = 0.995f; 4 4 float fPeakSmoothValue = 0.0f; 5 - float fftData[256] = {0}; 5 + float fftData[FFT_SIZE] = {0};
+2 -1
src/fftdata.h
··· 1 1 #pragma once 2 + #define FFT_SIZE 1024 2 3 float fPeakMinValue; 3 4 float fPeakSmoothing; 4 5 float fPeakSmoothValue; 5 - extern float fftData[256]; 6 + extern float fftData[FFT_SIZE];