$ show mborgerding/kissfft
KISS FFT is a mixed-radix Fast Fourier Transform library implemented in C and C++. It provides a compact, portable, and reasonably efficient FFT implementation supporting complex and real-valued transforms in one or multiple dimensions. The library is designed to be simple to integrate, offering both a C API (kiss_fft, kiss_fftr, kiss_fftnd, kiss_fftndr) and a header-only C++ template class. It supports multiple scalar types (float, double, int16_t, int32_t) and SIMD acceleration via SSE, LSX, and LASX instruction sets. The core algorithm uses decimation-in-time with optimized butterflies for radices 2, 3, 4, and 5, and provides a cache mechanism (kfc) to reuse FFT configurations. The codebase is self-contained with no external dependencies beyond libm; optional tools require fftw3 and libpng for benchmarking and image generation. It is widely used in embedded systems, audio processing, and scientific computing due to its permissive BSD license and straightforward API.
The LLM identified 3 files worth highlighting for reuse:
A header-only C++ template class implementing a mixed-radix FFT. It factorizes the transform length, precomputes twiddle factors, and provides a recursive transform method with specialized butterfly functions for radices 2,3,4,5 and a generic fallback. The class is self-contained, using only standard C++ headers (vector, complex, cmath), and can be dropped into any C++ project. It demonstrates clean template metaprogramming, efficient use of STL containers, and careful handling of complex arithmetic and twiddle generation. It also includes a real-valued transform helper (transform_real).
Implements an N-dimensional complex FFT by decomposing the problem into a sequence of 1D FFTs along each dimension. It uses a clever stride-based approach to transpose the matrix between stages, effectively performing the multi-dimensional transform with minimal copying. The implementation is self-contained within the file, relying only on the core kiss_fft_stride function. It demonstrates a clear understanding of memory layout and algorithmic decomposition, and could be reused as a generic multi-dimensional transform module.
Implements fast FIR filtering using overlap-save (overlap-scrap) convolution via FFT. It handles the allocation of FFT plans, frequency-domain multiplication, and proper handling of sample buffers with offset management to simulate continuous filtering. The code includes both a direct convolution fallback for comparison and a flush mechanism. It demonstrates advanced signal processing concepts and careful memory management, and is structured as a reusable state object (kiss_fastfir_cfg) that can be applied to streaming audio or data.