public void init() { // this.coeffs = MathBasics.getLPCoefficientsButterworth2Pole(bciSettings.getSamplesPerSecond(), 36d); this.fft = new DoubleFFT_1D(bciSettings.getSamplesPerSecond()); this.fftData.init(bciSettings.getSamplesPerSecond(), bciSettings.getBins(), bciSettings.getNumChannels()); System.out.println("window size: " + this.fftData.windowSize + " / samples per second: " + bciSettings.getSamplesPerSecond()); this.filterWindow = WindowFunction.generate(this.fftData.windowSize, WindowFunction.FunctionType.BLACKMAN); }
public void run() { if (icr == 0) { if (isgn == -1) { for (int r = n0; r < rows; r += nthreads) { fftColumns.complexForward(a, r * columns); } } else { for (int r = n0; r < rows; r += nthreads) { fftColumns.complexInverse(a, r * columns, scale); } } } else if (isgn == 1) { for (int r = n0; r < rows; r += nthreads) { fftColumns.realForward(a, r * columns); } } else { for (int r = n0; r < rows; r += nthreads) { fftColumns.realInverse(a, r * columns, scale); } } } });
public void run() { for (int s = firstSlice; s < lastSlice; s++) { for (int r = 0; r < rows; r++) { fftColumns.realForwardFull(a[s][r]); } } } });
public static double[][] computeFreqMagPhase(double[] time, double[] data) { int n = time.length; if (data.length != n) throw new RuntimeException("input.length != n"); DoubleFFT_1D fft = new DoubleFFT_1D(n); double T = time[n - 1] - time[0]; double fftInput[] = copyDoubleArray(data); fft.realForward(fftInput); double[] magnitude = extractMagnitude(fftInput); double[] phase = extractPhaseRadians(fftInput); double[] frequency = new double[n / 2]; for (int i = 0; i < n / 2; i++) { frequency[i] = (i) / T; } return new double[][] { frequency, magnitude, phase }; }
fft.realForward(convData);
public double calculateFFT(double[] signal) { final int mNumberOfFFTPoints =1024; double[] magnitude = new double[mNumberOfFFTPoints/2]; DoubleFFT_1D fft = new DoubleFFT_1D(mNumberOfFFTPoints); double[] fftData = new double[mNumberOfFFTPoints*2]; double max_index=-1; double max_magnitude=-1; final float sampleRate=44100; double frequency; for (int i=0;i<mNumberOfFFTPoints;i++){ //fftData[2 * i] = buffer[i+firstSample]; fftData[2 * i] = signal[i]; //da controllare fftData[2 * i + 1] = 0; fft.complexForward(fftData); } for(int i = 0; i < mNumberOfFFTPoints/2; i++){ magnitude[i]=Math.sqrt((fftData[2*i] * fftData[2*i]) + (fftData[2*i + 1] * fftData[2*i + 1])); if (max_magnitude<magnitude[i]){ max_magnitude=magnitude[i]; max_index=i; } } return frequency=sampleRate*(double)max_index/(double)mNumberOfFFTPoints; }
DoubleFFT_1D fft = new DoubleFFT_1D(reader.getSpectrum().getYvalues().length); DoubleFFT_1D ifft = new DoubleFFT_1D(reader.getSpectrum().getYvalues().length); fft.realForward(x); for (int i = 0; i < x.length/2; i++) { x[2*i] = Math.sqrt(Math.pow(x[2*i],2) + Math.pow(x[2*i+1],2)); x[2*i+1] = 0; } ifft.realInverse(x); for (int i = 1; i < x.length; i++) x[i] /= x[0]; x[0] = 1.0;
/** * Computes the inverse of the discrete Fourier transform (IDFT) of this * matrix. Throws IllegalArgumentException if the size of this matrix is not * a power of 2 number. * * @param scale * if true, then scaling is performed. */ public void ifft(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (fft == null) { fft = new DoubleFFT_1D(size); } if (isNoView) { fft.complexInverse(elements, scale); } else { DComplexMatrix1D copy = this.copy(); fft.complexInverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the inverse of the discrete Fourier transform (DFT) of this * matrix. The physical layout of the input data has to be as follows: * * <pre> * this[2*k] = Re[k], 0<=k<size/2 * this[2*k+1] = Im[k], 0<k<size/2 * this[1] = Re[size/2] * </pre> * * This method computes only half of the elements of the real transform. The * other half satisfies the symmetry condition. If you want the full real * inverse transform, use <code>getIfft</code>. * */ public void ifft(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (fft == null) { fft = new DoubleFFT_1D(size); } if (isNoView) { fft.realInverse(elements, scale); } else { DoubleMatrix1D copy = this.copy(); fft.realInverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Returns new complex matrix which is the discrete Fourier transform (DFT) * of this matrix. * * @return the discrete Fourier transform (DFT) of this matrix. */ public DenseDComplexMatrix1D getFft() { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); final double[] elems; if (isNoView == true) { elems = elements; } else { elems = (double[]) this.copy().elements(); } DenseDComplexMatrix1D c = new DenseDComplexMatrix1D(size); final double[] elementsC = (c).elements(); System.arraycopy(elems, 0, elementsC, 0, size); if (fft == null) { fft = new DoubleFFT_1D(size); } fft.realForwardFull(elementsC); ConcurrencyUtils.setNumberOfThreads(oldNthreads); return c; }
/** * Returns new complex matrix which is the inverse of the discrete Fourier * (IDFT) transform of this matrix. * * @return the inverse of the discrete Fourier transform (IDFT) of this * matrix. */ public DenseDComplexMatrix1D getIfft(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); final double[] elems; if (isNoView == true) { elems = elements; } else { elems = (double[]) this.copy().elements(); } DenseDComplexMatrix1D c = new DenseDComplexMatrix1D(size); final double[] elementsC = (c).elements(); System.arraycopy(elems, 0, elementsC, 0, size); if (fft == null) { fft = new DoubleFFT_1D(size); } fft.realInverseFull(elementsC, scale); ConcurrencyUtils.setNumberOfThreads(oldNthreads); return c; }
public void run() { for (int s = firstSlice; s < lastSlice; s++) { int idx1 = s * sliceStride; for (int r = 0; r < rows; r++) { fftColumns.complexInverse(a, idx1 + r * rowStride, scale); } } } });
public void run() { for (long s = firstSlice; s < lastSlice; s++) { long idx1 = s * sliceStridel; for (long r = 0; r < rowsl; r++) { fftColumns.complexForward(a, idx1 + r * rowStridel); } } } });
realInverse(a, 0, scale);
public void run() { for (int s = firstSlice; s < lastSlice; s++) { for (int r = 0; r < rows; r++) { fftColumns.realInverseFull(a[s][r], scale); } } } });
public static double[][] computeFreqMagPhase(double[] time, double[] data) { int n = time.length; if (data.length != n) throw new RuntimeException("input.length != n"); DoubleFFT_1D fft = new DoubleFFT_1D(n); double T = time[n - 1] - time[0]; double fftInput[] = copyDoubleArray(data); fft.realForward(fftInput); double[] magnitude = extractMagnitude(fftInput); double[] phase = extractPhaseRadians(fftInput); double[] frequency = new double[n / 2]; for (int i = 0; i < n / 2; i++) { frequency[i] = (i) / T; } return new double[][] { frequency, magnitude, phase }; }
public void run() { for (int i = firstRow; i < lastRow; i++) { fftColumns.realForward(a, i * columns); } } });
/** * Computes the discrete Fourier transform (DFT) of this matrix. Throws * IllegalArgumentException if the size of this matrix is not a power of 2 * number. */ public void fft() { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (fft == null) { fft = new DoubleFFT_1D(size); } if (isNoView) { fft.complexForward(elements); } else { DComplexMatrix1D copy = this.copy(); fft.complexForward((double[]) copy.elements()); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
public void run() { for (long s = firstSlice; s < lastSlice; s++) { long idx1 = s * sliceStridel; for (long r = 0; r < rowsl; r++) { fftColumns.complexInverse(a, idx1 + r * rowStridel, scale); } } } });
public void run() { for (long s = firstSlice; s < lastSlice; s++) { long idx1 = s * sliceStridel; for (long r = 0; r < rowsl; r++) { fftColumns.complexForward(a, idx1 + r * rowStridel); } } } });