diff options
author | Phil Burk <[email protected]> | 2015-11-02 19:02:22 -0800 |
---|---|---|
committer | Phil Burk <[email protected]> | 2015-11-02 19:02:22 -0800 |
commit | ce45e397cd3e3871aa197f0b3af424d9c3dd5403 (patch) | |
tree | eaa338f3ca650b002f78f9784034f7f2d3c1cef0 /src | |
parent | f6acddc087ed65bc68293ba7b6511c55a9d27d1d (diff) | |
parent | d705eac3210391f32764166fdbb6ef9f96623134 (diff) |
Merge pull request #10 from philburk/fixfft
fix scaling in FFT
Diffstat (limited to 'src')
-rw-r--r-- | src/com/jsyn/JSyn.java | 4 | ||||
-rw-r--r-- | src/com/softsynth/math/FourierMath.java | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/com/jsyn/JSyn.java b/src/com/jsyn/JSyn.java index c6e35b2..bc6f813 100644 --- a/src/com/jsyn/JSyn.java +++ b/src/com/jsyn/JSyn.java @@ -54,8 +54,8 @@ public class JSyn { // Update these for every release. private final static int VERSION_MAJOR = 16; private final static int VERSION_MINOR = 7; - private final static int VERSION_REVISION = 4; - public final static int BUILD_NUMBER = 457; + private final static int VERSION_REVISION = 5; + public final static int BUILD_NUMBER = 458; private final static long BUILD_TIME = new GregorianCalendar(2014, GregorianCalendar.DECEMBER, 25).getTime().getTime(); 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) { |