From ac79f0a76789cdc4ed761a12d461fd48c6891d07 Mon Sep 17 00:00:00 2001 From: lucifetsmith Date: Sat, 26 Jan 2019 10:39:49 +0800 Subject: [PATCH 1/7] Create .travis.yml --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ff99939 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: python + +python: + - "3.4.3" + +sudo: true + +before_install: + - apt-get install libfftw3-dev + +install: true + +script: + - make testall From 81b5370dedeaf1ab89fc3cae9e1567b1c1b5bdef Mon Sep 17 00:00:00 2001 From: lucifetsmith Date: Sat, 26 Jan 2019 11:04:19 +0800 Subject: [PATCH 2/7] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ff99939..f5cb524 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,8 @@ language: python python: - "3.4.3" +dist: trusty + sudo: true before_install: From 40ff673342b1fcaa4f7ddf5d55f61e247adac6e9 Mon Sep 17 00:00:00 2001 From: lucifetsmith Date: Sat, 26 Jan 2019 11:11:27 +0800 Subject: [PATCH 3/7] Update .travis.yml --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f5cb524..acbd883 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,16 @@ language: python python: - - "3.4.3" + - "2.6" dist: trusty -sudo: true - before_install: - - apt-get install libfftw3-dev + - sudo apt-get install -y libfftw3-dev + +addons: + apt: + update: true install: true From 6668a8214b97320c634f9463c5ca1912af824bec Mon Sep 17 00:00:00 2001 From: lucifetsmith Date: Sat, 26 Jan 2019 11:32:03 +0800 Subject: [PATCH 4/7] Create README.md --- README.md | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9c0f3c8 --- /dev/null +++ b/README.md @@ -0,0 +1,133 @@ +# KISS FFT [![Build Status](https://travis-ci.com/lucifetsmith/kissfft.svg?branch=master)](https://travis-ci.com/lucifetsmith/kissfft) + +KISS FFT - A mixed-radix Fast Fourier Transform based up on the principle, +"Keep It Simple, Stupid." + + There are many great fft libraries already around. Kiss FFT is not trying +to be better than any of them. It only attempts to be a reasonably efficient, +moderately useful FFT that can use fixed or floating data types and can be +incorporated into someone's C program in a few minutes with trivial licensing. + +USAGE: + + The basic usage for 1-d complex FFT is: + + #include "kiss_fft.h" + + kiss_fft_cfg cfg = kiss_fft_alloc( nfft ,is_inverse_fft ,0,0 ); + + while ... + + ... // 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 + + kiss_fft_free(cfg); + + Note: frequency-domain data is stored from dc up to 2pi. + so cx_out[0] is the dc bin of the FFT + and cx_out[nfft/2] is the Nyquist bin (if exists) + + Declarations are in "kiss_fft.h", along with a brief description of the +functions you'll need to use. + +Code definitions for 1d complex FFTs are in kiss_fft.c. + +You can do other cool stuff with the extras you'll find in tools/ + + * multi-dimensional FFTs + * real-optimized FFTs (returns the positive half-spectrum: (nfft/2+1) complex frequency bins) + * fast convolution FIR filtering (not available for fixed point) + * spectrum image creation + +The core fft and most tools/ code can be compiled to use float, double, + Q15 short or Q31 samples. The default is float. + + +BACKGROUND: + + I started coding this because I couldn't find a fixed point FFT that didn't +use assembly code. I started with floating point numbers so I could get the +theory straight before working on fixed point issues. In the end, I had a +little bit of code that could be recompiled easily to do ffts with short, float +or double (other types should be easy too). + + Once I got my FFT working, I was curious about the speed compared to +a well respected and highly optimized fft library. I don't want to criticize +this great library, so let's call it FFT_BRANDX. +During this process, I learned: + + 1. FFT_BRANDX has more than 100K lines of code. The core of kiss_fft is about 500 lines (cpx 1-d). + 2. It took me an embarrassingly long time to get FFT_BRANDX working. + 3. A simple program using FFT_BRANDX is 522KB. A similar program using kiss_fft is 18KB (without optimizing for size). + 4. FFT_BRANDX is roughly twice as fast as KISS FFT in default mode. + + It is wonderful that free, highly optimized libraries like FFT_BRANDX exist. +But such libraries carry a huge burden of complexity necessary to extract every +last bit of performance. + + Sometimes simpler is better, even if it's not better. + +FREQUENTLY ASKED QUESTIONS: + Q: Can I use kissfft in a project with a ___ license? + A: Yes. See LICENSE below. + + Q: Why don't I get the output I expect? + A: The two most common causes of this are + 1) scaling : is there a constant multiplier between what you got and what you want? + 2) mixed build environment -- all code must be compiled with same preprocessor + definitions for FIXED_POINT and kiss_fft_scalar + + Q: Will you write/debug my code for me? + A: Probably not unless you pay me. I am happy to answer pointed and topical questions, but + I may refer you to a book, a forum, or some other resource. + + +PERFORMANCE: + (on Athlon XP 2100+, with gcc 2.96, float data type) + + Kiss performed 10000 1024-pt cpx ffts in .63 s of cpu time. + For comparison, it took md5sum twice as long to process the same amount of data. + + Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024). + +DO NOT: + ... use Kiss if you need the Fastest Fourier Transform in the World + ... ask me to add features that will bloat the code + +UNDER THE HOOD: + + Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. If you give it an input buffer + and output buffer that are the same, a temporary buffer will be created to hold the data. + + No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory). + + No scaling is done for the floating point version (for speed). + Scaling is done both ways for the fixed-point version (for overflow prevention). + + Optimized butterflies are used for factors 2,3,4, and 5. + + The real (i.e. not complex) optimization code only works for even length ffts. It does two half-length + FFTs in parallel (packed into real&imag), and then combines them via twiddling. The result is + nfft/2+1 complex frequency bins from DC to Nyquist. If you don't know what this means, search the web. + + The fast convolution filtering uses the overlap-scrap method, slightly + modified to put the scrap at the tail. + +LICENSE: + Revised BSD License, see COPYING for verbiage. + Basically, "free to use&change, give credit where due, no guarantees" + Note this license is compatible with GPL at one end of the spectrum and closed, commercial software at + the other end. See http://www.fsf.org/licensing/licenses + +TODO: + *) Add real optimization for odd length FFTs + *) Document/revisit the input/output fft scaling + *) Make doc describing the overlap (tail) scrap fast convolution filtering in kiss_fastfir.c + *) Test all the ./tools/ code with fixed point (kiss_fastfir.c doesn't work, maybe others) + +AUTHOR: + Mark Borgerding + Mark@Borgerding.net From 5ba824ceec7e9b334acab57f1fb5fdd436d6e790 Mon Sep 17 00:00:00 2001 From: lucifetsmith Date: Sat, 26 Jan 2019 11:59:54 +0800 Subject: [PATCH 5/7] Update README.md --- README.md | 139 ++++++++++++++++++++++++++---------------------------- 1 file changed, 68 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 9c0f3c8..0d33027 100644 --- a/README.md +++ b/README.md @@ -2,132 +2,129 @@ KISS FFT - A mixed-radix Fast Fourier Transform based up on the principle, "Keep It Simple, Stupid." - - There are many great fft libraries already around. Kiss FFT is not trying +There are many great fft libraries already around. Kiss FFT is not trying to be better than any of them. It only attempts to be a reasonably efficient, moderately useful FFT that can use fixed or floating data types and can be incorporated into someone's C program in a few minutes with trivial licensing. -USAGE: +## USAGE: - The basic usage for 1-d complex FFT is: +The basic usage for 1-d complex FFT is: - #include "kiss_fft.h" - - kiss_fft_cfg cfg = kiss_fft_alloc( nfft ,is_inverse_fft ,0,0 ); - - while ... +```c + #include "kiss_fft.h" + kiss_fft_cfg cfg = kiss_fft_alloc( nfft ,is_inverse_fft ,0,0 ); + while ... + + ... // put kth sample in cx_in[k].r and cx_in[k].i - ... // 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 - - kiss_fft_free(cfg); - - Note: frequency-domain data is stored from dc up to 2pi. + kiss_fft( cfg , cx_in , cx_out ); + + ... // transformed. DC is in cx_out[0].r and cx_out[0].i + + kiss_fft_free(cfg); +``` + - **Note**: frequency-domain data is stored from dc up to 2pi. so cx_out[0] is the dc bin of the FFT and cx_out[nfft/2] is the Nyquist bin (if exists) - Declarations are in "kiss_fft.h", along with a brief description of the +Declarations are in "kiss_fft.h", along with a brief description of the functions you'll need to use. Code definitions for 1d complex FFTs are in kiss_fft.c. You can do other cool stuff with the extras you'll find in tools/ - - * multi-dimensional FFTs - * real-optimized FFTs (returns the positive half-spectrum: (nfft/2+1) complex frequency bins) - * fast convolution FIR filtering (not available for fixed point) - * spectrum image creation +> - multi-dimensional FFTs +> - real-optimized FFTs (returns the positive half-spectrum: + (nfft/2+1) complex frequency bins) +> - fast convolution FIR filtering (not available for fixed point) +> - spectrum image creation The core fft and most tools/ code can be compiled to use float, double, Q15 short or Q31 samples. The default is float. -BACKGROUND: +## BACKGROUND - I started coding this because I couldn't find a fixed point FFT that didn't +I started coding this because I couldn't find a fixed point FFT that didn't use assembly code. I started with floating point numbers so I could get the theory straight before working on fixed point issues. In the end, I had a little bit of code that could be recompiled easily to do ffts with short, float or double (other types should be easy too). - Once I got my FFT working, I was curious about the speed compared to +Once I got my FFT working, I was curious about the speed compared to a well respected and highly optimized fft library. I don't want to criticize this great library, so let's call it FFT_BRANDX. During this process, I learned: - 1. FFT_BRANDX has more than 100K lines of code. The core of kiss_fft is about 500 lines (cpx 1-d). - 2. It took me an embarrassingly long time to get FFT_BRANDX working. - 3. A simple program using FFT_BRANDX is 522KB. A similar program using kiss_fft is 18KB (without optimizing for size). - 4. FFT_BRANDX is roughly twice as fast as KISS FFT in default mode. +> 1. FFT_BRANDX has more than 100K lines of code. The core of kiss_fft is about 500 lines (cpx 1-d). +> 2. It took me an embarrassingly long time to get FFT_BRANDX working. +> 3. A simple program using FFT_BRANDX is 522KB. A similar program using kiss_fft is 18KB (without optimizing for size). +> 4. FFT_BRANDX is roughly twice as fast as KISS FFT in default mode. - It is wonderful that free, highly optimized libraries like FFT_BRANDX exist. +It is wonderful that free, highly optimized libraries like FFT_BRANDX exist. But such libraries carry a huge burden of complexity necessary to extract every last bit of performance. - Sometimes simpler is better, even if it's not better. +**Sometimes simpler is better, even if it's not better.** -FREQUENTLY ASKED QUESTIONS: - Q: Can I use kissfft in a project with a ___ license? - A: Yes. See LICENSE below. +## FREQUENTLY ASKED QUESTIONS: +> Q: Can I use kissfft in a project with a ___ license? +> A: Yes. See LICENSE below. - Q: Why don't I get the output I expect? - A: The two most common causes of this are - 1) scaling : is there a constant multiplier between what you got and what you want? - 2) mixed build environment -- all code must be compiled with same preprocessor - definitions for FIXED_POINT and kiss_fft_scalar +>Q: Why don't I get the output I expect? +> A: The two most common causes of this are +> 1) scaling : is there a constant multiplier between what you got and what you want? +> 2) mixed build environment -- all code must be compiled with same preprocessor +> definitions for FIXED_POINT and kiss_fft_scalar - Q: Will you write/debug my code for me? - A: Probably not unless you pay me. I am happy to answer pointed and topical questions, but - I may refer you to a book, a forum, or some other resource. +> Q: Will you write/debug my code for me? +> A: Probably not unless you pay me. I am happy to answer pointed and topical questions, but +> I may refer you to a book, a forum, or some other resource. -PERFORMANCE: +## PERFORMANCE (on Athlon XP 2100+, with gcc 2.96, float data type) - Kiss performed 10000 1024-pt cpx ffts in .63 s of cpu time. - For comparison, it took md5sum twice as long to process the same amount of data. +Kiss performed 10000 1024-pt cpx ffts in .63 s of cpu time. +For comparison, it took md5sum twice as long to process the same amount of data. +Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024). - Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024). +**DO NOT:** +- use Kiss if you need the Fastest Fourier Transform in the World +- ask me to add features that will bloat the code -DO NOT: - ... use Kiss if you need the Fastest Fourier Transform in the World - ... ask me to add features that will bloat the code +## UNDER THE HOOD -UNDER THE HOOD: +Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. If you give it an input buffer +and output buffer that are the same, a temporary buffer will be created to hold the data. - Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. If you give it an input buffer - and output buffer that are the same, a temporary buffer will be created to hold the data. +No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory). - No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory). +No scaling is done for the floating point version (for speed). +Scaling is done both ways for the fixed-point version (for overflow prevention). - No scaling is done for the floating point version (for speed). - Scaling is done both ways for the fixed-point version (for overflow prevention). +Optimized butterflies are used for factors 2,3,4, and 5. - Optimized butterflies are used for factors 2,3,4, and 5. +The real (i.e. not complex) optimization code only works for even length ffts. It does two half-length +FFTs in parallel (packed into real&imag), and then combines them via twiddling. The result is +nfft/2+1 complex frequency bins from DC to Nyquist. If you don't know what this means, search the web. - The real (i.e. not complex) optimization code only works for even length ffts. It does two half-length - FFTs in parallel (packed into real&imag), and then combines them via twiddling. The result is - nfft/2+1 complex frequency bins from DC to Nyquist. If you don't know what this means, search the web. +The fast convolution filtering uses the overlap-scrap method, slightly +modified to put the scrap at the tail. - The fast convolution filtering uses the overlap-scrap method, slightly - modified to put the scrap at the tail. - -LICENSE: +## LICENSE Revised BSD License, see COPYING for verbiage. Basically, "free to use&change, give credit where due, no guarantees" Note this license is compatible with GPL at one end of the spectrum and closed, commercial software at the other end. See http://www.fsf.org/licensing/licenses -TODO: - *) Add real optimization for odd length FFTs - *) Document/revisit the input/output fft scaling - *) Make doc describing the overlap (tail) scrap fast convolution filtering in kiss_fastfir.c - *) Test all the ./tools/ code with fixed point (kiss_fastfir.c doesn't work, maybe others) +## TODO + - Add real optimization for odd length FFTs + - Document/revisit the input/output fft scaling + - Make doc describing the overlap (tail) scrap fast convolution filtering in kiss_fastfir.c + - Test all the ./tools/ code with fixed point (kiss_fastfir.c doesn't work, maybe others) -AUTHOR: +## AUTHOR Mark Borgerding Mark@Borgerding.net From a74d6edce90ee86edf36ca0930d6c8aae50bef15 Mon Sep 17 00:00:00 2001 From: lucifetsmith Date: Sat, 26 Jan 2019 12:04:56 +0800 Subject: [PATCH 6/7] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0d33027..0f1ed47 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ KISS FFT - A mixed-radix Fast Fourier Transform based up on the principle, "Keep It Simple, Stupid." + There are many great fft libraries already around. Kiss FFT is not trying to be better than any of them. It only attempts to be a reasonably efficient, moderately useful FFT that can use fixed or floating data types and can be @@ -69,16 +70,16 @@ last bit of performance. **Sometimes simpler is better, even if it's not better.** ## FREQUENTLY ASKED QUESTIONS: -> Q: Can I use kissfft in a project with a ___ license? +> Q: Can I use kissfft in a project with a ___ license?
> A: Yes. See LICENSE below. ->Q: Why don't I get the output I expect? +> Q: Why don't I get the output I expect?
> A: The two most common causes of this are > 1) scaling : is there a constant multiplier between what you got and what you want? > 2) mixed build environment -- all code must be compiled with same preprocessor > definitions for FIXED_POINT and kiss_fft_scalar -> Q: Will you write/debug my code for me? +> Q: Will you write/debug my code for me?
> A: Probably not unless you pay me. I am happy to answer pointed and topical questions, but > I may refer you to a book, a forum, or some other resource. @@ -99,7 +100,7 @@ Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024). Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. If you give it an input buffer and output buffer that are the same, a temporary buffer will be created to hold the data. -No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory). +No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory).[ No scaling is done for the floating point version (for speed). Scaling is done both ways for the fixed-point version (for overflow prevention). From 2450b3930b716c582d6eced230f84835946cf6b3 Mon Sep 17 00:00:00 2001 From: lucifetsmith Date: Sat, 26 Jan 2019 13:40:19 +0800 Subject: [PATCH 7/7] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index acbd883..a5c5c3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,5 @@ addons: install: true script: + - make all - make testall