Mercurial > hg > dmlib
annotate src/dmfft.c @ 812:1e5cf1144f36
Move library source under src/ subdirectory.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 16 May 2014 03:22:39 +0300 |
parents | dmfft.c@95d9bd557a54 |
children | e06abfde6c39 |
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); | |
69 memset(ctx, 0, sizeof(DMFFTContext)); | |
70 } | |
71 } | |
72 | |
73 | |
74 int dmRealFFT(DMFFTContext * ctx, DMFFTType * buffer) | |
75 { | |
76 if (ctx == NULL || buffer == NULL) | |
77 return DMERR_NULLPTR; | |
78 | |
79 int rounds = ctx->npoints / 2; | |
80 DMFFTType *endptr1 = buffer + ctx->npoints * 2; | |
81 | |
82 while (rounds > 0) | |
83 { | |
84 DMFFTType *sptr = ctx->sinTable; | |
85 DMFFTType *A = buffer, | |
86 *B = buffer + rounds * 2; | |
87 | |
88 while (A < endptr1) | |
89 { | |
90 DMFFTType qsin = *sptr; | |
91 DMFFTType qcos = *(sptr + 1); | |
92 DMFFTType *endptr2 = B; | |
93 | |
94 while (A < endptr2) | |
95 { | |
96 DMFFTType v1 = (*B) * qcos + (*(B + 1)) * qsin; | |
97 DMFFTType v2 = (*B) * qsin - (*(B + 1)) * qcos; | |
98 *B = (*A + v1) * 0.5; | |
99 *(A++) = *(B++) - v1; | |
100 *B = (*A - v2) * 0.5; | |
101 *(A++) = *(B++) + v2; | |
102 } | |
103 A = B; | |
104 B += rounds * 2; | |
105 sptr += 2; | |
106 } | |
107 | |
108 rounds >>= 1; | |
109 } | |
110 | |
111 /* | |
112 * Massage output to get the output for a real input sequence. | |
113 */ | |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
114 const int *br1 = ctx->breversed + 1; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
115 const int *br2 = ctx->breversed + ctx->npoints - 1; |
749 | 116 |
117 while (br1 <= br2) | |
118 { | |
119 const DMFFTType vsin = ctx->sinTable[*br1]; | |
120 const DMFFTType vcos = ctx->sinTable[*br1 + 1]; | |
121 DMFFTType *A = buffer + *br1, | |
122 *B = buffer + *br2, | |
123 HRplus, HRminus, | |
124 HIplus, HIminus, | |
125 tmp1, tmp2; | |
126 | |
127 HRminus = *A - *B; | |
128 HRplus = HRminus + (*B * 2); | |
129 | |
130 HIminus = *(A + 1) - *(B + 1); | |
131 HIplus = HIminus + (*(B + 1) * 2); | |
132 | |
133 tmp1 = (vsin * HRminus) - (vcos * HIplus); | |
134 tmp2 = (vcos * HRminus) + (vsin * HIplus); | |
135 | |
136 *A = (HRplus + tmp1) * 0.5f; | |
137 *B = *A - tmp1; | |
138 | |
139 *(A + 1) = (HIminus + tmp2) * 0.5f; | |
140 *(B + 1) = (*(A + 1)) - HIminus; | |
141 | |
142 br1++; | |
143 br2--; | |
144 } | |
145 | |
146 // Handle DC bin separately | |
147 buffer[0] += buffer[1]; | |
148 buffer[1] = 0; | |
149 | |
150 return DMERR_OK; | |
151 } | |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
152 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
153 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
154 int dmConvertFFTtoFreqDomain(DMFFTContext *ctx, DMFFTType *buffer, |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
155 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
|
156 { |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
157 int i; |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
158 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
|
159 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
|
160 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
161 // 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
|
162 const int *breversed = ctx->breversed; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
163 |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
164 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
|
165 { |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
166 real[i] = buffer[breversed[i] ]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
167 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
|
168 } |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
169 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
170 // 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
176 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
|
177 } |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
178 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
179 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
180 #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
|
181 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
182 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
183 int dmConvertFFTtoFreqAndPower(DMFFTContext *ctx, DMFFTType *buffer, |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
184 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
|
185 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
186 int i; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
187 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
|
188 return DMERR_NULLPTR; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
189 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
190 // 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
|
191 const int *breversed = ctx->breversed; |
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 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
|
194 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
195 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
|
196 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
|
197 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
198 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
|
199 } |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
200 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
201 // Make the ends meet |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
202 real[0] = buffer[0]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
203 imag[0] = 0; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
204 power[0] = DM_PW(buffer[0], 0, scale); |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
205 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
206 real[ctx->npoints] = buffer[1]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
207 imag[ctx->npoints] = 0; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
208 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
|
209 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
210 return DMERR_OK; |
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 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
213 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
214 int dmConvertFFTtoPowerAndSum(DMFFTContext *ctx, DMFFTType *buffer, |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
215 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
|
216 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
217 int i; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
218 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
|
219 return DMERR_NULLPTR; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
220 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
221 // 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
|
222 const int *breversed = ctx->breversed; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
223 DMFFTType psum = 0; |
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 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
|
226 { |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
227 DMFFTType fre = buffer[breversed[i] ], |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
228 fim = buffer[breversed[i]+1], |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
229 fpw = sqrt(fre * fre + fim * fim); |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
230 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
231 power[i] = fpw * pscale; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
232 psum += fpw * sscale; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
233 } |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
234 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
235 // Make the ends meet |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
236 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
|
237 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
|
238 |
773
95d9bd557a54
Return the power sum variable in the FFT conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
239 *sum = psum; |
95d9bd557a54
Return the power sum variable in the FFT conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
240 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
241 return DMERR_OK; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
242 } |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
243 |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
244 |
750
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
245 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
|
246 { |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
247 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
|
248 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
|
249 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
|
250 |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
251 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
|
252 { |
772
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
253 tdom[n ] = buffer[ctx->breversed[i] ]; |
59df354b99cc
Add some utility functions in the FFT module.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
254 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
|
255 } |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
256 |
e6d807ce715b
Add two more functions for converting FFT data to frequency and time
Matti Hamalainen <ccr@tnsp.org>
parents:
749
diff
changeset
|
257 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
|
258 } |