annotate ext/kissfft/README @ 510:2adcd94c2079

Update test
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 06 Jun 2019 14:26:46 +0100
parents 1f1999b0f577
children
rev   line source
c@409 1 KISS FFT - A mixed-radix Fast Fourier Transform based up on the principle,
c@409 2 "Keep It Simple, Stupid."
c@409 3
c@409 4 There are many great fft libraries already around. Kiss FFT is not trying
c@409 5 to be better than any of them. It only attempts to be a reasonably efficient,
c@409 6 moderately useful FFT that can use fixed or floating data types and can be
c@409 7 incorporated into someone's C program in a few minutes with trivial licensing.
c@409 8
c@409 9 USAGE:
c@409 10
c@409 11 The basic usage for 1-d complex FFT is:
c@409 12
c@409 13 #include "kiss_fft.h"
c@409 14
c@409 15 kiss_fft_cfg cfg = kiss_fft_alloc( nfft ,is_inverse_fft ,0,0 );
c@409 16
c@409 17 while ...
c@409 18
c@409 19 ... // put kth sample in cx_in[k].r and cx_in[k].i
c@409 20
c@409 21 kiss_fft( cfg , cx_in , cx_out );
c@409 22
c@409 23 ... // transformed. DC is in cx_out[0].r and cx_out[0].i
c@409 24
c@409 25 free(cfg);
c@409 26
c@409 27 Note: frequency-domain data is stored from dc up to 2pi.
c@409 28 so cx_out[0] is the dc bin of the FFT
c@409 29 and cx_out[nfft/2] is the Nyquist bin (if exists)
c@409 30
c@409 31 Declarations are in "kiss_fft.h", along with a brief description of the
c@409 32 functions you'll need to use.
c@409 33
c@409 34 Code definitions for 1d complex FFTs are in kiss_fft.c.
c@409 35
c@409 36 You can do other cool stuff with the extras you'll find in tools/
c@409 37
c@409 38 * multi-dimensional FFTs
c@409 39 * real-optimized FFTs (returns the positive half-spectrum: (nfft/2+1) complex frequency bins)
c@409 40 * fast convolution FIR filtering (not available for fixed point)
c@409 41 * spectrum image creation
c@409 42
c@409 43 The core fft and most tools/ code can be compiled to use float, double,
c@409 44 Q15 short or Q31 samples. The default is float.
c@409 45
c@409 46
c@409 47 BACKGROUND:
c@409 48
c@409 49 I started coding this because I couldn't find a fixed point FFT that didn't
c@409 50 use assembly code. I started with floating point numbers so I could get the
c@409 51 theory straight before working on fixed point issues. In the end, I had a
c@409 52 little bit of code that could be recompiled easily to do ffts with short, float
c@409 53 or double (other types should be easy too).
c@409 54
c@409 55 Once I got my FFT working, I was curious about the speed compared to
c@409 56 a well respected and highly optimized fft library. I don't want to criticize
c@409 57 this great library, so let's call it FFT_BRANDX.
c@409 58 During this process, I learned:
c@409 59
c@409 60 1. FFT_BRANDX has more than 100K lines of code. The core of kiss_fft is about 500 lines (cpx 1-d).
c@409 61 2. It took me an embarrassingly long time to get FFT_BRANDX working.
c@409 62 3. A simple program using FFT_BRANDX is 522KB. A similar program using kiss_fft is 18KB (without optimizing for size).
c@409 63 4. FFT_BRANDX is roughly twice as fast as KISS FFT in default mode.
c@409 64
c@409 65 It is wonderful that free, highly optimized libraries like FFT_BRANDX exist.
c@409 66 But such libraries carry a huge burden of complexity necessary to extract every
c@409 67 last bit of performance.
c@409 68
c@409 69 Sometimes simpler is better, even if it's not better.
c@409 70
c@409 71 FREQUENTLY ASKED QUESTIONS:
c@409 72 Q: Can I use kissfft in a project with a ___ license?
c@409 73 A: Yes. See LICENSE below.
c@409 74
c@409 75 Q: Why don't I get the output I expect?
c@409 76 A: The two most common causes of this are
c@409 77 1) scaling : is there a constant multiplier between what you got and what you want?
c@409 78 2) mixed build environment -- all code must be compiled with same preprocessor
c@409 79 definitions for FIXED_POINT and kiss_fft_scalar
c@409 80
c@409 81 Q: Will you write/debug my code for me?
c@409 82 A: Probably not unless you pay me. I am happy to answer pointed and topical questions, but
c@409 83 I may refer you to a book, a forum, or some other resource.
c@409 84
c@409 85
c@409 86 PERFORMANCE:
c@409 87 (on Athlon XP 2100+, with gcc 2.96, float data type)
c@409 88
c@409 89 Kiss performed 10000 1024-pt cpx ffts in .63 s of cpu time.
c@409 90 For comparison, it took md5sum twice as long to process the same amount of data.
c@409 91
c@409 92 Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024).
c@409 93
c@409 94 DO NOT:
c@409 95 ... use Kiss if you need the Fastest Fourier Transform in the World
c@409 96 ... ask me to add features that will bloat the code
c@409 97
c@409 98 UNDER THE HOOD:
c@409 99
c@409 100 Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. If you give it an input buffer
c@409 101 and output buffer that are the same, a temporary buffer will be created to hold the data.
c@409 102
c@409 103 No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory).
c@409 104
c@409 105 No scaling is done for the floating point version (for speed).
c@409 106 Scaling is done both ways for the fixed-point version (for overflow prevention).
c@409 107
c@409 108 Optimized butterflies are used for factors 2,3,4, and 5.
c@409 109
c@409 110 The real (i.e. not complex) optimization code only works for even length ffts. It does two half-length
c@409 111 FFTs in parallel (packed into real&imag), and then combines them via twiddling. The result is
c@409 112 nfft/2+1 complex frequency bins from DC to Nyquist. If you don't know what this means, search the web.
c@409 113
c@409 114 The fast convolution filtering uses the overlap-scrap method, slightly
c@409 115 modified to put the scrap at the tail.
c@409 116
c@409 117 LICENSE:
c@409 118 Revised BSD License, see COPYING for verbiage.
c@409 119 Basically, "free to use&change, give credit where due, no guarantees"
c@409 120 Note this license is compatible with GPL at one end of the spectrum and closed, commercial software at
c@409 121 the other end. See http://www.fsf.org/licensing/licenses
c@409 122
c@409 123 A commercial license is available which removes the requirement for attribution. Contact me for details.
c@409 124
c@409 125
c@409 126 TODO:
c@409 127 *) Add real optimization for odd length FFTs
c@409 128 *) Document/revisit the input/output fft scaling
c@409 129 *) Make doc describing the overlap (tail) scrap fast convolution filtering in kiss_fastfir.c
c@409 130 *) Test all the ./tools/ code with fixed point (kiss_fastfir.c doesn't work, maybe others)
c@409 131
c@409 132 AUTHOR:
c@409 133 Mark Borgerding
c@409 134 Mark@Borgerding.net