All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.jaad.aac.gain.FFT Maven / Gradle / Ivy

There is a newer version: 0.2.5
Show newest version
package net.sourceforge.jaad.aac.gain;

/**
 * This class is part of JAAD ( jaadec.sourceforge.net ) that is distributed
 * under the Public Domain license. Code changes provided by the JCodec project
 * are distributed under FreeBSD license.
 *
 * @author in-somnia
 */
//complex FFT of length 128/16, inplace
class FFT {

	private static final float[][] FFT_TABLE_128 = {
		{1.0f, -0.0f},
		{0.99879545f, -0.049067676f},
		{0.9951847f, -0.09801714f},
		{0.9891765f, -0.14673047f},
		{0.98078525f, -0.19509032f},
		{0.97003126f, -0.24298018f},
		{0.95694035f, -0.29028466f},
		{0.94154406f, -0.33688986f},
		{0.9238795f, -0.38268343f},
		{0.9039893f, -0.42755508f},
		{0.8819213f, -0.47139674f},
		{0.8577286f, -0.51410276f},
		{0.8314696f, -0.55557024f},
		{0.8032075f, -0.5956993f},
		{0.77301043f, -0.6343933f},
		{0.7409511f, -0.671559f},
		{0.70710677f, -0.70710677f},
		{0.671559f, -0.7409511f},
		{0.6343933f, -0.77301043f},
		{0.5956993f, -0.8032075f},
		{0.55557024f, -0.8314696f},
		{0.51410276f, -0.8577286f},
		{0.47139674f, -0.8819213f},
		{0.42755508f, -0.9039893f},
		{0.38268343f, -0.9238795f},
		{0.33688986f, -0.94154406f},
		{0.29028466f, -0.95694035f},
		{0.24298018f, -0.97003126f},
		{0.19509032f, -0.98078525f},
		{0.14673047f, -0.9891765f},
		{0.09801714f, -0.9951847f},
		{0.049067676f, -0.99879545f},
		{6.123234E-17f, -1.0f},
		{-0.049067676f, -0.99879545f},
		{-0.09801714f, -0.9951847f},
		{-0.14673047f, -0.9891765f},
		{-0.19509032f, -0.98078525f},
		{-0.24298018f, -0.97003126f},
		{-0.29028466f, -0.95694035f},
		{-0.33688986f, -0.94154406f},
		{-0.38268343f, -0.9238795f},
		{-0.42755508f, -0.9039893f},
		{-0.47139674f, -0.8819213f},
		{-0.51410276f, -0.8577286f},
		{-0.55557024f, -0.8314696f},
		{-0.5956993f, -0.8032075f},
		{-0.6343933f, -0.77301043f},
		{-0.671559f, -0.7409511f},
		{-0.70710677f, -0.70710677f},
		{-0.7409511f, -0.671559f},
		{-0.77301043f, -0.6343933f},
		{-0.8032075f, -0.5956993f},
		{-0.8314696f, -0.55557024f},
		{-0.8577286f, -0.51410276f},
		{-0.8819213f, -0.47139674f},
		{-0.9039893f, -0.42755508f},
		{-0.9238795f, -0.38268343f},
		{-0.94154406f, -0.33688986f},
		{-0.95694035f, -0.29028466f},
		{-0.97003126f, -0.24298018f},
		{-0.98078525f, -0.19509032f},
		{-0.9891765f, -0.14673047f},
		{-0.9951847f, -0.09801714f},
		{-0.99879545f, -0.049067676f}
	};
	private static final float[][] FFT_TABLE_16 = {
		{1.0f, -0.0f},
		{0.9238795f, -0.38268343f},
		{0.70710677f, -0.70710677f},
		{0.38268343f, -0.9238795f},
		{6.123234E-17f, -1.0f},
		{-0.38268343f, -0.9238795f},
		{-0.70710677f, -0.70710677f},
		{-0.9238795f, -0.38268343f}
	};

	static void process(float[][] _in, int n) {
		final int ln = (int) Math.round(Math.log(n)/Math.log(2));
		final float[][] table = (n==128) ? FFT_TABLE_128 : FFT_TABLE_16;

		//bit-reversal
		final float[][] rev = new float[n][2];
		int i, ii = 0;
		for(i = 0; i>1;
			while(ii>=k&&k>0) {
				ii -= k;
				k >>= 1;
			}
			ii += k;
		}
		for(i = 0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy