Mercurial > hg > dmlib
annotate src/dmfft.c @ 1264:aa6e8a24b94b
Oops, when did I break this? IFF ILBM reader should now work again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 25 May 2015 12:58:02 +0300 |
parents | f077a709d491 |
children | e68f7b0cb536 |
rev | line source |
---|---|
749 | 1 /* |
2 * Realfftf | |
3 * Originally (C) Copyright 1993 Philib Van Baren | |
4 * Cleaned up and refactored to be re-entrant by | |
5 * Matti 'ccr' Hamalainen <ccr@tnsp.org>, 2013 | |
6 * | |
7 * Note: Output is BIT-REVERSED! so you must use the BitReversed to | |
8 * get legible output, (i.e. Real_i = buffer[ BitReversed[i] ] | |
9 * Imag_i = buffer[ BitReversed[i]+1 ] ) | |
10 * Input is in normal order. | |
11 */ | |
12 #include "dmfft.h" | |
13 #include <math.h> | |
14 | |
15 | |
16 int dmInitializeFFT(DMFFTContext * ctx, const int fftlen) | |
17 { | |
18 int i; | |
19 | |
20 if (ctx == NULL) | |
21 return DMERR_NULLPTR; | |
22 | |
23 if (fftlen <= 16) | |
24 return DMERR_INVALID_ARGS; | |
25 | |
26 // Allocate necessary tables | |
27 ctx->npoints = fftlen / 2; | |
28 ctx->sinTable = (DMFFTType *) dmMalloc(fftlen * sizeof(DMFFTType)); | |
29 if (ctx->sinTable == NULL) | |
30 return DMERR_MALLOC; | |
31 | |
32 // Bitreversion buffer | |
33 ctx->breversed = (int *) dmMalloc(ctx->npoints * sizeof(int)); | |
34 if (ctx->breversed == NULL) | |
35 { | |
36 dmFree(ctx->sinTable); | |
37 return DMERR_MALLOC; | |
38 } | |
39 | |
40 // Calculate data | |
41 for (i = 0; i < ctx->npoints; i++) | |
42 { | |
43 int mask, tmp; | |
44 for (tmp = 0, mask = ctx->npoints / 2; mask > 0; mask >>= 1) | |
45 { | |
46 tmp = (tmp >> 1) + ((i & mask) ? ctx->npoints : 0); | |
47 } | |
48 | |
49 ctx->breversed[i] = tmp; | |
50 } | |
51 | |
52 for (i = 0; i < ctx->npoints; i++) | |
53 { | |
751 | 54 ctx->sinTable[ctx->breversed[i]] = -sin((2.0f * DM_PI * i) / fftlen); |
749 | 55 ctx->sinTable[ctx->breversed[i] + 1] = |
751 | 56 -cos((2.0f * DM_PI * i) / fftlen); |
749 | 57 } |
58 | |
59 return DMERR_OK; | |
60 } | |
61 | |
62 | |
63 void dmEndFFT(DMFFTContext * ctx) | |
64 { | |
65 if (ctx != NULL) | |
66 { | |
67 dmFree(ctx->breversed); | |
68 dmFree(ctx->sinTable); | |
1167 | 69 dmMemset(ctx, 0, sizeof(DMFFTContext)); |
749 | 70 } |
71 } | |
72 | |
73 | |
74 int dmRealFFT(DMFFTContext * ctx, DMFFTType * buffer) | |
75 { | |
76 if (ctx == NULL || buffer == NULL) | |
77 return DMERR_NULLPTR; | |
78 | |
1252 | 79 const int *br1 = ctx->breversed + 1; |
80 const int *br2 = ctx->breversed + ctx->npoints - 1; | |
749 | 81 int rounds = ctx->npoints / 2; |
82 DMFFTType *endptr1 = buffer + ctx->npoints * 2; | |
83 | |
84 while (rounds > 0) | |
85 { | |
86 DMFFTType *sptr = ctx->sinTable; | |
87 DMFFTType *A = buffer, | |
88 *B = buffer + rounds * 2; | |
89 | |
90 while (A < endptr1) | |
91 { | |
92 DMFFTType qsin = *sptr; | |
93 DMFFTType qcos = *(sptr + 1); | |
94 DMFFTType *endptr2 = B; | |
95 | |
96 while (A < endptr2) | |
97 { | |
98 DMFFTType v1 = (*B) * qcos + (*(B + 1)) * qsin; | |
99 DMFFTType v2 = (*B) * qsin - (*(B + 1)) * qcos; | |
100 *B = (*A + v1) * 0.5; | |
101 *(A++) = *(B++) - v1; | |
102 *B = (*A - v2) * 0.5; | |
103 *(A++) = *(B++) + v2; | |
104 } | |
105 A = B; | |
106 B += rounds * 2; | |
107 sptr += 2; | |
108 } | |
109 | |
110 rounds >>= 1; | |
111 } | |
112 | |
1252 | 113 // Massage output to get the output for a real input sequence. |
749 | 114 |
115 while (br1 <= br2) | |
116 { | |
117 const DMFFTType vsin = ctx->sinTable[*br1]; | |
118 const DMFFTType vcos = ctx->sinTable[*br1 + 1]; | |
119 DMFFTType *A = buffer + *br1, | |
120 *B = buffer + *br2, | |
121 HRplus, HRminus, | |
122 HIplus, HIminus, | |
123 tmp1, tmp2; | |
124 | |
125 HRminus = *A - *B; | |
126 HRplus = HRminus + (*B * 2); | |
127 | |
128 HIminus = *(A + 1) - *(B + 1); | |
129 HIplus = HIminus + (*(B + 1) * 2); | |
130 | |
131 tmp1 = (vsin * HRminus) - (vcos * HIplus); | |
132 tmp2 = (vcos * HRminus) + (vsin * HIplus); | |
133 | |
134 *A = (HRplus + tmp1) * 0.5f; | |
135 *B = *A - tmp1; | |
136 | |
137 *(A + 1) = (HIminus + tmp2) * 0.5f; | |
138 *(B + 1) = (*(A + 1)) - HIminus; | |
139 | |
140 br1++; | |
141 br2--; | |
142 } | |
143 | |
144 // Handle DC bin separately | |
145 buffer[0] += buffer[1]; | |
146 buffer[1] = 0; | |
147 | |
148 return DMERR_OK; | |
149 } | |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
150 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
151 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
152 int dmConvertFFTtoFreqDomain(DMFFTContext *ctx, DMFFTType *buffer, |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
153 DMFFTType *real, DMFFTType *imag) |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
154 { |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
155 int i; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
156 if (ctx == NULL || buffer == NULL || real == NULL || imag == NULL) |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
157 return DMERR_NULLPTR; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
158 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
159 // Convert from bitreversed form to normal frequency domain |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
160 const int *breversed = ctx->breversed; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
161 |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
162 for (i = 1; i < ctx->npoints; i++) |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
163 { |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
164 real[i] = buffer[breversed[i] ]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
165 imag[i] = buffer[breversed[i]+1]; |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
166 } |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
167 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
168 // Make the ends meet |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
169 real[0] = buffer[0]; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
170 imag[0] = 0; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
171 real[ctx->npoints] = buffer[1]; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
172 imag[ctx->npoints] = 0; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
173 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
174 return DMERR_OK; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
175 } |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
176 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
177 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
178 #define DM_PW(a, b, c) sqrt(a * a + b * b) * c |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
179 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
180 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
181 int dmConvertFFTtoFreqAndPower(DMFFTContext *ctx, DMFFTType *buffer, |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
182 DMFFTType *real, DMFFTType *imag, DMFFTType *power, const DMFFTType scale) |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
183 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
184 int i; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
185 if (ctx == NULL || buffer == NULL || real == NULL || imag == NULL || power == NULL) |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
186 return DMERR_NULLPTR; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
187 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
188 // Convert from bitreversed form to normal frequency domain |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
189 const int *breversed = ctx->breversed; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
190 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
191 for (i = 1; i < ctx->npoints; i++) |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
192 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
193 DMFFTType fre = real[i] = buffer[breversed[i] ], |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
194 fim = imag[i] = buffer[breversed[i]+1]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
195 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
196 power[i] = DM_PW(fre, fim, scale); |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
197 } |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
198 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
199 // Make the ends meet |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
200 real[0] = buffer[0]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
201 imag[0] = 0; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
202 power[0] = DM_PW(buffer[0], 0, scale); |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
203 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
204 real[ctx->npoints] = buffer[1]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
205 imag[ctx->npoints] = 0; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
206 power[ctx->npoints] = DM_PW(buffer[1], 0, scale); |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
207 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
208 return DMERR_OK; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
209 } |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
210 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
211 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
212 int dmConvertFFTtoPowerAndSum(DMFFTContext *ctx, DMFFTType *buffer, |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
213 DMFFTType *power, const DMFFTType pscale, DMFFTType *sum, const DMFFTType sscale) |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
214 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
215 int i; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
216 if (ctx == NULL || buffer == NULL || power == NULL || sum == NULL) |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
217 return DMERR_NULLPTR; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
218 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
219 // Convert from bitreversed form to normal frequency domain |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
220 const int *breversed = ctx->breversed; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
221 DMFFTType psum = 0; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
222 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
223 for (i = 1; i < ctx->npoints; i++) |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
224 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
225 DMFFTType fre = buffer[breversed[i] ], |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
226 fim = buffer[breversed[i]+1], |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
227 fpw = sqrt(fre * fre + fim * fim); |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
228 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
229 power[i] = fpw * pscale; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
230 psum += fpw * sscale; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
231 } |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
232 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
233 // Make the ends meet |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
234 power[0] = DM_PW(buffer[0], 0, pscale); |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
235 power[ctx->npoints] = DM_PW(buffer[1], 0, pscale); |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
236 |
773
95d9bd557a54
Return the power sum variable in the FFT conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
237 *sum = psum; |
95d9bd557a54
Return the power sum variable in the FFT conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
238 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
239 return DMERR_OK; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
240 } |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
241 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
242 |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
243 int dmConvertFFTtoTimeDomain(DMFFTContext *ctx, DMFFTType *buffer, DMFFTType *tdom) |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
244 { |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
245 int i, n; |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
246 if (ctx == NULL || buffer == NULL || tdom == NULL) |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
247 return DMERR_NULLPTR; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
248 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
249 for (n = i = 0; i < ctx->npoints; i++, n += 2) |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
250 { |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
251 tdom[n ] = buffer[ctx->breversed[i] ]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
252 tdom[n+1] = buffer[ctx->breversed[i]+1]; |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
253 } |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
254 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
255 return DMERR_OK; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
256 } |