aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/softsynth/math
diff options
context:
space:
mode:
authorPhil Burk <[email protected]>2015-11-02 18:59:55 -0800
committerPhil Burk <[email protected]>2015-11-02 18:59:55 -0800
commitd705eac3210391f32764166fdbb6ef9f96623134 (patch)
tree611ce656a996d3e60ac32216280ad4b4c428f3e1 /src/com/softsynth/math
parentb19ff3c002edec62070cb6c6e8d5c2e321ff0354 (diff)
fix scaling in FFT
Diffstat (limited to 'src/com/softsynth/math')
-rw-r--r--src/com/softsynth/math/FourierMath.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/com/softsynth/math/FourierMath.java b/src/com/softsynth/math/FourierMath.java
index 82d4ec9..d133d7f 100644
--- a/src/com/softsynth/math/FourierMath.java
+++ b/src/com/softsynth/math/FourierMath.java
@@ -123,7 +123,7 @@ public class FourierMath {
}
public static void transform(int sign, int n, double ar[], double ai[]) {
- double scale = Math.sqrt(1.0 / n);
+ double scale = (sign > 0) ? (2.0 / n) : (0.5);
int numBits = FourierMath.numBits(n);
int[] reverseTable = getReverseTable(numBits);
@@ -150,7 +150,7 @@ public class FourierMath {
int phase = 0;
int phaseIncrement = numerator / (2 * mmax);
for (int m = 0; m < mmax; ++m) {
- double wr = sineTable[(phase + cosineOffset) & mask];
+ double wr = sineTable[(phase + cosineOffset) & mask]; // cosine
double wi = sineTable[phase];
for (i = m; i < n; i += stride) {
@@ -170,7 +170,7 @@ public class FourierMath {
}
public static void transform(int sign, int n, float ar[], float ai[]) {
- float scale = (float) Math.sqrt(1.0 / n);
+ float scale = (sign > 0) ? (2.0f / n) : (0.5f);
int numBits = FourierMath.numBits(n);
int[] reverseTable = getReverseTable(numBits);
@@ -197,7 +197,7 @@ public class FourierMath {
int phase = 0;
int phaseIncrement = numerator / (2 * mmax);
for (int m = 0; m < mmax; ++m) {
- float wr = sineTable[(phase + cosineOffset) & mask];
+ float wr = sineTable[(phase + cosineOffset) & mask]; // cosine
float wi = sineTable[phase];
for (i = m; i < n; i += stride) {