FastLED 3.9.15
Loading...
Searching...
No Matches

◆ kiss_fftr()

void kiss_fftr ( kiss_fftr_cfg st,
const kiss_fft_scalar * timedata,
kiss_fft_cpx * freqdata )

Definition at line 82 of file kiss_fftr.cpp.hpp.

83{
84 /* input buffer timedata is stored row-wise */
85 int k,ncfft;
86 kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc;
87
88 if ( st->substate->inverse) {
89 //fprintf(stderr,"kiss fft usage error: improper alloc\n");
90 FL_WARN("kiss fft usage error: improper alloc");
91 fl::exit(1);
92 }
93
94 ncfft = st->substate->nfft;
95
96 /*perform the parallel fft of two real signals packed in real,imag*/
97 kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf );
98 /* The real part of the DC element of the frequency spectrum in st->tmpbuf
99 * contains the sum of the even-numbered elements of the input time sequence
100 * The imag part is the sum of the odd-numbered elements
101 *
102 * The sum of tdc.r and tdc.i is the sum of the input time sequence.
103 * yielding DC of input time sequence
104 * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1...
105 * yielding Nyquist bin of input time sequence
106 */
107
108 tdc.r = st->tmpbuf[0].r;
109 tdc.i = st->tmpbuf[0].i;
110 C_FIXDIV(tdc,2);
111 CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i);
112 CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i);
113 freqdata[0].r = tdc.r + tdc.i;
114 freqdata[ncfft].r = tdc.r - tdc.i;
115#ifdef USE_SIMD
116 freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0);
117#else
118 freqdata[ncfft].i = freqdata[0].i = 0;
119#endif
120
121 for ( k=1;k <= ncfft/2 ; ++k ) {
122 fpk = st->tmpbuf[k];
123 fpnk.r = st->tmpbuf[ncfft-k].r;
124 fpnk.i = - st->tmpbuf[ncfft-k].i;
125 C_FIXDIV(fpk,2);
126 C_FIXDIV(fpnk,2);
127
128 C_ADD( f1k, fpk , fpnk );
129 C_SUB( f2k, fpk , fpnk );
130 C_MUL( tw , f2k , st->super_twiddles[k-1]);
131
132 freqdata[k].r = HALF_OF(f1k.r + tw.r);
133 freqdata[k].i = HALF_OF(f1k.i + tw.i);
134 freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r);
135 freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i);
136 }
137}
#define C_FIXDIV(c, div)
#define HALF_OF(x)
#define C_ADD(res, a, b)
#define CHECK_OVERFLOW_OP(a, op, b)
#define C_SUB(res, a, b)
#define C_MUL(m, a, b)
void kiss_fft(kiss_fft_cfg cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) FL_NOEXCEPT
kiss_fft_scalar r
Definition kiss_fft.h:85
kiss_fft_scalar i
Definition kiss_fft.h:86
kiss_fft_cfg substate
kiss_fft_cpx * tmpbuf
kiss_fft_cpx * super_twiddles
#define FL_WARN(X)
Definition log.h:276
void exit(int code)
No-op exit function for embedded systems In embedded environments, calling exit is typically not mean...
Definition exit.h:8

References C_ADD, C_FIXDIV, C_MUL, C_SUB, CHECK_OVERFLOW_OP, fl::exit(), FL_NOEXCEPT, FL_WARN, HALF_OF, kiss_fft_cpx::i, kiss_fft(), kiss_fft_scalar, and kiss_fft_cpx::r.

Referenced by _generate_kernel(), and fl::audio::fft::fl_fft_real_forward().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: