Skip to content

hendriks73/jipesFFT

Repository files navigation

LGPL 2.1 Maven Central Build and Test CodeCov

jipesFFT

Native FFT (Fast Fourier Transformation) implementations for Java (macOS, Windows, Linux).

The macOS version uses Apple's Accelerate framework. Windows and Linux versions use more ordinary implementations.

Installation

jipesFFT is released via Maven. You can install it via the following dependency:

<dependencies>
    <dependency>
        <groupId>com.tagtraum</groupId>
        <artifactId>jipesfft-complete</artifactId>
    </dependency>
</dependencies>

Usage

Here's a simple example that demonstrates how the com.tagtraum.jipesfft.FFT class can be used:

import com.tagtraum.jipesfft.FFT;

class Demo {
    public static void main(final String[] args) {
        // Create a new FFT instance suitable
        // for a window length of 8 samples.
        // Do this in a "try" statement to ensure native resources
        // are freed in a timely fashion.
        try (final FFT fft = new FFT(8)) {
            final float[] result = fft.transform(new float[]{0, 0, 0, 1, 0, 0, 0, 1});
            // real part of the complex result
            float[] real = result[FFT.REAL];
            // imaginary part of the complex result
            float[] imaginary = result[FFT.IMAGINARY];
            // frequencies for the result - must still be multiplied with sampling
            // frequency. Second half of frequency array is not necessarily useful.
            float[] frequencies = result[FFT.FREQUENCY];

            // go on and do something with it...
        }
    }
}

Java Module

jipesFFT is shipped as a Java module (see JPMS) with the name tagtraum.jipesfft.

API

You can find the complete API here.

Additional Resources