this repo has no description
0
fork

Configure Feed

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

reindent; remove unneccessary double loop

alice 8a66f199 3dabdb69

+29 -34
+29 -34
src/ext/fft.c
··· 194 194 195 195 bool FFT_GetFFT(float* _samples) 196 196 { 197 - kiss_fft_cpx out[FFT_SIZE + 1]; 198 - kiss_fftr(fftcfg, sampleBuf, out); 197 + kiss_fft_cpx out[FFT_SIZE + 1]; 198 + kiss_fftr(fftcfg, sampleBuf, out); 199 199 200 - bool bPeakNormalization = true; 201 - if (bPeakNormalization) { 202 - float peakValue = fPeakMinValue; 203 - for (int i = 0; i < FFT_SIZE; i++) 204 - { 205 - float val = 2.0f * sqrtf(out[i].r * out[i].r + out[i].i * out[i].i); 206 - if (val > peakValue) peakValue = val; 207 - } 208 - if (peakValue > fPeakSmoothValue) { 209 - fPeakSmoothValue = peakValue; 210 - } 211 - if (peakValue < fPeakSmoothValue) { 212 - fPeakSmoothValue = fPeakSmoothValue * fPeakSmoothing + peakValue * (1 - fPeakSmoothing); 213 - } 214 - fAmplification = 1.0f / fPeakSmoothValue; 215 - for (int i = 0; i < FFT_SIZE; i++) 216 - { 217 - float val = 2.0f * sqrtf(out[i].r * out[i].r + out[i].i * out[i].i); 218 - _samples[i] = val * fAmplification; 219 - } 220 - 221 - float fFFTSmoothingFactor = 0.9; 222 - for ( int i = 0; i < FFT_SIZE; i++ ) 223 - { 224 - _samples[i] = _samples[i] * fFFTSmoothingFactor + (1 - fFFTSmoothingFactor) * _samples[i]; 225 - } 226 - } else { 227 - for (int i = 0; i < FFT_SIZE; i++) 228 - { 229 - static const float scaling = 1.0f / (float)FFT_SIZE; 230 - _samples[i] = 2.0f * sqrtf(out[i].r * out[i].r + out[i].i * out[i].i) * scaling * fAmplification; 231 - } 200 + bool bPeakNormalization = true; 201 + if (bPeakNormalization) { 202 + float peakValue = fPeakMinValue; 203 + for (int i = 0; i < FFT_SIZE; i++) 204 + { 205 + float val = 2.0f * sqrtf(out[i].r * out[i].r + out[i].i * out[i].i); 206 + if (val > peakValue) peakValue = val; 207 + _samples[i] = val * fAmplification; 208 + } 209 + if (peakValue > fPeakSmoothValue) { 210 + fPeakSmoothValue = peakValue; 211 + } 212 + if (peakValue < fPeakSmoothValue) { 213 + fPeakSmoothValue = fPeakSmoothValue * fPeakSmoothing + peakValue * (1 - fPeakSmoothing); 214 + } 215 + fAmplification = 1.0f / fPeakSmoothValue; 216 + float fFFTSmoothingFactor = 0.9; 217 + for ( int i = 0; i < FFT_SIZE; i++ ) 218 + { 219 + _samples[i] = _samples[i] * fFFTSmoothingFactor + (1 - fFFTSmoothingFactor) * _samples[i]; 220 + } 221 + } else { 222 + for (int i = 0; i < FFT_SIZE; i++) 223 + { 224 + static const float scaling = 1.0f / (float)FFT_SIZE; 225 + _samples[i] = 2.0f * sqrtf(out[i].r * out[i].r + out[i].i * out[i].i) * scaling * fAmplification; 232 226 } 227 + } 233 228 234 229 return true; 235 230 }