diff --git a/app/src/main/rs/radix2.rsh b/app/src/main/rs/radix2.rsh index 9e6d989..f94176d 100644 --- a/app/src/main/rs/radix2.rsh +++ b/app/src/main/rs/radix2.rsh @@ -20,7 +20,7 @@ limitations under the License. #include "complex.rsh" #include "radix2_generated.rsh" -static void radix2(complex_t *out, complex_t *in, int N, int S, int L) +static void radix2(complex_t *out, float *in, int N, int S, int L) { if (1 == N) { out[0] = in[0]; @@ -32,9 +32,9 @@ static void radix2(complex_t *out, complex_t *in, int N, int S, int L) } else if (4 == N) { complex_t w = radix2_z[1 << L]; out[0] = in[0] + in[S] + in[2 * S] + in[3 * S]; - out[1] = in[0] + cmul(w, in[S]) - in[2 * S] - cmul(w, in[3 * S]); + out[1] = in[0] + w * in[S] - in[2 * S] - w * in[3 * S]; out[2] = in[0] - in[S] + in[2 * S] - in[3 * S]; - out[3] = in[0] - cmul(w, in[S]) - in[2 * S] + cmul(w, in[3 * S]); + out[3] = in[0] - w * in[S] - in[2 * S] + w * in[3 * S]; return; } radix2(out, in, N / 2, 2 * S, L + 1); diff --git a/app/src/main/rs/stft.rsh b/app/src/main/rs/stft.rsh index fda090b..fa18605 100644 --- a/app/src/main/rs/stft.rsh +++ b/app/src/main/rs/stft.rsh @@ -74,7 +74,7 @@ static void spectrum_analyzer(int amplitude) const int M = 7; static int n, m; static int buffer[stft_N]; - static complex_t input[radix2_N]; + static float input[radix2_N]; static complex_t output[radix2_N]; if (disable_analyzer) @@ -103,8 +103,8 @@ static void spectrum_analyzer(int amplitude) if (!(++n&(radix2_N-1))) { 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 + input[i&(radix2_N-1)] += stft_w[i] * buffer[(i+n)&(stft_N-1)]; + // yep, were wasting 2x performance radix2(output, input, radix2_N, 1, 0); for (int i = 0; i < radix2_N; ++i) input[i] = 0.0f;