mirror of
https://github.com/alexkay/spek.git
synced 2025-04-22 03:10:29 +03:00
Fix magnitude calculation for the first and the last frequency band
This commit is contained in:
parent
a6540309ac
commit
85b8a79cf0
@ -43,14 +43,15 @@ void spek_fft_execute(struct spek_fft_plan *p)
|
||||
|
||||
// Calculate magnitudes.
|
||||
int n = p->n;
|
||||
p->output[0] = p->input[0] * p->input[0] / (n * n);
|
||||
p->output[n / 2] = p->input[1] * p->input[1] / (n * n);
|
||||
float n2 = n * n;
|
||||
p->output[0] = 10.0f * log10f(p->input[0] * p->input[0] / n2);
|
||||
p->output[n / 2] = 10.0f * log10f(p->input[1] * p->input[1] / n2);
|
||||
for (int i = 1; i < n / 2; i++) {
|
||||
float val =
|
||||
p->input[i * 2] * p->input[i * 2] +
|
||||
p->input[i * 2 + 1] * p->input[i * 2 + 1];
|
||||
val /= n * n;
|
||||
p->output[i] = 10.0 * log10f (val);
|
||||
val /= n2;
|
||||
p->output[i] = 10.0f * log10f(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user