Fast, modern C++ DSP framework

KFR is built for developers who need a powerful toolkit for Audio and DSP applications

Get KFR Fork on GitHub

Built by developers for developers


Fast

All algorithms are designed and implemented for maximum performance and functionality

FFT

KFR includes Fastest Fourier Transform(*) and many more DSP and Audio algorithms

Cross-platform

KFR is cross-platform and supports macOS, Linux, and Windows, both Intel and ARM cpus

Extensible

Writing your own algorithms based on KFR framework is easy

Precise

Thousands of tests are executed in order to guarantee accurate and precise results

Open Source

KFR is open source and all the code is available on GitHub

Features


The KFR framework is packed with ready-to-use C++ classes and functions for various DSP tasks from high-quality filtering to small helpers to improve development speed
macOS (Xcode 7, 8) Windows (Visual Studio/MinGW) Linux

  • DFT/FFT
  • Convolution
  • High quality Sample Rate Conversion (SRC)
  • FIR (Finite Impulse Response) filtering
  • IIR (Infnite Impulse Response) filtering
  • FIR filter design using window method
  • Delay line and fractional delay line
  • Biquad filters and Biquad cascades
  • Biquad design functions
  • Oscillators
  • Window functions
  • Waveshaper
  • Stereo conversion (L/R, M/S)
  • Goertzel algorithm
  • DC Remover
  • Audio file reading/writing
  • Fast incremental sine/cosine generation
  • Pseudorandom number generator
  • Sorting
  • Mathematical and statistical functions
  • A-, B- and C- weighting
  • Template expressions
  • SIMD functions
  • Runtime CPU dispatching
  • All vector lengths are supported
  • Ring (Circular) buffer

Performance


Highest possible performance is one of the main goals of the KFR framework.
Accurate benchmark measurements prove that KFR offers high speed implementations of the DSP algorithms

Our Fast Fourier Transform implementation is the fastest FFT according to measurements of the best available FFT libraries

FFT performance (double precision)

Biquad performance (single precision)

FFT benchmark source code

Getting started


 git clone https://github.com/kfrlib/kfr.git

or

Download .zip

Examples

For more examples, check examples directory


#include <kfr/all.hpp>

using namespace kfr;

...

univector<complex<float_type>, size> in  = sin(linspace(0.0, c_pi<float_type, 2> * 4.0, size));
univector<complex<float_type>, size> out = scalar(qnan);

// initialize fft
const dft_plan<float_type> dft(size);

// allocate work buffer for fft (if needed)
univector<u8> temp(dft.temp_size);

// perform forward fft
dft.execute(out, in, temp);

// scale output
out = out / size;

// get magnitude and convert to decibels
univector<float_type, size> dB = amp_to_dB(cabs(out));

println("max  = ", max(dB));
println("min  = ", min(dB));
println("mean = ", mean(dB));
println("rms  = ", rms(dB));
#include <kfr/all.hpp>

using namespace kfr;

template <typename T>
void print_type(const T& value)
{
    println(type_name(value), ":");
    println(value);
}

...

using color       = vec<u8, 3>;
const color green = cast<u8>(make_vector(0.0, 1.0, 0.0) * 255);
print_type(green);
// >>> kfr::vec<unsigned char, 3>:
// >>>         0       255         0

License


KFR is dual-licensed, available under both commercial and open-source GPL license.
If you want to use KFR in commercial product or a closed-source project, you need to purchase a Commercial License

Purchase a license