1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Graphic Equalizer: C:/Project Marcel & Oliver/Graphic_Equalizer/src/fft.hcc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="globals.html">Globals</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">C:</a> / <a class="el" href="dir_000001.html">Project Marcel & Oliver</a> / <a class="el" href="dir_000002.html">Graphic_Equalizer</a> / <a class="el" href="dir_000004.html">src</a></div>
<h1>fft.hcc</h1><a href="fft_8hcc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001
00020 <span class="preprocessor">#include <stdlib.hch></span>
00021 <span class="preprocessor">#include "pal_master.hch"</span>
00022
00023 <span class="preprocessor">#include "<a class="code" href="audio_8hch.html">audio.hch</a>"</span>
00024 <span class="preprocessor">#include "weights_256.hch"</span>
00025 <span class="preprocessor">#include "<a class="code" href="configuration_8hch.html">configuration.hch</a>"</span>
00026 <span class="preprocessor">#include "debug.hch"</span>
00027 <span class="preprocessor">#include "xilinxmult.hch"</span>
00028
00029 <span class="comment">/* Define two multi-port RAMs for FFT calculation; one for real and one for imaginary values</span>
00030 <span class="comment"> * Extra block RAM settings are defined to make sure read and write actions can be performed</span>
00031 <span class="comment"> * within one clock-cycle.</span>
00032 <span class="comment"> * Left out extra settings on new board the clock changes TODO !!!!</span>
00033 <span class="comment"> */</span>
00034 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00035 <span class="preprocessor"></span>mpram
00036 {
00037 ram <span class="keywordtype">signed</span> 18 rwrite[256];
00038 rom <span class="keywordtype">signed</span> 18 read[256];
00039 } real with {block = <span class="stringliteral">"BlockRAM"</span><span class="comment">/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/</span>};
00040
00041 mpram
00042 {
00043 ram <span class="keywordtype">signed</span> 18 rwrite[256];
00044 rom <span class="keywordtype">signed</span> 18 read[256];
00045 } imaginary with {block = <span class="stringliteral">"BlockRAM"</span><span class="comment">/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/</span>};
00046 <span class="preprocessor">#else</span>
00047 <span class="preprocessor"></span>mpram
00048 {
00049 ram <span class="keywordtype">signed</span> 24 rwrite[256];
00050 rom <span class="keywordtype">signed</span> 24 read[256];
00051 } real with {block = <span class="stringliteral">"BlockRAM"</span><span class="comment">/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/</span>};
00052
00053 mpram
00054 {
00055 ram <span class="keywordtype">signed</span> 24 rwrite[256];
00056 rom <span class="keywordtype">signed</span> 24 read[256];
00057 } imaginary with {block = <span class="stringliteral">"BlockRAM"</span><span class="comment">/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/</span>};
00058 <span class="preprocessor">#endif</span>
00059 <span class="preprocessor"></span><span class="comment">// multiplication factors for equalizer function</span>
00060 ram <span class="keywordtype">signed</span> 7 eq_settings[16] = {0,2,4,7,10,13,16,19,22,26,30,35,41,48,55,63};
00061
00062
<a name="l00073"></a><a class="code" href="fft_8hcc.html#a1">00073</a> macro proc <a class="code" href="fft_8hcc.html#a1">multiply</a>(result, op_a, op_b)
00074 {
00075 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00076 <span class="preprocessor"></span> xilinxmult(result, op_a, adjs(op_b,18));
00077 <span class="preprocessor">#else</span>
00078 <span class="preprocessor"></span> result = (adjs(op_a,38))*(adjs(op_a,38));
00079 <span class="preprocessor">#endif </span>
00080 <span class="preprocessor"></span>}
00081
00082
00083
00084
<a name="l00095"></a><a class="code" href="fft_8hcc.html#a2">00095</a> <span class="keywordtype">void</span> <a class="code" href="fft_8hcc.html#a2">calculate_fft</a>(<span class="keywordtype">unsigned</span> 1 select_inverse)
00096 {
00097 <span class="keywordtype">unsigned</span> 4 level;
00098 <span class="keywordtype">unsigned</span> 8 point1,point2,j,f,k;
00099 <span class="keywordtype">unsigned</span> 9 e,i;
00100 <span class="keywordtype">signed</span> 16 weight1,weight2;
00101 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00102 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 18 p,q,r,t;
00103 <span class="preprocessor">#else</span>
00104 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 24 p,q,r,t;
00105 <span class="preprocessor">#endif</span>
00106 <span class="preprocessor"></span> <span class="keywordtype">signed</span> a,b;
00107
00108 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00109 <span class="preprocessor"></span> <span class="comment">// Macro to provide rescaling of 36-bit result of fixed point multiply</span>
00110 <span class="comment">// down to an 18-bit result. The range of bits selected depends on the </span>
00111 <span class="comment">// number that represents the value of "1" in the trig function lookup</span>
00112 <span class="comment">// tables. (Eg. for 16384 == 1, the lowest bit selected should be [14]).</span>
00113 macro expr rescale (x) = (x[35] @ x[30:14]);
00114 <span class="preprocessor">#else</span>
00115 <span class="preprocessor"></span> <span class="comment">//Macro to rescale the multiply result down to a 24-bit value.</span>
00116 macro expr rescale (x) = ((x>>FRACBITS)<-24);
00117 <span class="preprocessor">#endif</span>
00118 <span class="preprocessor"></span>
00119 <span class="keywordflow">for</span>(level=1;level<=NUMBER_OF_COLUMNS;level++) <span class="comment">// count all the columns</span>
00120 {
00121 e=1<<(NUMBER_OF_COLUMNS-level+1); <span class="comment">// number of points in each block in this column</span>
00122 f=(e>>1)<-8; <span class="comment">// number of butterflies in each block in this column</span>
00123
00124 <span class="keywordflow">for</span>(j=1;j<=f;j++) <span class="comment">// count all the butterflies in each block</span>
00125 {
00126 par
00127 {
00128 <span class="comment">// Weight factors for real (the same for FFT and iFFT)</span>
00129 weight1 = weight_re[((j-1)<<(level-1))<-7];
00130
00131
00132 <span class="comment">// Weight factors for imaginary (opposite for FFT and iFFT)</span>
00133 weight2 = (!select_inverse) ? (weight_im[((j-1)<<(level-1))<-7]) : -(weight_im[((j-1)<<(level-1))<-7]);
00134
00135 <span class="comment">/* ORIGINAL CODE BELOW, MODIFIED BECAUSE OF MISMATCHING OUTPUT WITH BORLAND TESTAPP</span>
00136 <span class="comment"> weight2 = (!select_inverse) ? -(weight_im[((j-1)<<(level-1))<-7]) : weight_im[((j-1)<<(level-1))<-7]; </span>
00137 <span class="comment"> */</span>
00138
00139
00140
00141 <span class="keywordflow">for</span>(i=0@j;i<=NUMBER_OF_POINTS;i+=e) <span class="comment">// count all the blocks in this column</span>
00142 { <span class="comment">// Butterfly calculation</span>
00143 par
00144 {
00145 point1 = ((i<-8)-1);
00146 point2 = (((i<-8)+f)-1);
00147 }
00148
00149 par
00150 {
00151 p = (real.read[point1] >> 1) + (real.rwrite[point2] >> 1);
00152 q = (imaginary.read[point1] >> 1) + (imaginary.rwrite[point2] >> 1);
00153 }
00154
00155 par
00156 {
00157 r = (real.read[point1] >> 1) - (real.rwrite[point2] >> 1);
00158 t = (imaginary.read[point1] >> 1) - (imaginary.rwrite[point2] >> 1);
00159 }
00160
00161 <a class="code" href="fft_8hcc.html#a1">multiply</a>(a,r,weight1);
00162 <a class="code" href="fft_8hcc.html#a1">multiply</a>(b,t,weight2);
00163
00164 par
00165 {
00166 real.rwrite[point2] = (rescale(a-b));
00167 imaginary.rwrite[point1] = q;
00168 }
00169
00170 <a class="code" href="fft_8hcc.html#a1">multiply</a>(a,t,weight1);
00171 <a class="code" href="fft_8hcc.html#a1">multiply</a>(b,r,weight2);
00172
00173 par
00174 {
00175 real.rwrite[point1] = p;
00176 imaginary.rwrite[point2] = (rescale(a+b));
00177 }
00178
00179 }
00180 }
00181 }
00182 }
00183
00184 j=1;
00185 <span class="keywordflow">for</span>(i=1;i<NUMBER_OF_POINTS;i++)
00186 {
00187 <span class="keywordflow">if</span>(i<(0@j))
00188 {
00189 par
00190 {
00191 point1=j-1;
00192 point2=(i-1)<-8;
00193 }
00194 <span class="comment">/*</span>
00195 <span class="comment"> COPYING ARRAY VALUES FROM ONE PLACE TO ANOTHER IN THE ARRAT MUST BE DONE IN </span>
00196 <span class="comment"> 2 STEPS. FIRSTLY THE VALUES ARE COPIED TO SEPARATE VARIABLES AFTER THAT THEY</span>
00197 <span class="comment"> ARE COPIED BACK TO THEIR NEW POSITION IN THE ARRAY. THIS MUST BE DONE TO </span>
00198 <span class="comment"> PREVENT TIMING ISSUES FROM OCCURING.</span>
00199 <span class="comment"> */</span>
00200 par
00201 {
00202 p = real.read[point1];
00203 q = imaginary.read[point1];
00204 }
00205 par
00206 {
00207 r = real.read[point2];
00208 t = imaginary.read[point2];
00209 }
00210 par
00211 {
00212 real.rwrite[point1] = r;
00213 imaginary.rwrite[point1] = t;
00214 }
00215 par
00216 {
00217 real.rwrite[point2] = p;
00218 imaginary.rwrite[point2] = q;
00219 }
00220 }
00221
00222 k = NUMBER_OF_POINTS>>1;
00223
00224
00225 <span class="keywordflow">while</span>(k<j)
00226 {
00227 j = j-k;
00228 k = k>>1;
00229 }
00230
00231 j+=k;
00232 }
00233
00234 }
00235
00247 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00248 <span class="preprocessor"></span><span class="keywordtype">void</span> perform_fft(<span class="keywordtype">signed</span> 18 *pcm_audio)
00249 #<span class="keywordflow">else</span>
00250 <span class="keywordtype">void</span> perform_fft(<span class="keywordtype">signed</span> 16 *pcm_audio)
00251 #endif
00252 {
00253 <span class="keywordtype">unsigned</span> 8 k;
00254 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00255 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 18 sample;
00256 k=0;
00257 sample = adjs(pcm_audio[k],18);
00258 <span class="preprocessor">#else</span>
00259 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 24 sample;
00260 k=0;
00261 sample = adjs(pcm_audio[k],24);
00262 <span class="preprocessor">#endif</span>
00263 <span class="preprocessor"></span>
00264 <span class="comment">//initialize variables for the copying pipeline</span>
00265
00266
00267 <span class="comment">// copy audio data to real-array before starting FFT calculation</span>
00268 <span class="comment">// and set imaginary values to zero</span>
00269 <span class="keywordflow">do</span>
00270 {
00271 <span class="comment">//Copying the array values has been pipelined to prevent parallel access to the</span>
00272 <span class="comment">//pcm_audio array. This copying procedure must be finished before another </span>
00273 <span class="comment">//sample is read from the audio input. The time available for this loop is </span>
00274 <span class="comment">//determined by the sampling rate of 44,1 Khz</span>
00275 par
00276 {
00277 <span class="comment">//COPYING NEEDS TO BE DONE IN 2 STEPS, BECAUSE THE VALUE THAT NEEDS TO WRITTEN</span>
00278 <span class="comment">//TO THE REAL-RAM NEEDS TO BE AVAILABLE ON THE START OFF THE CLOCKCYCLE.</span>
00279 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00280 <span class="preprocessor"></span> sample = adjs(pcm_audio[k+1],18);
00281 <span class="preprocessor">#else</span>
00282 <span class="preprocessor"></span> sample = adjs(pcm_audio[k+1],24);
00283 <span class="preprocessor">#endif</span>
00284 <span class="preprocessor"></span> real.rwrite[k] = sample;
00285 imaginary.rwrite[k] = 0;
00286 k++;
00287 }
00288 } <span class="keywordflow">while</span> (k);
00289
00290
00291
00292 <span class="preprocessor">#if PERFORM_FFT_CALCULATION</span>
00293 <span class="preprocessor"></span> <a class="code" href="fft_8hcc.html#a2">calculate_fft</a>(0);
00294 <span class="preprocessor">#endif</span>
00295 <span class="preprocessor"></span>
00296
00297 }
00298
00312 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00313 <span class="preprocessor"></span><span class="keywordtype">void</span> perform_ifft(<span class="keywordtype">signed</span> 18 *modified_audio, <span class="keywordtype">unsigned</span> 6 *ifft_info)
00314 #<span class="keywordflow">else</span>
00315 <span class="keywordtype">void</span> perform_ifft(<span class="keywordtype">signed</span> 16 *modified_audio, <span class="keywordtype">unsigned</span> 6 *ifft_info)
00316 #endif
00317 {
00318 <span class="keywordtype">unsigned</span> 6 k;
00319 <span class="preprocessor">#if HARDWARE_MULTIPLY </span>
00320 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 18 p;
00321 <span class="preprocessor">#else</span>
00322 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 24 p;
00323 <span class="preprocessor">#endif</span>
00324 <span class="preprocessor"></span><span class="preprocessor">#if PERFORM_FFT_CALCULATION </span>
00325 <span class="preprocessor"></span> <a class="code" href="fft_8hcc.html#a2">calculate_fft</a>(1);
00326 <span class="preprocessor">#endif</span>
00327 <span class="preprocessor"></span>
00328 k=0;
00329 <span class="comment">//initialize variables for the copying pipeline</span>
00330 <span class="preprocessor">#if PERFORM_FFT_CALCULATION </span>
00331 <span class="preprocessor"></span><span class="preprocessor"> #if HARDWARE_MULTIPLY </span>
00332 <span class="preprocessor"></span> p = (real.read[(0@k)+95] << NUMBER_OF_COLUMNS);
00333 <span class="preprocessor"> #else</span>
00334 <span class="preprocessor"></span> p = (real.read[(0@k)+95] >> NUMBER_OF_COLUMNS);
00335 <span class="preprocessor"> #endif</span>
00336 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00337 <span class="preprocessor"></span> p = (real.read[(0@k)+95]);
00338 <span class="preprocessor">#endif</span>
00339 <span class="preprocessor"></span>
00340 <span class="keywordflow">do</span>
00341 {
00342 <span class="comment">//Copying the array values has been pipelined to prevent parallel access to the</span>
00343 <span class="comment">//pcm_audio array. This copying procedure must be finished before another </span>
00344 <span class="comment">//sample is read from the audio input. The time available for this loop is </span>
00345 <span class="comment">//determined by the sampling rate of 44,1 Khz</span>
00346 par
00347 {
00348 <span class="comment">/*</span>
00349 <span class="comment"> * Before copying the modified audio from the local real-array </span>
00350 <span class="comment"> * to the output array of the audio I/O component, compensate</span>
00351 <span class="comment"> * for the FFT calculation by shifting the values. </span>
00352 <span class="comment"> * 95 is added to start the output from the middle of the sliding</span>
00353 <span class="comment"> * window, this is done to get a better sound quality.</span>
00354 <span class="comment"> */</span>
00355 <span class="preprocessor">#if PERFORM_FFT_CALCULATION </span>
00356 <span class="preprocessor"></span><span class="preprocessor"> #if HARDWARE_MULTIPLY </span>
00357 <span class="preprocessor"></span> p = (real.read[(0@k)+95] << NUMBER_OF_COLUMNS);
00358 <span class="preprocessor"> #else</span>
00359 <span class="preprocessor"></span> p = (real.read[(0@k)+95] >> NUMBER_OF_COLUMNS);
00360 <span class="preprocessor"> #endif</span>
00361 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00362 <span class="preprocessor"></span> p = (real.read[(0@k)+95]);
00363 <span class="preprocessor">#endif</span>
00364 <span class="preprocessor"></span> <span class="comment">//Copy the modified audio from the local real array to the output array of the audio I/O component.</span>
00365 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00366 <span class="preprocessor"></span> modified_audio[k] = p ;
00367 <span class="preprocessor">#else</span>
00368 <span class="preprocessor"></span> modified_audio[k] = (p<-16);
00369 <span class="preprocessor">#endif</span>
00370 <span class="preprocessor"></span> <span class="comment">//Fill the array for displaying the waveform, only the 6 MSB are needed.</span>
00371 ifft_info[k] = (<span class="keywordtype">unsigned</span> 6)(32+(p[17:12]));
00372 k++;
00373 }
00374 } <span class="keywordflow">while</span>(k);
00375 }
00376
<a name="l00389"></a><a class="code" href="fft_8hcc.html#a5">00389</a> <span class="keywordtype">void</span> <a class="code" href="fft_8hcc.html#a5">equalize_audio</a>(audiodata_t *audiodata)
00390 {
00391 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00392 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 18 p,q;
00393 <span class="preprocessor">#else</span>
00394 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 24 p,q;
00395 <span class="preprocessor">#endif</span>
00396 <span class="preprocessor"></span> <span class="keywordtype">signed</span> 18 a;
00397 <span class="keywordtype">unsigned</span> 8 i, mirror_i, bit, m, n;
00398 <span class="keywordtype">unsigned</span> 7 old_value;
00399 <span class="keywordtype">unsigned</span> 9 tmp;
00400
00401 <span class="comment">//macro expr equalize_bar = multiply(q,a)[29:6];</span>
00402
00403 macro proc equalize_bar(retval)
00404 {
00405 <span class="keywordtype">signed</span> result;
00406 <a class="code" href="fft_8hcc.html#a1">multiply</a>(result, q,a);
00407 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00408 <span class="preprocessor"></span> retval = result[23:6]; <span class="comment">//drop last 6 bit to compensate the maximum multiplication with 64 from the eq_settings array</span>
00409 <span class="preprocessor">#else</span>
00410 <span class="preprocessor"></span> retval = result[29:6]; <span class="comment">//drop last 6 bit to compensate the maximum multiplication with 64 from the eq_settings array</span>
00411 <span class="preprocessor">#endif</span>
00412 <span class="preprocessor"></span> }
00413
00414 p = real.read[0] - DC_COMPONENT; <span class="comment">// remove DC component for calculations</span>
00415 real.rwrite[0] = p;
00416
00417 <span class="keywordflow">for</span>(i=0;i!=NUMBER_OF_FREQUENCIES;i++)
00418 {
00419
00420 <span class="comment">// set multiplication factor (0..64) for current frequency bar, The first frequency band must be equalized at 100% (63) since there is no DC-component taken into account.</span>
00421 a = adjs(eq_settings[audiodata->equalizer_levels_ptr[i <- 7]],18);
00422
00423
00424 <span class="comment">// multiply frequency with this factor and divide by 64 (drop 6 LSB's)</span>
00425 q = real.read[i];
00426 equalize_bar(p);
00427 real.rwrite[i] = p;
00428
00429 q = imaginary.read[i];
00430 equalize_bar(p);
00431 imaginary.rwrite[i] = p;
00432
00433 <span class="comment">// the upper part(128..255) of the spectrum is mirrored to the lower part; </span>
00434 <span class="comment">// these values need to be adjusted too</span>
00435 <span class="keywordflow">if</span> ((i<-7)!=0) <span class="comment">// if not in DC component bar</span>
00436 {
00437 mirror_i = (NUMBER_OF_POINTS-1)-i+1;
00438 q = real.read[mirror_i];
00439 equalize_bar(p);
00440 real.rwrite[mirror_i] = p;
00441
00442 q = imaginary.read[mirror_i];
00443 equalize_bar(p);
00444 imaginary.rwrite[mirror_i] = p;
00445 }
00446 }
00447
00448 <span class="comment">//write data to fft_info for display purposes</span>
00449 <span class="keywordflow">for</span>(i=0;i<NUMBER_OF_FREQUENCIES;i++)
00450 {
00451 p = real.read[i];
00452 q = imaginary.read[i];
00453 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00454 <span class="preprocessor"></span> <span class="keywordflow">if</span> (p[17] == 1) p = -p; <span class="keywordflow">else</span> delay;
00455 <span class="keywordflow">if</span> (q[17] == 1) q = -q; <span class="keywordflow">else</span> delay;
00456 <span class="preprocessor">#else</span>
00457 <span class="preprocessor"></span> <span class="keywordflow">if</span> (p[23] == 1) p = -p; <span class="keywordflow">else</span> delay;
00458 <span class="keywordflow">if</span> (q[23] == 1) q = -q; <span class="keywordflow">else</span> delay;
00459 <span class="preprocessor">#endif</span>
00460 <span class="preprocessor"></span> p = (p<q) ? q : p; <span class="comment">// This is done to get the best visual frequency result</span>
00461
00462 <span class="keywordflow">if</span> (!audiodata->display_log)
00463 {
00464
00465 bit=126;
00466 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00467 <span class="preprocessor"></span> <span class="keywordflow">while</span> ((p[15] == 0) && (bit != 0))
00468 <span class="preprocessor">#else</span>
00469 <span class="preprocessor"></span> <span class="keywordflow">while</span> ((p[21] == 0) && (bit != 0))
00470 <span class="preprocessor">#endif</span>
00471 <span class="preprocessor"></span> par
00472 {
00473 p = p<<1;
00474 bit = bit - 18;
00475 }
00476 old_value = audiodata->fft_info.write[0 @ (i <- 7)];
00477 tmp = ((0@old_value) + (0@bit))>>1;
00478 audiodata->fft_info.write[0 @ (i <- 7)] = (old_value <= (tmp<-7)) ? (tmp<-7) : old_value-1;
00479 }
00480 <span class="keywordflow">else</span>
00481 {
00482 old_value = audiodata->fft_info.write[0 @ (i <- 7)];
00483 <span class="preprocessor">#if HARDWARE_MULTIPLY</span>
00484 <span class="preprocessor"></span> audiodata->fft_info.write[0 @ (i <- 7)] = (old_value<=(unsigned)(p[15:9])) ? (unsigned)(p[15:9]) : old_value-1;
00485 <span class="preprocessor">#else</span>
00486 <span class="preprocessor"></span> audiodata->fft_info.write[0 @ (i <- 7)] = (old_value<=(unsigned)(p[21:15])) ? (unsigned)(p[21:15]) : old_value-1;
00487 <span class="preprocessor">#endif</span>
00488 <span class="preprocessor"></span> }
00489 }
00490
00491 <span class="comment">// add DC component again before inverse FFT calculation is performed</span>
00492
00493 p = real.read[0] + DC_COMPONENT;
00494 real.rwrite[0] = p;
00495 }
00496
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Nov 29 12:04:47 2004 for Graphic Equalizer by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
</body>
</html>
|