All Projects → berndporr → Kiss Fft

berndporr / Kiss Fft

Licence: bsd-3-clause
A compact FFT library in C with an Android JNI wrapper

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Kiss Fft

Competitive Programming Repository
Competitive Programming templates that I used during the past few years.
Stars: ✭ 367 (+1259.26%)
Mutual labels:  fft
Realtime pyaudio fft
Realtime audio analysis in Python, using PyAudio and Numpy to extract and visualize FFT features from streaming audio.
Stars: ✭ 515 (+1807.41%)
Mutual labels:  fft
Qspectrumanalyzer
Spectrum analyzer for multiple SDR platforms (PyQtGraph based GUI for soapy_power, hackrf_sweep, rtl_power, rx_power and other backends)
Stars: ✭ 677 (+2407.41%)
Mutual labels:  fft
Keepalive
Fighting against force-stop kill process on Android with binder ioctl / Android高级保活
Stars: ✭ 376 (+1292.59%)
Mutual labels:  jni
Jni Rs
Rust bindings to the Java Native Interface — JNI
Stars: ✭ 456 (+1588.89%)
Mutual labels:  jni
Surge
A Swift library that uses the Accelerate framework to provide high-performance functions for matrix math, digital signal processing, and image manipulation.
Stars: ✭ 4,945 (+18214.81%)
Mutual labels:  fft
Aparapi
The New Official Aparapi: a framework for executing native Java and Scala code on the GPU.
Stars: ✭ 352 (+1203.7%)
Mutual labels:  jni
Jep
Embed Python in Java
Stars: ✭ 759 (+2711.11%)
Mutual labels:  jni
Flapigen Rs
Tool for connecting programs or libraries written in Rust with other languages
Stars: ✭ 473 (+1651.85%)
Mutual labels:  jni
Vkfft
Vulkan Fast Fourier Transform library
Stars: ✭ 594 (+2100%)
Mutual labels:  fft
Fmj
FMJ (FFMpeg for Java)。通过Java调用FFMpeg命令的方式来对音视频进行处理(获取信息、截图等等)。
Stars: ✭ 379 (+1303.7%)
Mutual labels:  jni
Dsp Theory
Theory of digital signal processing (DSP): signals, filtration (IIR, FIR, CIC, MAF), transforms (FFT, DFT, Hilbert, Z-transform) etc.
Stars: ✭ 437 (+1518.52%)
Mutual labels:  fft
Jnitrace
A Frida based tool that traces usage of the JNI API in Android apps.
Stars: ✭ 534 (+1877.78%)
Mutual labels:  jni
Android Api Securekeys
Store data in a simple and secure way
Stars: ✭ 372 (+1277.78%)
Mutual labels:  jni
Jpype
JPype is cross language bridge to allow python programs full access to java class libraries.
Stars: ✭ 685 (+2437.04%)
Mutual labels:  jni
Sleef
SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT
Stars: ✭ 353 (+1207.41%)
Mutual labels:  fft
Ffsubsync
Automagically synchronize subtitles with video.
Stars: ✭ 5,167 (+19037.04%)
Mutual labels:  fft
Fake Jni
An implementation of the JNI and JVMTI with support for direct interaction between natively registered classes and JVM objects.
Stars: ✭ 20 (-25.93%)
Mutual labels:  jni
Ffmpeg
Mirror of https://git.ffmpeg.org/ffmpeg.git
Stars: ✭ 27,382 (+101314.81%)
Mutual labels:  fft
Dart native
Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.
Stars: ✭ 564 (+1988.89%)
Mutual labels:  jni

KISS FFT

KISS FFT - A mixed-radix Fast Fourier Transform in C with an Android JNI wrapper.

In C

Complex to Complex FFT and IFFT

The basic usage for 1-d complex FFT is:

#include "kiss_fft.h"

kiss_fft_cfg cfg = kiss_fft_alloc( nfft, is_inverse_fft );
kiss_fft_cpx *cx_in = new kiss_fft_cpx[nfft];
kiss_fft_cpx *cx_out = new kiss_fft_cpx[nfft];
    
// put kth sample in cx_in[k].r and cx_in[k].i
            
kiss_fft( cfg , cx_in , cx_out );
            
// transformed. DC is in cx_out[0].r and cx_out[0].i 
            
free(cfg);
delete[] cx_in;
delete[] cx_out;
  • nfft is the number of samples in both time- and frequency domain
  • is_inverse is 0 for the forward transform and 1 for the inverse
  • cx_in and cx_out are arrays of nfft samples
  • Frequency domain: cx_out[0] is the DC bin of the FFT and cx_out[nfft/2] is the Nyquist bin (if exists).
  • Files: kiss_fft.h, kiss_fft.cpp and _kiss_fft_guts.h.

Real valued FFT

A real valued optimized FFT which takes real valued signals as its input is implemtned in kiss_fftr.h and kiss_fftr.cpp. It returns the positive half-spectrum: (nfft/2+1) complex frequency bins.

Real signal to complex frequencies transform

#include "kiss_fftr.h"

kiss_fftr_cfg cfg = kiss_fftr_alloc(nfft, 0);
double *cx_in = new kiss_fft_scalar[nfft];
kiss_fft_cpx *cx_out = new kiss_fft_cpx[nfft/2+1];

// put `nfft` samples in cx_in[k]

kiss_fftr(cfg, cx_in, cx_out);

// Process the spectrum `cx_out` here: We have `nfft/2+1` (!) samples.
            
free(cfg);
delete[] cx_in;
delete[] cx_out;

Complex frequencies to real signal transform

#include "kiss_fftr.h"

kiss_fftr_cfg cfg = kiss_fftr_alloc(nfft, 1);
kiss_fft_cpx *cx_in = new kiss_fft_cpx[nfft/2+1];
double *cx_out = new kiss_fft_scalar[nfft];

// put kth frequency sample in cx_in[k] up to index `nfft/2`.
// No need to populate the mirror.

kiss_fftr(cfg, cx_in, cx_out);

// Process signal `cx_out` here. It has again `nfft` samples
// and is real valued.
            
free(cfg);
delete[] cx_in;
delete[] cx_out;

Installation / Usage

The library is so small that you can directly include the sources in your project or you can pre-package it as a static library and then link it into your project. Create the static library (with the help of cmake):

cmake .
make
make install

which is installed in the usual places (e.g. /usr/local/lib and /usr/local/include) and is called libkiss-fft.a.

Android

Super-fast native FFTs under Android.

Compilation

Open this project in Android studio and run "Build". Depending on the config you'll generate a debug version of the kiss-fft library or a release version.

Installation

The Android library is in jnifft/build/outputs/. Just import it into your Android project with "New-Module-Android Library" and add the dependency with

compile project(":jnifft-release")

Complex to Complex transform

kissFastFourierTransformer = new KISSFastFourierTransformer();
Complex[] outdata = kissFastFourierTransformer.transform(indata, TransformType.FORWARD);

which transforms from Complex to Complex as defined in the apache Commons. The constant TransformType is also defined in apache Commons which determines if it's a forward or inverse transform. It can be used as a direct replacement of the apache commons FFT function.

There are also convenience functions as implemented in the apache commons library for double and Double which perform the conversion to Complex in C++. The function for the primitive type double is slightly faster than the one with Double.

Real to Complex and Complex to Real transform

For real valued sequences there are two optimised functions which directly perform the FFT on the raw double buffer without any conversion to Complex. For such real valued sequences this runs at least twice as fast as the Complex FFT functions above. The complex frequency sequence of the real sequence of length N has the length N/2+1 and then expands back to length N by the inverse transform:

public Complex[] transformRealOptimisedForward(double[] v)
public double[] transformRealOptimisedInverse(Complex[] v)

Unit tests (Android vs C)

Run FFTTest and FFTRTest which compare the results to that from the apache commons FFT functions and perform an ifft(fft) test to check for rounding errors.

Attribution

This is a fork, stripped down and further debugged version of the original kiss-fft library by Mark Borgerding [email protected].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].