-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
362 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
============================================================================== | ||
FFT.h | ||
Created: 30 Apr 2021 2:18:00pm | ||
Author: Hayden Setlik | ||
============================================================================== | ||
*/ | ||
|
||
#pragma once | ||
#include <JuceHeader.h> | ||
struct FFT { | ||
static void runFloat(int N, float *ar, float *ai) | ||
/* | ||
in-place complex fft | ||
After Cooley, Lewis, and Welch; from Rabiner & Gold (1975) | ||
program adapted from FORTRAN | ||
by K. Steiglitz ([email protected]) | ||
Computer Science Dept. | ||
Princeton University 08544 */ | ||
{ | ||
int i, j, k, L; /* indexes */ | ||
int M, TEMP, LE, LE1, ip; /* M = log N */ | ||
int NV2, NM1; | ||
double t; /* temp */ | ||
float Ur, Ui, Wr, Wi, Tr, Ti; | ||
float Ur_old; | ||
// if ((N > 1) && !(N & (N - 1))) // make sure we have a power of 2 | ||
NV2 = N >> 1; | ||
NM1 = N - 1; | ||
TEMP = N; /* get M = log N */ | ||
M = 0; | ||
while (TEMP >>= 1) | ||
++M; | ||
/* shuffle */ | ||
j = 1; | ||
for (i = 1; i <= NM1; i++) | ||
{ | ||
if(i<j) | ||
{ /* swap a[i] and a[j] */ | ||
t = ar[j-1]; | ||
ar[j-1] = ar[i-1]; | ||
ar[i-1] = t; | ||
t = ai[j-1]; | ||
ai[j-1] = ai[i-1]; | ||
ai[i-1] = t; | ||
} | ||
k = NV2; /* bit-reversed counter */ | ||
while(k < j) | ||
{ | ||
j -= k; | ||
k /= 2; | ||
} | ||
j += k; | ||
} | ||
LE = 1.0f; | ||
for (L = 1; L <= M; L++) { // stage L | ||
LE1 = LE; // (LE1 = LE/2) | ||
LE *= 2; // (LE = 2^L) | ||
Ur = 1.0f; | ||
Ui = 0.0f; | ||
Wr = cos(M_PI/(float)LE1); | ||
Wi = -sin(M_PI/(float)LE1); // Cooley, Lewis, and Welch have "+" here | ||
for (j = 1; j <= LE1; j++) | ||
{ | ||
for (i = j; i <= N; i += LE) | ||
{ // butterfly | ||
ip = i+LE1; | ||
Tr = ar[ip-1] * Ur - ai[ip-1] * Ui; | ||
Ti = ar[ip-1] * Ui + ai[ip-1] * Ur; | ||
ar[ip-1] = ar[i-1] - Tr; | ||
ai[ip-1] = ai[i-1] - Ti; | ||
ar[i-1] = ar[i-1] + Tr; | ||
ai[i-1] = ai[i-1] + Ti; | ||
} | ||
Ur_old = Ur; | ||
Ur = Ur_old * Wr - Ui * Wi; | ||
Ui = Ur_old * Wi + Ui * Wr; | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.