reduced stft window size to 1024, used ring buffer to slide dft

pull/6/head
Ahmet Inan 2015-01-09 18:31:01 +01:00
rodzic 55da5a9d77
commit 3c9d5b7da0
3 zmienionych plików z 1031 dodań i 16388 usunięć

Wyświetl plik

@ -45,6 +45,7 @@ static void spectrum_analyzer(int amplitude)
{ {
const int M = 7; const int M = 7;
static int n, m; static int n, m;
static int buffer[stft_N];
static complex_t input[radix2_N]; static complex_t input[radix2_N];
static complex_t output[radix2_N]; static complex_t output[radix2_N];
@ -65,9 +66,11 @@ static void spectrum_analyzer(int amplitude)
sum = 0; sum = 0;
#endif #endif
input[n&(radix2_N-1)] += complex(stft_w[n] * amplitude, 0.0f); buffer[n] = amplitude;
if (++n >= stft_N) { if (!((++n)%(radix2_N))) {
n = 0; n &= stft_N - 1;
for (int i = 0; i < stft_N; ++i)
input[i&(radix2_N-1)] += complex(stft_w[i] * buffer[(i+n)&(stft_N-1)], 0.0f);
// yep, were wasting 3x performance // yep, were wasting 3x performance
radix2(output, input, radix2_N, 1, 0); radix2(output, input, radix2_N, 1, 0);
for (int i = 0; i < radix2_N; ++i) for (int i = 0; i < radix2_N; ++i)

Wyświetl plik

@ -25,7 +25,7 @@ double gauss(double n, double N, double o)
int main() int main()
{ {
const int N = 1 << 14; const int N = 1024;
const double o = 0.2; const double o = 0.2;
printf("/* code generated by 'utils/stft.c' */\n"); printf("/* code generated by 'utils/stft.c' */\n");
printf("static const int stft_N = %d;\n", N); printf("static const int stft_N = %d;\n", N);