From 9a26c7d0cc5b69d8a7e0e0dc93a1b43c909a4268 Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Wed, 19 Feb 2025 20:53:02 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20doxygen=20from=20@=20pschatzma?= =?UTF-8?q?nn/arduino-audio-tools@d28bb081e26bee6c6354424ec80c762f2bd40236?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _audio_cmsis_f_f_t_8h_source.html | 2 +- _audio_e_s_p32_f_f_t_8h_source.html | 2 +- _audio_espressif_f_f_t_8h_source.html | 2 +- _audio_f_f_t_8h_source.html | 702 +- _audio_kiss_f_f_t_8h_source.html | 2 +- _audio_real_f_f_t_8h_source.html | 4 +- _f_f_t_display_8h_source.html | 6 +- _f_f_t_real_8h_source.html | 6922 +++++++++-------- ...__tools_1_1_audio_cmsis_f_f_t-members.html | 29 +- classaudio__tools_1_1_audio_cmsis_f_f_t.html | 3 + ...tools_1_1_audio_e_s_p32_f_f_t-members.html | 29 +- ...saudio__tools_1_1_audio_e_s_p32_f_f_t.html | 3 + ...ols_1_1_audio_espressif_f_f_t-members.html | 29 +- ...udio__tools_1_1_audio_espressif_f_f_t.html | 3 + ...o__tools_1_1_audio_f_f_t_base-members.html | 29 +- classaudio__tools_1_1_audio_f_f_t_base.html | 3 + ...o__tools_1_1_audio_kiss_f_f_t-members.html | 29 +- classaudio__tools_1_1_audio_kiss_f_f_t.html | 3 + ...o__tools_1_1_audio_real_f_f_t-members.html | 29 +- classaudio__tools_1_1_audio_real_f_f_t.html | 3 + 20 files changed, 3946 insertions(+), 3888 deletions(-) diff --git a/_audio_cmsis_f_f_t_8h_source.html b/_audio_cmsis_f_f_t_8h_source.html index e046f68b1..a9df42b6f 100644 --- a/_audio_cmsis_f_f_t_8h_source.html +++ b/_audio_cmsis_f_f_t_8h_source.html @@ -222,7 +222,7 @@
AudioFFT for ARM processors that provided Cmsis DSP.
Definition AudioCmsisFFT.h:112
float * array()
Provides the result array returned by CMSIS FFT.
Definition AudioCmsisFFT.h:117
Executes FFT using audio data privded by write() and/or an inverse FFT where the samples are made ava...
Definition AudioFFT.h:179
-
FFTDriver * driver()
Definition AudioFFT.h:369
+
FFTDriver * driver()
Definition AudioFFT.h:370
Driver for Cmsis-FFT see https://arm-software.github.io/CMSIS_5/DSP.
Definition AudioCmsisFFT.h:23
float magnitudeFast(int idx) override
same as magnitude
Definition AudioCmsisFFT.h:72
void setValue(int idx, float value) override
Sets the real value.
Definition AudioCmsisFFT.h:50
diff --git a/_audio_e_s_p32_f_f_t_8h_source.html b/_audio_e_s_p32_f_f_t_8h_source.html index 9a38e1212..a7b76a55d 100644 --- a/_audio_e_s_p32_f_f_t_8h_source.html +++ b/_audio_e_s_p32_f_f_t_8h_source.html @@ -180,7 +180,7 @@
AudioFFT using RealFFT.
Definition AudioESP32FFT.h:84
float * array()
Provides the result array returned by the FFT: The real part of a magnitude at a frequency is followe...
Definition AudioESP32FFT.h:89
Executes FFT using audio data privded by write() and/or an inverse FFT where the samples are made ava...
Definition AudioFFT.h:179
-
FFTDriver * driver()
Definition AudioFFT.h:369
+
FFTDriver * driver()
Definition AudioFFT.h:370
Driver for ESP32-FFT https://github.com/pschatzmann/esp32-fft
Definition AudioESP32FFT.h:21
float magnitudeFast(int idx) override
magnitude w/o sqrt
Definition AudioESP32FFT.h:49
float getValue(int idx)
Get result value from Reverse FFT.
Definition AudioESP32FFT.h:53
diff --git a/_audio_espressif_f_f_t_8h_source.html b/_audio_espressif_f_f_t_8h_source.html index 949292f38..2384fe0c9 100644 --- a/_audio_espressif_f_f_t_8h_source.html +++ b/_audio_espressif_f_f_t_8h_source.html @@ -238,7 +238,7 @@
AudioFFT using FFTReal. The only specific functionality is the access to the dataArray.
Definition AudioEspressifFFT.h:139
float * dataArray()
Provides the complex array returned by the FFT
Definition AudioEspressifFFT.h:144
Executes FFT using audio data privded by write() and/or an inverse FFT where the samples are made ava...
Definition AudioFFT.h:179
-
FFTDriver * driver()
Definition AudioFFT.h:369
+
FFTDriver * driver()
Definition AudioFFT.h:370
fft Driver for espressif dsp library: https://espressif-docs.readthedocs-hosted.com/projects/esp-dsp/...
Definition AudioEspressifFFT.h:20
float magnitudeFast(int idx) override
magnitude w/o sqrt
Definition AudioEspressifFFT.h:105
void setValue(int idx, float value) override
Sets the real value.
Definition AudioEspressifFFT.h:46
diff --git a/_audio_f_f_t_8h_source.html b/_audio_f_f_t_8h_source.html index 02fc4dbd7..9ef6eb174 100644 --- a/_audio_f_f_t_8h_source.html +++ b/_audio_f_f_t_8h_source.html @@ -311,366 +311,368 @@
259 l_magnitudes.resize(0);
260 rfft_data.resize(0);
261 rfft_add.resize(0);
-
262 }
- -
263
-
-
265 size_t write(const uint8_t *data, size_t len) override {
-
266 size_t result = 0;
-
267 if (p_driver->isValid()) {
-
268 result = len;
-
269 switch (cfg.bits_per_sample) {
-
270 case 8:
-
271 processSamples<int8_t>(data, len);
-
272 break;
-
273 case 16:
-
274 processSamples<int16_t>(data, len / 2);
-
275 break;
-
276 case 24:
-
277 processSamples<int24_t>(data, len / 3);
-
278 break;
-
279 case 32:
-
280 processSamples<int32_t>(data, len / 4);
-
281 break;
-
282 default:
-
283 LOGE("Unsupported bits_per_sample: %d", cfg.bits_per_sample);
-
284 break;
-
285 }
-
286 }
-
287 return result;
-
288 }
-
-
289
-
-
291 size_t readBytes(uint8_t *data, size_t len) override {
-
292 LOGD("setup ifft data");
-
293 if (rfft_data.size() == 0) return 0;
-
294 // execute rfft when we consumed all data
-
295 if (has_rfft_data && rfft_data.available() == 0) {
-
296 rfft();
-
297 }
-
298 return rfft_data.readArray(data, len);
-
299 }
-
-
300
-
-
302 int availableForWrite() override {
-
303 return cfg.channels * bytesPerSample() * cfg.length;
-
304 }
-
-
305
-
-
307 int available() override {
-
308 int step_size = cfg.stride > 0 ? cfg.stride : cfg.length;
-
309 return step_size * cfg.channels * bytesPerSample();
-
310 }
-
-
311
-
313 int size() { return bins; }
-
314
-
316 int length() { return cfg.length; }
-
317
-
320 unsigned long resultTime() { return timestamp; }
-
322 unsigned long resultTimeBegin() { return timestamp_begin; }
-
323
-
-
325 float frequency(int bin) {
-
326 if (bin >= bins) {
-
327 LOGE("Invalid bin %d", bin);
-
328 return 0;
-
329 }
-
330 return static_cast<float>(bin) * cfg.sample_rate / cfg.length;
-
331 }
-
-
332
-
- - -
336 ret_value.magnitude = 0;
-
337 ret_value.bin = 0;
-
338 // find max value and index
-
339 for (int j = 0; j < size(); j++) {
-
340 float m = magnitude(j);
-
341 if (m > ret_value.magnitude) {
-
342 ret_value.magnitude = m;
-
343 ret_value.bin = j;
-
344 }
-
345 }
-
346 ret_value.frequency = frequency(ret_value.bin);
-
347 return ret_value;
-
348 }
-
-
349
-
351 template <int N>
-
- -
353 // initialize to negative value
-
354 for (int j = 0; j < N; j++) {
-
355 result[j].magnitude = -1000000;
-
356 }
-
357 // find top n values
- -
359 for (int j = 0; j < size(); j++) {
-
360 act.magnitude = magnitude(j);
-
361 act.bin = j;
-
362 act.frequency = frequency(j);
- -
364 }
-
365 }
-
-
366
-
369 FFTDriver *driver() { return p_driver; }
-
370
-
-
373 float magnitude(int bin) {
-
374 if (bin >= bins) {
-
375 LOGE("Invalid bin %d", bin);
-
376 return 0;
-
377 }
-
378 return p_driver->magnitude(bin);
-
379 }
-
-
380
-
381 float magnitudeFast(int bin) {
-
382 if (bin >= bins) {
-
383 LOGE("Invalid bin %d", bin);
-
384 return 0;
-
385 }
-
386 return p_driver->magnitudeFast(bin);
-
387 }
-
-
390 float *magnitudes() {
-
391 if (l_magnitudes.size() == 0) {
-
392 l_magnitudes.resize(size());
-
393 }
-
394 for (int j = 0; j < size(); j++) {
-
395 l_magnitudes[j] = magnitude(j);
-
396 }
-
397 return l_magnitudes.data();
-
398 }
-
-
399
-
-
402 float *magnitudesFast() {
-
403 if (l_magnitudes.size() == 0) {
-
404 l_magnitudes.resize(size());
-
405 }
-
406 for (int j = 0; j < size(); j++) {
-
407 l_magnitudes[j] = magnitudeFast(j);
-
408 }
-
409 return l_magnitudes.data();
-
410 }
-
-
411
-
-
413 bool setBin(int idx, float real, float img) {
-
414 has_rfft_data = true;
-
415 return p_driver->setBin(idx, real, img);
-
416 }
-
-
-
418 bool setBin(int pos, FFTBin &bin) {
-
419 has_rfft_data = true;
-
420 return p_driver->setBin(pos, bin.real, bin.img);
-
421 }
-
-
423 bool getBin(int pos, FFTBin &bin) { return p_driver->getBin(pos, bin); }
-
424
-
426 AudioFFTConfig &config() { return cfg; }
-
427
-
428 protected:
-
429 FFTDriver *p_driver = nullptr;
-
430 int current_pos = 0;
-
431 AudioFFTConfig cfg;
-
432 unsigned long timestamp_begin = 0l;
-
433 unsigned long timestamp = 0l;
-
434 RingBuffer<uint8_t> stride_buffer{0};
-
435 Vector<float> l_magnitudes{0};
-
436 int bins = 0;
-
437 RingBuffer<uint8_t> rfft_data{0};
-
438 FFTInverseOverlapAdder rfft_add{0};
-
439 bool has_rfft_data = false;
-
440
-
441 // Add samples to input data p_x - and process them if full
-
442 template <typename T>
-
443 void processSamples(const void *data, size_t samples) {
-
444 T *dataT = (T *)data;
-
445 T sample;
-
446 float sample_windowed;
-
447 for (int j = 0; j < samples; j += cfg.channels) {
-
448 sample = dataT[j + cfg.channel_used];
-
449 p_driver->setValue(current_pos, windowedSample(sample, current_pos));
-
450 writeStrideBuffer((uint8_t *)&sample, sizeof(T));
-
451 if (++current_pos >= cfg.length) {
-
452 fft<T>();
-
453 current_pos = 0;
-
454
-
455 // reprocess data in stride buffer
-
456 if (stride_buffer.size() > 0) {
-
457 // reload data from stride buffer
-
458 while (stride_buffer.available()) {
-
459 T sample;
-
460 stride_buffer.readArray((uint8_t *)&sample, sizeof(T));
-
461 p_driver->setValue(current_pos,
-
462 windowedSample(sample, current_pos));
-
463 current_pos++;
-
464 }
-
465 }
-
466 }
-
467 }
-
468 }
-
469
-
470 template <typename T>
-
471 T windowedSample(T sample, int pos) {
-
472 T result = sample;
-
473 if (cfg.window_function != nullptr) {
-
474 result = cfg.window_function->factor(pos) * sample;
-
475 }
-
476 return result;
-
477 }
-
478
-
479 template <typename T>
-
480 void fft() {
-
481 timestamp_begin = millis();
-
482 p_driver->fft();
-
483 has_rfft_data = true;
-
484 timestamp = millis();
-
485 if (cfg.callback != nullptr) {
-
486 cfg.callback(*this);
-
487 }
-
488 }
-
489
-
-
491 void rfft() {
-
492 TRACED();
-
493 // execute reverse fft
-
494 p_driver->rfft();
-
495 has_rfft_data = false;
-
496 // add data to sum buffer
-
497 for (int j = 0; j < cfg.length; j++) {
-
498 float value = p_driver->getValue(j);
-
499 rfft_add.add(value, j, cfg.window_function);
-
500 }
-
501 // get result data from sum buffer
-
502 rfftWriteData(rfft_data);
-
503 }
-
-
504
-
- -
507 int step_size = cfg.stride > 0 ? cfg.stride : cfg.length;
-
508 // get data to result buffer
-
509 float step_data[step_size];
-
510 for (int j = 0; j < step_size; j++) {
-
511 step_data[j] = 0.0;
-
512 }
-
513 rfft_add.getStepData(step_data, step_size,
- -
515
-
516 switch (cfg.bits_per_sample) {
-
517 case 8:
-
518 writeIFFT<int8_t>(step_data, step_size);
-
519 break;
-
520 case 16:
-
521 writeIFFT<int16_t>(step_data, step_size);
-
522 break;
-
523 case 24:
-
524 writeIFFT<int24_t>(step_data, step_size);
-
525 break;
-
526 case 32:
-
527 writeIFFT<int32_t>(step_data, step_size);
-
528 break;
-
529 default:
-
530 LOGE("Unsupported bits: %d", cfg.bits_per_sample);
-
531 }
-
532 }
-
-
533
-
534 template <typename T>
-
535 void writeIFFT(float *data, int len) {
-
536 for (int j = 0; j < len; j++) {
-
537 T sample = data[j];
-
538 T out_data[cfg.channels];
-
539 for (int ch = 0; ch < cfg.channels; ch++) {
-
540 out_data[ch] = sample;
-
541 }
-
542 int result = rfft_data.writeArray((uint8_t *)out_data, sizeof(out_data));
-
543 assert(result == sizeof(out_data));
-
544 }
-
545 }
-
546
-
547 inline int bytesPerSample() { return cfg.bits_per_sample / 8; }
+
262 step_data.resize(0);
+
263 }
+ +
264
+
+
266 size_t write(const uint8_t *data, size_t len) override {
+
267 size_t result = 0;
+
268 if (p_driver->isValid()) {
+
269 result = len;
+
270 switch (cfg.bits_per_sample) {
+
271 case 8:
+
272 processSamples<int8_t>(data, len);
+
273 break;
+
274 case 16:
+
275 processSamples<int16_t>(data, len / 2);
+
276 break;
+
277 case 24:
+
278 processSamples<int24_t>(data, len / 3);
+
279 break;
+
280 case 32:
+
281 processSamples<int32_t>(data, len / 4);
+
282 break;
+
283 default:
+
284 LOGE("Unsupported bits_per_sample: %d", cfg.bits_per_sample);
+
285 break;
+
286 }
+
287 }
+
288 return result;
+
289 }
+
+
290
+
+
292 size_t readBytes(uint8_t *data, size_t len) override {
+
293 LOGD("setup ifft data");
+
294 if (rfft_data.size() == 0) return 0;
+
295 // execute rfft when we consumed all data
+
296 if (has_rfft_data && rfft_data.available() == 0) {
+
297 rfft();
+
298 }
+
299 return rfft_data.readArray(data, len);
+
300 }
+
+
301
+
+
303 int availableForWrite() override {
+
304 return cfg.channels * bytesPerSample() * cfg.length;
+
305 }
+
+
306
+
+
308 int available() override {
+
309 int step_size = cfg.stride > 0 ? cfg.stride : cfg.length;
+
310 return step_size * cfg.channels * bytesPerSample();
+
311 }
+
+
312
+
314 int size() { return bins; }
+
315
+
317 int length() { return cfg.length; }
+
318
+
321 unsigned long resultTime() { return timestamp; }
+
323 unsigned long resultTimeBegin() { return timestamp_begin; }
+
324
+
+
326 float frequency(int bin) {
+
327 if (bin >= bins) {
+
328 LOGE("Invalid bin %d", bin);
+
329 return 0;
+
330 }
+
331 return static_cast<float>(bin) * cfg.sample_rate / cfg.length;
+
332 }
+
+
333
+
+ + +
337 ret_value.magnitude = 0;
+
338 ret_value.bin = 0;
+
339 // find max value and index
+
340 for (int j = 0; j < size(); j++) {
+
341 float m = magnitude(j);
+
342 if (m > ret_value.magnitude) {
+
343 ret_value.magnitude = m;
+
344 ret_value.bin = j;
+
345 }
+
346 }
+
347 ret_value.frequency = frequency(ret_value.bin);
+
348 return ret_value;
+
349 }
+
+
350
+
352 template <int N>
+
+ +
354 // initialize to negative value
+
355 for (int j = 0; j < N; j++) {
+
356 result[j].magnitude = -1000000;
+
357 }
+
358 // find top n values
+ +
360 for (int j = 0; j < size(); j++) {
+
361 act.magnitude = magnitude(j);
+
362 act.bin = j;
+
363 act.frequency = frequency(j);
+ +
365 }
+
366 }
+
+
367
+
370 FFTDriver *driver() { return p_driver; }
+
371
+
+
374 float magnitude(int bin) {
+
375 if (bin >= bins) {
+
376 LOGE("Invalid bin %d", bin);
+
377 return 0;
+
378 }
+
379 return p_driver->magnitude(bin);
+
380 }
+
+
381
+
382 float magnitudeFast(int bin) {
+
383 if (bin >= bins) {
+
384 LOGE("Invalid bin %d", bin);
+
385 return 0;
+
386 }
+
387 return p_driver->magnitudeFast(bin);
+
388 }
+
+
391 float *magnitudes() {
+
392 if (l_magnitudes.size() == 0) {
+
393 l_magnitudes.resize(size());
+
394 }
+
395 for (int j = 0; j < size(); j++) {
+
396 l_magnitudes[j] = magnitude(j);
+
397 }
+
398 return l_magnitudes.data();
+
399 }
+
+
400
+
+
403 float *magnitudesFast() {
+
404 if (l_magnitudes.size() == 0) {
+
405 l_magnitudes.resize(size());
+
406 }
+
407 for (int j = 0; j < size(); j++) {
+
408 l_magnitudes[j] = magnitudeFast(j);
+
409 }
+
410 return l_magnitudes.data();
+
411 }
+
+
412
+
+
414 bool setBin(int idx, float real, float img) {
+
415 has_rfft_data = true;
+
416 return p_driver->setBin(idx, real, img);
+
417 }
+
+
+
419 bool setBin(int pos, FFTBin &bin) {
+
420 has_rfft_data = true;
+
421 return p_driver->setBin(pos, bin.real, bin.img);
+
422 }
+
+
424 bool getBin(int pos, FFTBin &bin) { return p_driver->getBin(pos, bin); }
+
425
+
427 AudioFFTConfig &config() { return cfg; }
+
428
+
429 protected:
+
430 FFTDriver *p_driver = nullptr;
+
431 int current_pos = 0;
+
432 AudioFFTConfig cfg;
+
433 unsigned long timestamp_begin = 0l;
+
434 unsigned long timestamp = 0l;
+
435 RingBuffer<uint8_t> stride_buffer{0};
+
436 Vector<float> l_magnitudes{0};
+
437 Vector<float> step_data{0};
+
438 int bins = 0;
+
439 RingBuffer<uint8_t> rfft_data{0};
+
440 FFTInverseOverlapAdder rfft_add{0};
+
441 bool has_rfft_data = false;
+
442
+
443 // Add samples to input data p_x - and process them if full
+
444 template <typename T>
+
445 void processSamples(const void *data, size_t samples) {
+
446 T *dataT = (T *)data;
+
447 T sample;
+
448 float sample_windowed;
+
449 for (int j = 0; j < samples; j += cfg.channels) {
+
450 sample = dataT[j + cfg.channel_used];
+
451 p_driver->setValue(current_pos, windowedSample(sample, current_pos));
+
452 writeStrideBuffer((uint8_t *)&sample, sizeof(T));
+
453 if (++current_pos >= cfg.length) {
+
454 fft<T>();
+
455 current_pos = 0;
+
456
+
457 // reprocess data in stride buffer
+
458 if (stride_buffer.size() > 0) {
+
459 // reload data from stride buffer
+
460 while (stride_buffer.available()) {
+
461 T sample;
+
462 stride_buffer.readArray((uint8_t *)&sample, sizeof(T));
+
463 p_driver->setValue(current_pos,
+
464 windowedSample(sample, current_pos));
+
465 current_pos++;
+
466 }
+
467 }
+
468 }
+
469 }
+
470 }
+
471
+
472 template <typename T>
+
473 T windowedSample(T sample, int pos) {
+
474 T result = sample;
+
475 if (cfg.window_function != nullptr) {
+
476 result = cfg.window_function->factor(pos) * sample;
+
477 }
+
478 return result;
+
479 }
+
480
+
481 template <typename T>
+
482 void fft() {
+
483 timestamp_begin = millis();
+
484 p_driver->fft();
+
485 has_rfft_data = true;
+
486 timestamp = millis();
+
487 if (cfg.callback != nullptr) {
+
488 cfg.callback(*this);
+
489 }
+
490 }
+
491
+
+
493 void rfft() {
+
494 TRACED();
+
495 // execute reverse fft
+
496 p_driver->rfft();
+
497 has_rfft_data = false;
+
498 // add data to sum buffer
+
499 for (int j = 0; j < cfg.length; j++) {
+
500 float value = p_driver->getValue(j);
+
501 rfft_add.add(value, j, cfg.window_function);
+
502 }
+
503 // get result data from sum buffer
+
504 rfftWriteData(rfft_data);
+
505 }
+
+
506
+
+ +
509 int step_size = cfg.stride > 0 ? cfg.stride : cfg.length;
+
510 // get data to result buffer
+
511 step_data.resize(step_size);
+
512 for (int j = 0; j < step_size; j++) {
+
513 step_data[j] = 0.0;
+
514 }
+
515 rfft_add.getStepData(step_data.data(), step_size,
+ +
517
+
518 switch (cfg.bits_per_sample) {
+
519 case 8:
+
520 writeIFFT<int8_t>(step_data.data(), step_size);
+
521 break;
+
522 case 16:
+
523 writeIFFT<int16_t>(step_data.data(), step_size);
+
524 break;
+
525 case 24:
+
526 writeIFFT<int24_t>(step_data.data(), step_size);
+
527 break;
+
528 case 32:
+
529 writeIFFT<int32_t>(step_data.data(), step_size);
+
530 break;
+
531 default:
+
532 LOGE("Unsupported bits: %d", cfg.bits_per_sample);
+
533 }
+
534 }
+
+
535
+
536 template <typename T>
+
537 void writeIFFT(float *data, int len) {
+
538 for (int j = 0; j < len; j++) {
+
539 T sample = data[j];
+
540 T out_data[cfg.channels];
+
541 for (int ch = 0; ch < cfg.channels; ch++) {
+
542 out_data[ch] = sample;
+
543 }
+
544 int result = rfft_data.writeArray((uint8_t *)out_data, sizeof(out_data));
+
545 assert(result == sizeof(out_data));
+
546 }
+
547 }
548
-
550 template <int N>
-
- -
552 // find place where we need to insert new record
-
553 for (int j = 0; j < N; j++) {
-
554 // insert when biggen then current record
-
555 if (tmp.magnitude > result[j].magnitude) {
-
556 // shift existing values right
-
557 for (int i = N - 2; i >= j; i--) {
-
558 result[i + 1] = result[i];
-
559 }
-
560 // insert new value
-
561 result[j] = tmp;
-
562 // stop after we found the correct index
-
563 break;
-
564 }
-
565 }
-
566 }
-
-
567
-
568 void writeStrideBuffer(uint8_t *buffer, size_t len) {
-
569 if (stride_buffer.size() > 0) {
-
570 int available = stride_buffer.availableForWrite();
-
571 if (len > available) {
-
572 // clear oldest values to make space
-
573 int diff = len - available;
-
574 for (int j = 0; j < diff; j++) {
-
575 stride_buffer.read();
-
576 }
-
577 }
-
578 stride_buffer.writeArray(buffer, len);
-
579 }
-
580 }
-
581
-
582 bool isPowerOfTwo(uint16_t x) { return (x & (x - 1)) == 0; }
-
583};
- -
584
-
585} // namespace audio_tools
+
549 inline int bytesPerSample() { return cfg.bits_per_sample / 8; }
+
550
+
552 template <int N>
+
+ +
554 // find place where we need to insert new record
+
555 for (int j = 0; j < N; j++) {
+
556 // insert when biggen then current record
+
557 if (tmp.magnitude > result[j].magnitude) {
+
558 // shift existing values right
+
559 for (int i = N - 2; i >= j; i--) {
+
560 result[i + 1] = result[i];
+
561 }
+
562 // insert new value
+
563 result[j] = tmp;
+
564 // stop after we found the correct index
+
565 break;
+
566 }
+
567 }
+
568 }
+
+
569
+
570 void writeStrideBuffer(uint8_t *buffer, size_t len) {
+
571 if (stride_buffer.size() > 0) {
+
572 int available = stride_buffer.availableForWrite();
+
573 if (len > available) {
+
574 // clear oldest values to make space
+
575 int diff = len - available;
+
576 for (int j = 0; j < diff; j++) {
+
577 stride_buffer.read();
+
578 }
+
579 }
+
580 stride_buffer.writeArray(buffer, len);
+
581 }
+
582 }
+
583
+
584 bool isPowerOfTwo(uint16_t x) { return (x & (x - 1)) == 0; }
+
585};
+ +
586
+
587} // namespace audio_tools
Different Window functions that can be used by FFT.
Executes FFT using audio data privded by write() and/or an inverse FFT where the samples are made ava...
Definition AudioFFT.h:179
-
unsigned long resultTimeBegin()
time before the fft
Definition AudioFFT.h:322
-
float magnitude(int bin)
Definition AudioFFT.h:373
-
float * magnitudesFast()
Definition AudioFFT.h:402
-
unsigned long resultTime()
Definition AudioFFT.h:320
-
int length()
The number of samples.
Definition AudioFFT.h:316
-
size_t readBytes(uint8_t *data, size_t len) override
Provides the result of a reverse FFT.
Definition AudioFFT.h:291
+
unsigned long resultTimeBegin()
time before the fft
Definition AudioFFT.h:323
+
float magnitude(int bin)
Definition AudioFFT.h:374
+
float * magnitudesFast()
Definition AudioFFT.h:403
+
unsigned long resultTime()
Definition AudioFFT.h:321
+
int length()
The number of samples.
Definition AudioFFT.h:317
+
size_t readBytes(uint8_t *data, size_t len) override
Provides the result of a reverse FFT.
Definition AudioFFT.h:292
void end() override
Release the allocated memory.
Definition AudioFFT.h:257
-
int available() override
Data available for reverse fft.
Definition AudioFFT.h:307
+
int available() override
Data available for reverse fft.
Definition AudioFFT.h:308
AudioFFTBase(FFTDriver *driver)
Definition AudioFFT.h:183
-
AudioFFTConfig & config()
Provides the actual configuration.
Definition AudioFFT.h:426
-
size_t write(const uint8_t *data, size_t len) override
Provide the audio data as FFT input.
Definition AudioFFT.h:265
-
FFTDriver * driver()
Definition AudioFFT.h:369
-
bool setBin(int idx, float real, float img)
sets the value of a bin
Definition AudioFFT.h:413
-
int availableForWrite() override
We try to fill the buffer at once.
Definition AudioFFT.h:302
+
AudioFFTConfig & config()
Provides the actual configuration.
Definition AudioFFT.h:427
+
size_t write(const uint8_t *data, size_t len) override
Provide the audio data as FFT input.
Definition AudioFFT.h:266
+
FFTDriver * driver()
Definition AudioFFT.h:370
+
bool setBin(int idx, float real, float img)
sets the value of a bin
Definition AudioFFT.h:414
+
int availableForWrite() override
We try to fill the buffer at once.
Definition AudioFFT.h:303
AudioFFTConfig defaultConfig(RxTxMode mode=TX_MODE)
Provides the default configuration.
Definition AudioFFT.h:188
bool begin(AudioFFTConfig info)
starts the processing
Definition AudioFFT.h:195
-
float * magnitudes()
Definition AudioFFT.h:390
-
bool getBin(int pos, FFTBin &bin)
gets the value of a bin
Definition AudioFFT.h:423
-
AudioFFTResult result()
Determines the result values in the max magnitude bin.
Definition AudioFFT.h:334
-
float frequency(int bin)
Determines the frequency of the indicated bin.
Definition AudioFFT.h:325
-
void rfft()
reverse fft
Definition AudioFFT.h:491
-
bool setBin(int pos, FFTBin &bin)
sets the value of a bin
Definition AudioFFT.h:418
-
void insertSorted(AudioFFTResult(&result)[N], AudioFFTResult tmp)
make sure that we do not reuse already found results
Definition AudioFFT.h:551
+
float * magnitudes()
Definition AudioFFT.h:391
+
bool getBin(int pos, FFTBin &bin)
gets the value of a bin
Definition AudioFFT.h:424
+
AudioFFTResult result()
Determines the result values in the max magnitude bin.
Definition AudioFFT.h:335
+
float frequency(int bin)
Determines the frequency of the indicated bin.
Definition AudioFFT.h:326
+
void rfft()
reverse fft
Definition AudioFFT.h:493
+
bool setBin(int pos, FFTBin &bin)
sets the value of a bin
Definition AudioFFT.h:419
+
void insertSorted(AudioFFTResult(&result)[N], AudioFFTResult tmp)
make sure that we do not reuse already found results
Definition AudioFFT.h:553
bool begin() override
starts the processing
Definition AudioFFT.h:201
void setAudioInfo(AudioInfo info) override
Notify change of audio information.
Definition AudioFFT.h:249
void reset()
Just resets the current_pos e.g. to start a new cycle.
Definition AudioFFT.h:239
-
void resultArray(AudioFFTResult(&result)[N])
Determines the N biggest result values.
Definition AudioFFT.h:352
-
int size()
The number of bins used by the FFT which are relevant for the result.
Definition AudioFFT.h:313
-
void rfftWriteData(BaseBuffer< uint8_t > &data)
write reverse fft result to buffer to make it available for readBytes
Definition AudioFFT.h:506
+
void resultArray(AudioFFTResult(&result)[N])
Determines the N biggest result values.
Definition AudioFFT.h:353
+
int size()
The number of bins used by the FFT which are relevant for the result.
Definition AudioFFT.h:314
+
void rfftWriteData(BaseBuffer< uint8_t > &data)
write reverse fft result to buffer to make it available for readBytes
Definition AudioFFT.h:508
Base class for all Audio Streams. It support the boolean operator to test if the object is ready with...
Definition BaseStream.h:113
virtual int readArray(T data[], int len)
reads multiple values
Definition Buffers.h:41
virtual int writeArray(const T data[], int len)
Fills the buffer data.
Definition Buffers.h:65
diff --git a/_audio_kiss_f_f_t_8h_source.html b/_audio_kiss_f_f_t_8h_source.html index cefa5aeb3..851311c24 100644 --- a/_audio_kiss_f_f_t_8h_source.html +++ b/_audio_kiss_f_f_t_8h_source.html @@ -193,7 +193,7 @@
110
111}
Executes FFT using audio data privded by write() and/or an inverse FFT where the samples are made ava...
Definition AudioFFT.h:179
-
FFTDriver * driver()
Definition AudioFFT.h:369
+
FFTDriver * driver()
Definition AudioFFT.h:370
AudioFFT using FFTReal. The only specific functionality is the access to the dataArray.
Definition AudioKissFFT.h:96
kiss_fft_cpx * dataArray()
Provides the complex array returned by the FFT
Definition AudioKissFFT.h:101
Abstract Class which defines the basic FFT functionality.
Definition AudioFFT.h:144
diff --git a/_audio_real_f_f_t_8h_source.html b/_audio_real_f_f_t_8h_source.html index bd336d8ef..ae5222230 100644 --- a/_audio_real_f_f_t_8h_source.html +++ b/_audio_real_f_f_t_8h_source.html @@ -197,7 +197,7 @@
115
116}
Executes FFT using audio data privded by write() and/or an inverse FFT where the samples are made ava...
Definition AudioFFT.h:179
-
FFTDriver * driver()
Definition AudioFFT.h:369
+
FFTDriver * driver()
Definition AudioFFT.h:370
AudioFFT using RealFFT.
Definition AudioRealFFT.h:97
float * realArray()
Provides the real array returned by the FFT.
Definition AudioRealFFT.h:102
float * imgArray()
Provides the complex array returned by the FFT
Definition AudioRealFFT.h:107
@@ -213,7 +213,7 @@
void rfft() override
Inverse fft - convert fft result back to time domain (samples)
Definition AudioRealFFT.h:50
float getValue(int idx) override
get Real value
Definition AudioRealFFT.h:69
Vector implementation which provides the most important methods as defined by std::vector....
Definition Vector.h:21
-
Definition FFTReal.h:578
+
Definition FFTReal.h:596
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioConfig.h:877
And individual FFT Bin.
Definition AudioFFT.h:59
diff --git a/_f_f_t_display_8h_source.html b/_f_f_t_display_8h_source.html index 85fd3dc66..510d84098 100644 --- a/_f_f_t_display_8h_source.html +++ b/_f_f_t_display_8h_source.html @@ -167,9 +167,9 @@
89
90} // namespace audio_tools
Executes FFT using audio data privded by write() and/or an inverse FFT where the samples are made ava...
Definition AudioFFT.h:179
-
float magnitude(int bin)
Definition AudioFFT.h:373
-
AudioFFTConfig & config()
Provides the actual configuration.
Definition AudioFFT.h:426
-
int size()
The number of bins used by the FFT which are relevant for the result.
Definition AudioFFT.h:313
+
float magnitude(int bin)
Definition AudioFFT.h:374
+
AudioFFTConfig & config()
Provides the actual configuration.
Definition AudioFFT.h:427
+
int size()
The number of bins used by the FFT which are relevant for the result.
Definition AudioFFT.h:314
Definition FFTDisplay.h:18
float fft_max_magnitude
Influences the senitivity.
Definition FFTDisplay.h:30
int fft_group_bin
group result by adding subsequent bins
Definition FFTDisplay.h:28
diff --git a/_f_f_t_real_8h_source.html b/_f_f_t_real_8h_source.html index 88d8d3aa2..1057cadf9 100644 --- a/_f_f_t_real_8h_source.html +++ b/_f_f_t_real_8h_source.html @@ -97,3988 +97,4020 @@
14*Tab=3***********************************************************************/
15#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
16
-
17
-
18#if ! defined (ffft_FFTReal_HEADER_INCLUDED)
-
19#define ffft_FFTReal_HEADER_INCLUDED
+
17// We use the DefaultAllocator which supports PSRAM
+
18#define FFT_CUSTOM_ALLOC DefaultAllocator
+
19
20
-
21#if defined (_MSC_VER)
-
22 #pragma once
-
23 #pragma warning (4 : 4250) // "Inherits via dominance."
-
24#endif
-
25
-
26
-
27
-
28/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
21#if ! defined (ffft_FFTReal_HEADER_INCLUDED)
+
22#define ffft_FFTReal_HEADER_INCLUDED
+
23
+
24#if defined (_MSC_VER)
+
25 #pragma once
+
26 #pragma warning (4 : 4250) // "Inherits via dominance."
+
27#endif
+
28
29
-
30/*****************************************************************************
-
31
-
32 def.h
-
33 By Laurent de Soras
+
30
+
31/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
32
+
33/*****************************************************************************
34
-
35--- Legal stuff ---
-
36
-
37This program is free software. It comes without any warranty, to
-
38the extent permitted by applicable law. You can redistribute it
-
39and/or modify it under the terms of the Do What The Fuck You Want
-
40To Public License, Version 2, as published by Sam Hocevar. See
-
41http://sam.zoy.org/wtfpl/COPYING for more details.
-
42
-
43*Tab=3***********************************************************************/
-
44
-
45
-
46
-
47#if ! defined (ffft_def_HEADER_INCLUDED)
-
48#define ffft_def_HEADER_INCLUDED
+
35 def.h
+
36 By Laurent de Soras
+
37
+
38--- Legal stuff ---
+
39
+
40This program is free software. It comes without any warranty, to
+
41the extent permitted by applicable law. You can redistribute it
+
42and/or modify it under the terms of the Do What The Fuck You Want
+
43To Public License, Version 2, as published by Sam Hocevar. See
+
44http://sam.zoy.org/wtfpl/COPYING for more details.
+
45
+
46*Tab=3***********************************************************************/
+
47
+
48
49
-
50#if defined (_MSC_VER)
-
51 #pragma once
-
52 #pragma warning (4 : 4250) // "Inherits via dominance."
-
53#endif
-
54
-
55
-
56
-
57/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
50#if ! defined (ffft_def_HEADER_INCLUDED)
+
51#define ffft_def_HEADER_INCLUDED
+
52
+
53#if defined (_MSC_VER)
+
54 #pragma once
+
55 #pragma warning (4 : 4250) // "Inherits via dominance."
+
56#endif
+
57
58
59
-
-
61namespace ffft {
+
60/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
61
62
-
63
-
64#ifndef PI
-
65const double PI = 3.1415926535897932384626433832795;
-
66#endif
-
67const double SQRT2 = 1.41421356237309514547462185873883;
-
68
-
69#if defined (_MSC_VER)
-
70
-
71 #define ffft_FORCEINLINE __forceinline
-
72
-
73#else
-
74
-
75 #define ffft_FORCEINLINE inline
-
76
-
77#endif
-
78
+
+
64namespace ffft {
+
65
+
66
+
67#ifndef PI
+
68const double PI = 3.1415926535897932384626433832795;
+
69#endif
+
70const double SQRT2 = 1.41421356237309514547462185873883;
+
71
+
72#if defined (_MSC_VER)
+
73
+
74 #define ffft_FORCEINLINE __forceinline
+
75
+
76#else
+
77
+
78 #define ffft_FORCEINLINE inline
79
-
80
-
81} // namespace ffft
-
+
80#endif
+
81
82
83
-
84
-
85#endif // ffft_def_HEADER_INCLUDED
+
84} // namespace ffft
+
+
85
86
87
-
88
-
89/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
88#endif // ffft_def_HEADER_INCLUDED
+
89
90
-
91/*****************************************************************************
-
92
-
93 DynArray.h
-
94 By Laurent de Soras
+
91
+
92/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
93
+
94/*****************************************************************************
95
-
96--- Legal stuff ---
-
97
-
98This program is free software. It comes without any warranty, to
-
99the extent permitted by applicable law. You can redistribute it
-
100and/or modify it under the terms of the Do What The Fuck You Want
-
101To Public License, Version 2, as published by Sam Hocevar. See
-
102http://sam.zoy.org/wtfpl/COPYING for more details.
-
103
-
104*Tab=3***********************************************************************/
-
105
-
106
-
107
-
108#if ! defined (ffft_DynArray_HEADER_INCLUDED)
-
109#define ffft_DynArray_HEADER_INCLUDED
+
96 DynArray.h
+
97 By Laurent de Soras
+
98
+
99--- Legal stuff ---
+
100
+
101This program is free software. It comes without any warranty, to
+
102the extent permitted by applicable law. You can redistribute it
+
103and/or modify it under the terms of the Do What The Fuck You Want
+
104To Public License, Version 2, as published by Sam Hocevar. See
+
105http://sam.zoy.org/wtfpl/COPYING for more details.
+
106
+
107*Tab=3***********************************************************************/
+
108
+
109
110
-
111#if defined (_MSC_VER)
-
112 #pragma once
-
113 #pragma warning (4 : 4250) // "Inherits via dominance."
-
114#endif
-
115
-
116
-
117
-
118/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
111#if ! defined (ffft_DynArray_HEADER_INCLUDED)
+
112#define ffft_DynArray_HEADER_INCLUDED
+
113
+
114#if defined (_MSC_VER)
+
115 #pragma once
+
116 #pragma warning (4 : 4250) // "Inherits via dominance."
+
117#endif
+
118
119
120
-
122namespace ffft
-
123{
-
124
-
125
-
126
-
127template <class T>
-
- -
129{
-
130
-
131/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
132
-
133public:
-
134
-
135 typedef T DataType;
-
136
-
137 DynArray ();
-
138 explicit DynArray (long size);
-
139 ~DynArray ();
-
140
-
141 inline long size () const;
-
142 inline void resize (long size);
+
121/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
122
+
123
+
125namespace ffft
+
126{
+
127
+
128
+
129
+
130template <class T>
+
+ +
132{
+
133
+
134/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
135
+
136public:
+
137
+
138 typedef T DataType;
+
139
+
140 DynArray ();
+
141 explicit DynArray (long size);
+
142 ~DynArray ();
143
-
144 inline const DataType &
-
145 operator [] (long pos) const;
-
146 inline DataType &
-
147 operator [] (long pos);
-
148
-
149
-
150
-
151/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
144 inline long size () const;
+
145 inline void resize (long size);
+
146
+
147 inline const DataType &
+
148 operator [] (long pos) const;
+
149 inline DataType &
+
150 operator [] (long pos);
+
151
152
-
153protected:
-
154
+
153
+
154/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
155
-
156
-
157/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
156protected:
+
157
158
-
159private:
-
160
-
161 DataType * _data_ptr;
-
162 long _len;
+
159
+
160/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
161
+
162private:
163
-
164
-
165
-
166/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
164 DataType * _data_ptr;
+
165 long _len;
+
166
167
-
168private:
-
169
-
170 DynArray (const DynArray &other);
-
171 DynArray & operator = (const DynArray &other);
-
172 bool operator == (const DynArray &other);
-
173 bool operator != (const DynArray &other);
-
174
-
175}; // class DynArray
-
-
176
+
168
+
169/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
170
+
171private:
+
172
+
173 DynArray (const DynArray &other);
+
174 DynArray & operator = (const DynArray &other);
+
175 bool operator == (const DynArray &other);
+
176 bool operator != (const DynArray &other);
177
-
178
-
179} // namespace ffft
+
178}; // class DynArray
+
+
179
180
181
-
182
-
183/*****************************************************************************
-
184
-
185 DynArray.hpp
-
186 By Laurent de Soras
+
182} // namespace ffft
+
183
+
184
+
185
+
186/*****************************************************************************
187
-
188--- Legal stuff ---
-
189
-
190This program is free software. It comes without any warranty, to
-
191the extent permitted by applicable law. You can redistribute it
-
192and/or modify it under the terms of the Do What The Fuck You Want
-
193To Public License, Version 2, as published by Sam Hocevar. See
-
194http://sam.zoy.org/wtfpl/COPYING for more details.
-
195
-
196*Tab=3***********************************************************************/
-
197
-
198
-
199
-
200#if defined (ffft_DynArray_CURRENT_CODEHEADER)
-
201 #error Recursive inclusion of DynArray code header.
-
202#endif
-
203#define ffft_DynArray_CURRENT_CODEHEADER
-
204
-
205#if ! defined (ffft_DynArray_CODEHEADER_INCLUDED)
-
206#define ffft_DynArray_CODEHEADER_INCLUDED
+
188 DynArray.hpp
+
189 By Laurent de Soras
+
190
+
191--- Legal stuff ---
+
192
+
193This program is free software. It comes without any warranty, to
+
194the extent permitted by applicable law. You can redistribute it
+
195and/or modify it under the terms of the Do What The Fuck You Want
+
196To Public License, Version 2, as published by Sam Hocevar. See
+
197http://sam.zoy.org/wtfpl/COPYING for more details.
+
198
+
199*Tab=3***********************************************************************/
+
200
+
201
+
202
+
203#if defined (ffft_DynArray_CURRENT_CODEHEADER)
+
204 #error Recursive inclusion of DynArray code header.
+
205#endif
+
206#define ffft_DynArray_CURRENT_CODEHEADER
207
-
208
-
209
-
210/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
208#if ! defined (ffft_DynArray_CODEHEADER_INCLUDED)
+
209#define ffft_DynArray_CODEHEADER_INCLUDED
+
210
211
-
212#include <cassert>
-
213
+
212
+
213/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
214
-
215
-
216namespace ffft
-
217{
+
215#include <cassert>
+
216
+
217
218
-
219
-
220
-
221/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
219namespace ffft
+
220{
+
221
222
223
-
224
-
225template <class T>
-
226DynArray <T>::DynArray ()
-
227: _data_ptr (0)
-
228, _len (0)
-
229{
-
230 // Nothing
-
231}
-
232
-
233
-
234
-
235template <class T>
-
236DynArray <T>::DynArray (long size)
-
237: _data_ptr (0)
-
238, _len (0)
-
239{
-
240 assert (size >= 0);
-
241 if (size > 0)
-
242 {
-
243 _data_ptr = new DataType [size];
-
244 _len = size;
-
245 }
-
246}
-
247
-
248
-
249
-
250template <class T>
-
251DynArray <T>::~DynArray ()
-
252{
-
253 delete [] _data_ptr;
-
254 _data_ptr = 0;
-
255 _len = 0;
-
256}
-
257
-
258
-
259
-
260template <class T>
-
261long DynArray <T>::size () const
-
262{
-
263 return (_len);
-
264}
-
265
-
266
-
267
-
268template <class T>
-
269void DynArray <T>::resize (long size)
-
270{
-
271 assert (size >= 0);
-
272 if (size > 0)
-
273 {
-
274 DataType * old_data_ptr = _data_ptr;
-
275 DataType * tmp_data_ptr = new DataType [size];
+
224/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
225
+
226
+
227
+
228template <class T>
+
229DynArray <T>::DynArray ()
+
230: _data_ptr (0)
+
231, _len (0)
+
232{
+
233 // Nothing
+
234}
+
235
+
236
+
237
+
238template <class T>
+
239DynArray <T>::DynArray (long size)
+
240: _data_ptr (0)
+
241, _len (0)
+
242{
+
243 assert (size >= 0);
+
244 if (size > 0)
+
245 {
+
246#ifdef FFT_CUSTOM_ALLOC
+
247 _data_ptr = FFT_CUSTOM_ALLOC.createArray<DataType>(size);
+
248#else
+
249 _data_ptr = new DataType [size];
+
250#endif
+
251 _len = size;
+
252 }
+
253}
+
254
+
255
+
256
+
257template <class T>
+
258DynArray <T>::~DynArray ()
+
259{
+
260#ifdef FFT_CUSTOM_ALLOC
+
261 FFT_CUSTOM_ALLOC.removeArray<DataType>(_data_ptr, _len);
+
262#else
+
263 delete [] _data_ptr;
+
264#endif
+
265 _data_ptr = 0;
+
266 _len = 0;
+
267}
+
268
+
269
+
270
+
271template <class T>
+
272long DynArray <T>::size () const
+
273{
+
274 return (_len);
+
275}
276
-
277 _data_ptr = tmp_data_ptr;
-
278 _len = size;
-
279
-
280 delete [] old_data_ptr;
-
281 }
-
282}
-
283
-
284
-
285
-
286template <class T>
-
287const typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos) const
-
288{
-
289 assert (pos >= 0);
-
290 assert (pos < _len);
-
291
-
292 return (_data_ptr [pos]);
-
293}
-
294
-
295
-
296
-
297template <class T>
-
298typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos)
-
299{
-
300 assert (pos >= 0);
-
301 assert (pos < _len);
+
277
+
278
+
279template <class T>
+
280void DynArray <T>::resize (long size)
+
281{
+
282 assert (size >= 0);
+
283 if (size > 0)
+
284 {
+
285 DataType * old_data_ptr = _data_ptr;
+
286#ifdef FFT_CUSTOM_ALLOC
+
287 DataType * tmp_data_ptr = FFT_CUSTOM_ALLOC.createArray<DataType>(size);
+
288#else
+
289 DataType * tmp_data_ptr = new DataType [size];
+
290#endif
+
291 _data_ptr = tmp_data_ptr;
+
292 _len = size;
+
293
+
294#ifdef FFT_CUSTOM_ALLOC
+
295 FFT_CUSTOM_ALLOC.removeArray<DataType>(old_data_ptr, _len);
+
296#else
+
297 delete [] old_data_ptr;
+
298#endif
+
299 }
+
300}
+
301
302
-
303 return (_data_ptr [pos]);
-
304}
-
305
-
306
-
307
-
308/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
303
+
304template <class T>
+
305const typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos) const
+
306{
+
307 assert (pos >= 0);
+
308 assert (pos < _len);
309
-
310
-
311
-
312/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
310 return (_data_ptr [pos]);
+
311}
+
312
313
314
-
315
-
316} // namespace ffft
-
317
-
318
-
319
-
320#endif // ffft_DynArray_CODEHEADER_INCLUDED
-
321
-
322#undef ffft_DynArray_CURRENT_CODEHEADER
+
315template <class T>
+
316typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos)
+
317{
+
318 assert (pos >= 0);
+
319 assert (pos < _len);
+
320
+
321 return (_data_ptr [pos]);
+
322}
323
324
325
-
326/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
326/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
327
328
329
-
330
-
331#endif // ffft_DynArray_HEADER_INCLUDED
+
330/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
331
332
333
-
334
-
335/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
334} // namespace ffft
+
335
336
-
337/*****************************************************************************
-
338
-
339 OscSinCos.h
-
340 By Laurent de Soras
-
341
-
342--- Legal stuff ---
-
343
-
344This program is free software. It comes without any warranty, to
-
345the extent permitted by applicable law. You can redistribute it
-
346and/or modify it under the terms of the Do What The Fuck You Want
-
347To Public License, Version 2, as published by Sam Hocevar. See
-
348http://sam.zoy.org/wtfpl/COPYING for more details.
-
349
-
350*Tab=3***********************************************************************/
+
337
+
338#endif // ffft_DynArray_CODEHEADER_INCLUDED
+
339
+
340#undef ffft_DynArray_CURRENT_CODEHEADER
+
341
+
342
+
343
+
344/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
345
+
346
+
347
+
348
+
349#endif // ffft_DynArray_HEADER_INCLUDED
+
350
351
352
-
353
-
354#if ! defined (ffft_OscSinCos_HEADER_INCLUDED)
-
355#define ffft_OscSinCos_HEADER_INCLUDED
-
356
-
357#if defined (_MSC_VER)
-
358 #pragma once
-
359 #pragma warning (4 : 4250) // "Inherits via dominance."
-
360#endif
-
361
-
362
-
363
-
364/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
365
-
366
-
367
-
368
+
353/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
354
+
355/*****************************************************************************
+
356
+
357 OscSinCos.h
+
358 By Laurent de Soras
+
359
+
360--- Legal stuff ---
+
361
+
362This program is free software. It comes without any warranty, to
+
363the extent permitted by applicable law. You can redistribute it
+
364and/or modify it under the terms of the Do What The Fuck You Want
+
365To Public License, Version 2, as published by Sam Hocevar. See
+
366http://sam.zoy.org/wtfpl/COPYING for more details.
+
367
+
368*Tab=3***********************************************************************/
369
-
370namespace ffft
-
371{
-
372
-
373
+
370
+
371
+
372#if ! defined (ffft_OscSinCos_HEADER_INCLUDED)
+
373#define ffft_OscSinCos_HEADER_INCLUDED
374
-
375template <class T>
-
- -
377{
-
378
-
379/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
375#if defined (_MSC_VER)
+
376 #pragma once
+
377 #pragma warning (4 : 4250) // "Inherits via dominance."
+
378#endif
+
379
380
-
381public:
-
382
-
383 typedef T DataType;
+
381
+
382/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
383
384
-
385 OscSinCos ();
+
385
386
-
387 ffft_FORCEINLINE void
-
388 set_step (double angle_rad);
-
389
-
390 ffft_FORCEINLINE DataType
-
391 get_cos () const;
-
392 ffft_FORCEINLINE DataType
-
393 get_sin () const;
-
394 ffft_FORCEINLINE void
-
395 step ();
-
396 ffft_FORCEINLINE void
-
397 clear_buffers ();
+
387
+
388namespace ffft
+
389{
+
390
+
391
+
392
+
393template <class T>
+
+ +
395{
+
396
+
397/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
398
-
399
+
399public:
400
-
401/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
401 typedef T DataType;
402
-
403protected:
+
403 OscSinCos ();
404
-
405
-
406
-
407/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
408
-
409private:
-
410
-
411 DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1]
-
412 DataType _pos_sin; // -
-
413 DataType _step_cos; // Phase increment per step, [-1 ; 1]
-
414 DataType _step_sin; // -
-
415
+
405 ffft_FORCEINLINE void
+
406 set_step (double angle_rad);
+
407
+
408 ffft_FORCEINLINE DataType
+
409 get_cos () const;
+
410 ffft_FORCEINLINE DataType
+
411 get_sin () const;
+
412 ffft_FORCEINLINE void
+
413 step ();
+
414 ffft_FORCEINLINE void
+
415 clear_buffers ();
416
417
-
418/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
-
419
-
420private:
-
421
-
422 OscSinCos (const OscSinCos &other);
-
423 OscSinCos & operator = (const OscSinCos &other);
-
424 bool operator == (const OscSinCos &other);
-
425 bool operator != (const OscSinCos &other);
+
418
+
419/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
420
+
421protected:
+
422
+
423
+
424
+
425/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
426
-
427}; // class OscSinCos
-
+
427private:
428
-
429
-
430
-
431} // namespace ffft
-
432
+
429 DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1]
+
430 DataType _pos_sin; // -
+
431 DataType _step_cos; // Phase increment per step, [-1 ; 1]
+
432 DataType _step_sin; // -
433
434
-
435/*****************************************************************************
-
436
-
437 OscSinCos.hpp
-
438 By Laurent de Soras
-
439
-
440--- Legal stuff ---
-
441
-
442This program is free software. It comes without any warranty, to
-
443the extent permitted by applicable law. You can redistribute it
-
444and/or modify it under the terms of the Do What The Fuck You Want
-
445To Public License, Version 2, as published by Sam Hocevar. See
-
446http://sam.zoy.org/wtfpl/COPYING for more details.
-
447
-
448*Tab=3***********************************************************************/
-
449
+
435
+
436/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
437
+
438private:
+
439
+
440 OscSinCos (const OscSinCos &other);
+
441 OscSinCos & operator = (const OscSinCos &other);
+
442 bool operator == (const OscSinCos &other);
+
443 bool operator != (const OscSinCos &other);
+
444
+
445}; // class OscSinCos
+
+
446
+
447
+
448
+
449} // namespace ffft
450
451
-
452#if defined (ffft_OscSinCos_CURRENT_CODEHEADER)
-
453 #error Recursive inclusion of OscSinCos code header.
-
454#endif
-
455#define ffft_OscSinCos_CURRENT_CODEHEADER
-
456
-
457#if ! defined (ffft_OscSinCos_CODEHEADER_INCLUDED)
-
458#define ffft_OscSinCos_CODEHEADER_INCLUDED
-
459
-
460
-
461
-
462/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
463
-
464#include <cmath>
-
465
-
466namespace std { }
+
452
+
453/*****************************************************************************
+
454
+
455 OscSinCos.hpp
+
456 By Laurent de Soras
+
457
+
458--- Legal stuff ---
+
459
+
460This program is free software. It comes without any warranty, to
+
461the extent permitted by applicable law. You can redistribute it
+
462and/or modify it under the terms of the Do What The Fuck You Want
+
463To Public License, Version 2, as published by Sam Hocevar. See
+
464http://sam.zoy.org/wtfpl/COPYING for more details.
+
465
+
466*Tab=3***********************************************************************/
467
468
469
-
470namespace ffft
-
471{
-
472
-
473
+
470#if defined (ffft_OscSinCos_CURRENT_CODEHEADER)
+
471 #error Recursive inclusion of OscSinCos code header.
+
472#endif
+
473#define ffft_OscSinCos_CURRENT_CODEHEADER
474
-
475/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
476
+
475#if ! defined (ffft_OscSinCos_CODEHEADER_INCLUDED)
+
476#define ffft_OscSinCos_CODEHEADER_INCLUDED
477
478
-
479template <class T>
-
480OscSinCos <T>::OscSinCos ()
-
481: _pos_cos (1)
-
482, _pos_sin (0)
-
483, _step_cos (1)
-
484, _step_sin (0)
-
485{
-
486 // Nothing
-
487}
-
488
-
489
+
479
+
480/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
481
+
482#include <cmath>
+
483
+
484namespace std { }
+
485
+
486
+
487
+
488namespace ffft
+
489{
490
-
491template <class T>
-
492void OscSinCos <T>::set_step (double angle_rad)
-
493{
-
494 using namespace std;
+
491
+
492
+
493/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
494
495
-
496 _step_cos = static_cast <DataType> (cos (angle_rad));
-
497 _step_sin = static_cast <DataType> (sin (angle_rad));
-
498}
-
499
-
500
-
501
-
502template <class T>
-
503typename OscSinCos <T>::DataType OscSinCos <T>::get_cos () const
-
504{
-
505 return (_pos_cos);
-
506}
+
496
+
497template <class T>
+
498OscSinCos <T>::OscSinCos ()
+
499: _pos_cos (1)
+
500, _pos_sin (0)
+
501, _step_cos (1)
+
502, _step_sin (0)
+
503{
+
504 // Nothing
+
505}
+
506
507
508
-
509
-
510template <class T>
-
511typename OscSinCos <T>::DataType OscSinCos <T>::get_sin () const
-
512{
-
513 return (_pos_sin);
-
514}
-
515
-
516
+
509template <class T>
+
510void OscSinCos <T>::set_step (double angle_rad)
+
511{
+
512 using namespace std;
+
513
+
514 _step_cos = static_cast <DataType> (cos (angle_rad));
+
515 _step_sin = static_cast <DataType> (sin (angle_rad));
+
516}
517
-
518template <class T>
-
519void OscSinCos <T>::step ()
-
520{
-
521 const DataType old_cos = _pos_cos;
-
522 const DataType old_sin = _pos_sin;
-
523
-
524 _pos_cos = old_cos * _step_cos - old_sin * _step_sin;
-
525 _pos_sin = old_cos * _step_sin + old_sin * _step_cos;
-
526}
+
518
+
519
+
520template <class T>
+
521typename OscSinCos <T>::DataType OscSinCos <T>::get_cos () const
+
522{
+
523 return (_pos_cos);
+
524}
+
525
+
526
527
-
528
-
529
-
530template <class T>
-
531void OscSinCos <T>::clear_buffers ()
-
532{
-
533 _pos_cos = static_cast <DataType> (1);
-
534 _pos_sin = static_cast <DataType> (0);
-
535}
-
536
-
537
-
538
-
539/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
540
+
528template <class T>
+
529typename OscSinCos <T>::DataType OscSinCos <T>::get_sin () const
+
530{
+
531 return (_pos_sin);
+
532}
+
533
+
534
+
535
+
536template <class T>
+
537void OscSinCos <T>::step ()
+
538{
+
539 const DataType old_cos = _pos_cos;
+
540 const DataType old_sin = _pos_sin;
541
-
542
-
543/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
544
+
542 _pos_cos = old_cos * _step_cos - old_sin * _step_sin;
+
543 _pos_sin = old_cos * _step_sin + old_sin * _step_cos;
+
544}
545
546
-
547} // namespace ffft
-
548
-
549
-
550
-
551#endif // ffft_OscSinCos_CODEHEADER_INCLUDED
-
552
-
553#undef ffft_OscSinCos_CURRENT_CODEHEADER
+
547
+
548template <class T>
+
549void OscSinCos <T>::clear_buffers ()
+
550{
+
551 _pos_cos = static_cast <DataType> (1);
+
552 _pos_sin = static_cast <DataType> (0);
+
553}
554
555
556
-
557/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
557/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
558
559
560
-
561
-
562#endif // ffft_OscSinCos_HEADER_INCLUDED
+
561/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
562
563
564
-
565
-
566/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
565} // namespace ffft
+
566
567
568
-
569
+
569#endif // ffft_OscSinCos_CODEHEADER_INCLUDED
570
-
571namespace ffft
-
572{
+
571#undef ffft_OscSinCos_CURRENT_CODEHEADER
+
572
573
574
-
575
-
576template <class DT>
-
- -
578{
+
575/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
576
+
577
+
578
579
-
580/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
580#endif // ffft_OscSinCos_HEADER_INCLUDED
581
-
582public:
+
582
583
-
584 enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int
+
584/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
585
-
586 typedef DT DataType;
+
586
587
-
588 explicit FFTReal (long length);
-
589 virtual ~FFTReal () {}
-
590
-
591 long get_length () const;
-
592 void do_fft (DataType f [], const DataType x []) const;
-
593 void do_ifft (const DataType f [], DataType x []) const;
-
594 void rescale (DataType x []) const;
-
595 DataType * use_buffer () const;
-
596
+
588
+
589namespace ffft
+
590{
+
591
+
592
+
593
+
594template <class DT>
+
+ +
596{
597
-
598
-
599/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
600
-
601protected:
-
602
+
598/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
599
+
600public:
+
601
+
602 enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int
603
-
604
-
605/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
606
-
607private:
+
604 typedef DT DataType;
+
605
+
606 explicit FFTReal (long length);
+
607 virtual ~FFTReal () {}
608
-
609 // Over this bit depth, we use direct calculation for sin/cos
-
610 enum { TRIGO_BD_LIMIT = 12 };
-
611
-
612 typedef OscSinCos <DataType> OscType;
-
613
-
614 void init_br_lut ();
-
615 void init_trigo_lut ();
-
616 void init_trigo_osc ();
-
617
-
618 ffft_FORCEINLINE const long *
-
619 get_br_ptr () const;
-
620 ffft_FORCEINLINE const DataType *
-
621 get_trigo_ptr (int level) const;
-
622 ffft_FORCEINLINE long
-
623 get_trigo_level_index (int level) const;
+
609 long get_length () const;
+
610 void do_fft (DataType f [], const DataType x []) const;
+
611 void do_ifft (const DataType f [], DataType x []) const;
+
612 void rescale (DataType x []) const;
+
613 DataType * use_buffer () const;
+
614
+
615
+
616
+
617/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
618
+
619protected:
+
620
+
621
+
622
+
623/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
624
-
625 inline void compute_fft_general (DataType f [], const DataType x []) const;
-
626 inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const;
-
627 inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const;
-
628 inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const;
-
629 inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const;
-
630 inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const;
+
625private:
+
626
+
627 // Over this bit depth, we use direct calculation for sin/cos
+
628 enum { TRIGO_BD_LIMIT = 12 };
+
629
+
630 typedef OscSinCos <DataType> OscType;
631
-
632 inline void compute_ifft_general (const DataType f [], DataType x []) const;
-
633 inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const;
-
634 inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const;
-
635 inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const;
-
636 inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const;
-
637 inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const;
-
638
-
639 const long _length;
-
640 const int _nbr_bits;
-
641 DynArray <long>
-
642 _br_lut;
-
643 DynArray <DataType>
-
644 _trigo_lut;
-
645 mutable DynArray <DataType>
-
646 _buffer;
-
647 mutable DynArray <OscType>
-
648 _trigo_osc;
+
632 void init_br_lut ();
+
633 void init_trigo_lut ();
+
634 void init_trigo_osc ();
+
635
+
636 ffft_FORCEINLINE const long *
+
637 get_br_ptr () const;
+
638 ffft_FORCEINLINE const DataType *
+
639 get_trigo_ptr (int level) const;
+
640 ffft_FORCEINLINE long
+
641 get_trigo_level_index (int level) const;
+
642
+
643 inline void compute_fft_general (DataType f [], const DataType x []) const;
+
644 inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const;
+
645 inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const;
+
646 inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const;
+
647 inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const;
+
648 inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const;
649
-
650
-
651
-
652/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
-
653
-
654private:
-
655
-
656 FFTReal ();
-
657 FFTReal (const FFTReal &other);
-
658 FFTReal & operator = (const FFTReal &other);
-
659 bool operator == (const FFTReal &other);
-
660 bool operator != (const FFTReal &other);
-
661
-
662}; // class FFTReal
-
-
663
-
664
-
665
-
666} // namespace ffft
+
650 inline void compute_ifft_general (const DataType f [], DataType x []) const;
+
651 inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const;
+
652 inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const;
+
653 inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const;
+
654 inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const;
+
655 inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const;
+
656
+
657 const long _length;
+
658 const int _nbr_bits;
+
659 DynArray <long>
+
660 _br_lut;
+
661 DynArray <DataType>
+
662 _trigo_lut;
+
663 mutable DynArray <DataType>
+
664 _buffer;
+
665 mutable DynArray <OscType>
+
666 _trigo_osc;
667
668
669
-
670/*****************************************************************************
-
671
-
672 FFTReal.hpp
-
673 By Laurent de Soras
-
674
-
675--- Legal stuff ---
-
676
-
677This program is free software. It comes without any warranty, to
-
678the extent permitted by applicable law. You can redistribute it
-
679and/or modify it under the terms of the Do What The Fuck You Want
-
680To Public License, Version 2, as published by Sam Hocevar. See
-
681http://sam.zoy.org/wtfpl/COPYING for more details.
-
682
-
683*Tab=3***********************************************************************/
-
684
+
670/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
671
+
672private:
+
673
+
674 FFTReal ();
+
675 FFTReal (const FFTReal &other);
+
676 FFTReal & operator = (const FFTReal &other);
+
677 bool operator == (const FFTReal &other);
+
678 bool operator != (const FFTReal &other);
+
679
+
680}; // class FFTReal
+
+
681
+
682
+
683
+
684} // namespace ffft
685
686
-
687#if defined (ffft_FFTReal_CURRENT_CODEHEADER)
-
688 #error Recursive inclusion of FFTReal code header.
-
689#endif
-
690#define ffft_FFTReal_CURRENT_CODEHEADER
-
691
-
692#if ! defined (ffft_FFTReal_CODEHEADER_INCLUDED)
-
693#define ffft_FFTReal_CODEHEADER_INCLUDED
-
694
-
695
-
696
-
697/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
698
-
699#include <cassert>
-
700#include <cmath>
-
701
+
687
+
688/*****************************************************************************
+
689
+
690 FFTReal.hpp
+
691 By Laurent de Soras
+
692
+
693--- Legal stuff ---
+
694
+
695This program is free software. It comes without any warranty, to
+
696the extent permitted by applicable law. You can redistribute it
+
697and/or modify it under the terms of the Do What The Fuck You Want
+
698To Public License, Version 2, as published by Sam Hocevar. See
+
699http://sam.zoy.org/wtfpl/COPYING for more details.
+
700
+
701*Tab=3***********************************************************************/
702
703
-
704namespace ffft
-
705{
-
706
-
707
-
708
-
709static inline bool FFTReal_is_pow2 (long x)
-
710{
-
711 assert (x > 0);
+
704
+
705#if defined (ffft_FFTReal_CURRENT_CODEHEADER)
+
706 #error Recursive inclusion of FFTReal code header.
+
707#endif
+
708#define ffft_FFTReal_CURRENT_CODEHEADER
+
709
+
710#if ! defined (ffft_FFTReal_CODEHEADER_INCLUDED)
+
711#define ffft_FFTReal_CODEHEADER_INCLUDED
712
-
713 return ((x & -x) == x);
-
714}
-
715
+
713
+
714
+
715/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
716
-
717
-
718static inline int FFTReal_get_next_pow2 (long x)
-
719{
-
720 --x;
+
717#include <cassert>
+
718#include <cmath>
+
719
+
720
721
-
722 int p = 0;
-
723 while ((x & ~0xFFFFL) != 0)
-
724 {
-
725 p += 16;
-
726 x >>= 16;
-
727 }
-
728 while ((x & ~0xFL) != 0)
-
729 {
-
730 p += 4;
-
731 x >>= 4;
-
732 }
-
733 while (x > 0)
-
734 {
-
735 ++p;
-
736 x >>= 1;
-
737 }
-
738
-
739 return (p);
-
740}
-
741
-
742
-
743
-
744/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
745
-
746
-
747
-
748/*
-
749==============================================================================
-
750Name: ctor
-
751Input parameters:
-
752 - length: length of the array on which we want to do a FFT. Range: power of
-
753 2 only, > 0.
-
754Throws: std::bad_alloc
-
755==============================================================================
-
756*/
-
757
-
758template <class DT>
-
759FFTReal <DT>::FFTReal (long length)
-
760: _length (length)
-
761, _nbr_bits (FFTReal_get_next_pow2 (length))
-
762, _br_lut ()
-
763, _trigo_lut ()
-
764, _buffer (length)
-
765, _trigo_osc ()
-
766{
-
767 assert (FFTReal_is_pow2 (length));
-
768 assert (_nbr_bits <= MAX_BIT_DEPTH);
-
769
-
770 init_br_lut ();
-
771 init_trigo_lut ();
-
772 init_trigo_osc ();
-
773}
-
774
+
722namespace ffft
+
723{
+
724
+
725
+
726
+
727static inline bool FFTReal_is_pow2 (long x)
+
728{
+
729 assert (x > 0);
+
730
+
731 return ((x & -x) == x);
+
732}
+
733
+
734
+
735
+
736static inline int FFTReal_get_next_pow2 (long x)
+
737{
+
738 --x;
+
739
+
740 int p = 0;
+
741 while ((x & ~0xFFFFL) != 0)
+
742 {
+
743 p += 16;
+
744 x >>= 16;
+
745 }
+
746 while ((x & ~0xFL) != 0)
+
747 {
+
748 p += 4;
+
749 x >>= 4;
+
750 }
+
751 while (x > 0)
+
752 {
+
753 ++p;
+
754 x >>= 1;
+
755 }
+
756
+
757 return (p);
+
758}
+
759
+
760
+
761
+
762/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
763
+
764
+
765
+
766/*
+
767==============================================================================
+
768Name: ctor
+
769Input parameters:
+
770 - length: length of the array on which we want to do a FFT. Range: power of
+
771 2 only, > 0.
+
772Throws: std::bad_alloc
+
773==============================================================================
+
774*/
775
-
776
-
777/*
-
778==============================================================================
-
779Name: get_length
-
780Description:
-
781 Returns the number of points processed by this FFT object.
-
782Returns: The number of points, power of 2, > 0.
-
783Throws: Nothing
-
784==============================================================================
-
785*/
-
786
-
787template <class DT>
-
788long FFTReal <DT>::get_length () const
-
789{
-
790 return (_length);
+
776template <class DT>
+
777FFTReal <DT>::FFTReal (long length)
+
778: _length (length)
+
779, _nbr_bits (FFTReal_get_next_pow2 (length))
+
780, _br_lut ()
+
781, _trigo_lut ()
+
782, _buffer (length)
+
783, _trigo_osc ()
+
784{
+
785 assert (FFTReal_is_pow2 (length));
+
786 assert (_nbr_bits <= MAX_BIT_DEPTH);
+
787
+
788 init_br_lut ();
+
789 init_trigo_lut ();
+
790 init_trigo_osc ();
791}
792
793
794
795/*
796==============================================================================
-
797Name: do_fft
+
797Name: get_length
798Description:
-
799 Compute the FFT of the array.
-
800Input parameters:
-
801 - x: pointer on the source array (time).
-
802Output parameters:
-
803 - f: pointer on the destination array (frequencies).
-
804 f [0...length(x)/2] = real values,
-
805 f [length(x)/2+1...length(x)-1] = negative imaginary values of
-
806 coefficents 1...length(x)/2-1.
-
807Throws: Nothing
-
808==============================================================================
-
809*/
+
799 Returns the number of points processed by this FFT object.
+
800Returns: The number of points, power of 2, > 0.
+
801Throws: Nothing
+
802==============================================================================
+
803*/
+
804
+
805template <class DT>
+
806long FFTReal <DT>::get_length () const
+
807{
+
808 return (_length);
+
809}
810
-
811template <class DT>
-
812void FFTReal <DT>::do_fft (DataType f [], const DataType x []) const
-
813{
-
814 assert (f != 0);
-
815 assert (f != use_buffer ());
-
816 assert (x != 0);
-
817 assert (x != use_buffer ());
-
818 assert (x != f);
-
819
-
820 // General case
-
821 if (_nbr_bits > 2)
-
822 {
-
823 compute_fft_general (f, x);
-
824 }
-
825
-
826 // 4-point FFT
-
827 else if (_nbr_bits == 2)
-
828 {
-
829 f [1] = x [0] - x [2];
-
830 f [3] = x [1] - x [3];
-
831
-
832 const DataType b_0 = x [0] + x [2];
-
833 const DataType b_2 = x [1] + x [3];
-
834
-
835 f [0] = b_0 + b_2;
-
836 f [2] = b_0 - b_2;
-
837 }
-
838
-
839 // 2-point FFT
-
840 else if (_nbr_bits == 1)
-
841 {
-
842 f [0] = x [0] + x [1];
-
843 f [1] = x [0] - x [1];
-
844 }
-
845
-
846 // 1-point FFT
-
847 else
-
848 {
-
849 f [0] = x [0];
-
850 }
-
851}
-
852
-
853
-
854
-
855/*
-
856==============================================================================
-
857Name: do_ifft
-
858Description:
-
859 Compute the inverse FFT of the array. Note that data must be post-scaled:
-
860 IFFT (FFT (x)) = x * length (x).
-
861Input parameters:
-
862 - f: pointer on the source array (frequencies).
-
863 f [0...length(x)/2] = real values
-
864 f [length(x)/2+1...length(x)-1] = negative imaginary values of
-
865 coefficents 1...length(x)/2-1.
-
866Output parameters:
-
867 - x: pointer on the destination array (time).
-
868Throws: Nothing
-
869==============================================================================
-
870*/
+
811
+
812
+
813/*
+
814==============================================================================
+
815Name: do_fft
+
816Description:
+
817 Compute the FFT of the array.
+
818Input parameters:
+
819 - x: pointer on the source array (time).
+
820Output parameters:
+
821 - f: pointer on the destination array (frequencies).
+
822 f [0...length(x)/2] = real values,
+
823 f [length(x)/2+1...length(x)-1] = negative imaginary values of
+
824 coefficents 1...length(x)/2-1.
+
825Throws: Nothing
+
826==============================================================================
+
827*/
+
828
+
829template <class DT>
+
830void FFTReal <DT>::do_fft (DataType f [], const DataType x []) const
+
831{
+
832 assert (f != 0);
+
833 assert (f != use_buffer ());
+
834 assert (x != 0);
+
835 assert (x != use_buffer ());
+
836 assert (x != f);
+
837
+
838 // General case
+
839 if (_nbr_bits > 2)
+
840 {
+
841 compute_fft_general (f, x);
+
842 }
+
843
+
844 // 4-point FFT
+
845 else if (_nbr_bits == 2)
+
846 {
+
847 f [1] = x [0] - x [2];
+
848 f [3] = x [1] - x [3];
+
849
+
850 const DataType b_0 = x [0] + x [2];
+
851 const DataType b_2 = x [1] + x [3];
+
852
+
853 f [0] = b_0 + b_2;
+
854 f [2] = b_0 - b_2;
+
855 }
+
856
+
857 // 2-point FFT
+
858 else if (_nbr_bits == 1)
+
859 {
+
860 f [0] = x [0] + x [1];
+
861 f [1] = x [0] - x [1];
+
862 }
+
863
+
864 // 1-point FFT
+
865 else
+
866 {
+
867 f [0] = x [0];
+
868 }
+
869}
+
870
871
-
872template <class DT>
-
873void FFTReal <DT>::do_ifft (const DataType f [], DataType x []) const
-
874{
-
875 assert (f != 0);
-
876 assert (f != use_buffer ());
-
877 assert (x != 0);
-
878 assert (x != use_buffer ());
-
879 assert (x != f);
-
880
-
881 // General case
-
882 if (_nbr_bits > 2)
-
883 {
-
884 compute_ifft_general (f, x);
-
885 }
-
886
-
887 // 4-point IFFT
-
888 else if (_nbr_bits == 2)
-
889 {
-
890 const DataType b_0 = f [0] + f [2];
-
891 const DataType b_2 = f [0] - f [2];
-
892
-
893 x [0] = b_0 + f [1] * 2;
-
894 x [2] = b_0 - f [1] * 2;
-
895 x [1] = b_2 + f [3] * 2;
-
896 x [3] = b_2 - f [3] * 2;
-
897 }
+
872
+
873/*
+
874==============================================================================
+
875Name: do_ifft
+
876Description:
+
877 Compute the inverse FFT of the array. Note that data must be post-scaled:
+
878 IFFT (FFT (x)) = x * length (x).
+
879Input parameters:
+
880 - f: pointer on the source array (frequencies).
+
881 f [0...length(x)/2] = real values
+
882 f [length(x)/2+1...length(x)-1] = negative imaginary values of
+
883 coefficents 1...length(x)/2-1.
+
884Output parameters:
+
885 - x: pointer on the destination array (time).
+
886Throws: Nothing
+
887==============================================================================
+
888*/
+
889
+
890template <class DT>
+
891void FFTReal <DT>::do_ifft (const DataType f [], DataType x []) const
+
892{
+
893 assert (f != 0);
+
894 assert (f != use_buffer ());
+
895 assert (x != 0);
+
896 assert (x != use_buffer ());
+
897 assert (x != f);
898
-
899 // 2-point IFFT
-
900 else if (_nbr_bits == 1)
+
899 // General case
+
900 if (_nbr_bits > 2)
901 {
-
902 x [0] = f [0] + f [1];
-
903 x [1] = f [0] - f [1];
-
904 }
-
905
-
906 // 1-point IFFT
-
907 else
-
908 {
-
909 x [0] = f [0];
-
910 }
-
911}
-
912
-
913
-
914
-
915/*
-
916==============================================================================
-
917Name: rescale
-
918Description:
-
919 Scale an array by divide each element by its length. This function should
-
920 be called after FFT + IFFT.
-
921Input parameters:
-
922 - x: pointer on array to rescale (time or frequency).
-
923Throws: Nothing
-
924==============================================================================
-
925*/
-
926
-
927template <class DT>
-
928void FFTReal <DT>::rescale (DataType x []) const
-
929{
-
930 const DataType mul = DataType (1.0 / _length);
+
902 compute_ifft_general (f, x);
+
903 }
+
904
+
905 // 4-point IFFT
+
906 else if (_nbr_bits == 2)
+
907 {
+
908 const DataType b_0 = f [0] + f [2];
+
909 const DataType b_2 = f [0] - f [2];
+
910
+
911 x [0] = b_0 + f [1] * 2;
+
912 x [2] = b_0 - f [1] * 2;
+
913 x [1] = b_2 + f [3] * 2;
+
914 x [3] = b_2 - f [3] * 2;
+
915 }
+
916
+
917 // 2-point IFFT
+
918 else if (_nbr_bits == 1)
+
919 {
+
920 x [0] = f [0] + f [1];
+
921 x [1] = f [0] - f [1];
+
922 }
+
923
+
924 // 1-point IFFT
+
925 else
+
926 {
+
927 x [0] = f [0];
+
928 }
+
929}
+
930
931
-
932 if (_length < 4)
-
933 {
-
934 long i = _length - 1;
-
935 do
-
936 {
-
937 x [i] *= mul;
-
938 --i;
-
939 }
-
940 while (i >= 0);
-
941 }
-
942
-
943 else
-
944 {
-
945 assert ((_length & 3) == 0);
-
946
-
947 // Could be optimized with SIMD instruction sets (needs alignment check)
-
948 long i = _length - 4;
-
949 do
-
950 {
-
951 x [i + 0] *= mul;
-
952 x [i + 1] *= mul;
-
953 x [i + 2] *= mul;
-
954 x [i + 3] *= mul;
-
955 i -= 4;
-
956 }
-
957 while (i >= 0);
-
958 }
-
959}
+
932
+
933/*
+
934==============================================================================
+
935Name: rescale
+
936Description:
+
937 Scale an array by divide each element by its length. This function should
+
938 be called after FFT + IFFT.
+
939Input parameters:
+
940 - x: pointer on array to rescale (time or frequency).
+
941Throws: Nothing
+
942==============================================================================
+
943*/
+
944
+
945template <class DT>
+
946void FFTReal <DT>::rescale (DataType x []) const
+
947{
+
948 const DataType mul = DataType (1.0 / _length);
+
949
+
950 if (_length < 4)
+
951 {
+
952 long i = _length - 1;
+
953 do
+
954 {
+
955 x [i] *= mul;
+
956 --i;
+
957 }
+
958 while (i >= 0);
+
959 }
960
-
961
-
962
-
963/*
-
964==============================================================================
-
965Name: use_buffer
-
966Description:
-
967 Access the internal buffer, whose length is the FFT one.
-
968 Buffer content will be erased at each do_fft() / do_ifft() call!
-
969 This buffer cannot be used as:
-
970 - source for FFT or IFFT done with this object
-
971 - destination for FFT or IFFT done with this object
-
972Returns:
-
973 Buffer start address
-
974Throws: Nothing
-
975==============================================================================
-
976*/
-
977
-
978template <class DT>
-
979typename FFTReal <DT>::DataType * FFTReal <DT>::use_buffer () const
-
980{
-
981 return (&_buffer [0]);
-
982}
-
983
-
984
-
985
-
986/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
987
-
988
-
989
-
990/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
991
-
992
-
993
-
994template <class DT>
-
995void FFTReal <DT>::init_br_lut ()
-
996{
-
997 const long length = 1L << _nbr_bits;
-
998 _br_lut.resize (length);
-
999
-
1000 _br_lut [0] = 0;
-
1001 long br_index = 0;
-
1002 for (long cnt = 1; cnt < length; ++cnt)
-
1003 {
-
1004 // ++br_index (bit reversed)
-
1005 long bit = length >> 1;
-
1006 while (((br_index ^= bit) & bit) == 0)
-
1007 {
-
1008 bit >>= 1;
-
1009 }
+
961 else
+
962 {
+
963 assert ((_length & 3) == 0);
+
964
+
965 // Could be optimized with SIMD instruction sets (needs alignment check)
+
966 long i = _length - 4;
+
967 do
+
968 {
+
969 x [i + 0] *= mul;
+
970 x [i + 1] *= mul;
+
971 x [i + 2] *= mul;
+
972 x [i + 3] *= mul;
+
973 i -= 4;
+
974 }
+
975 while (i >= 0);
+
976 }
+
977}
+
978
+
979
+
980
+
981/*
+
982==============================================================================
+
983Name: use_buffer
+
984Description:
+
985 Access the internal buffer, whose length is the FFT one.
+
986 Buffer content will be erased at each do_fft() / do_ifft() call!
+
987 This buffer cannot be used as:
+
988 - source for FFT or IFFT done with this object
+
989 - destination for FFT or IFFT done with this object
+
990Returns:
+
991 Buffer start address
+
992Throws: Nothing
+
993==============================================================================
+
994*/
+
995
+
996template <class DT>
+
997typename FFTReal <DT>::DataType * FFTReal <DT>::use_buffer () const
+
998{
+
999 return (&_buffer [0]);
+
1000}
+
1001
+
1002
+
1003
+
1004/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1005
+
1006
+
1007
+
1008/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1009
1010
-
1011 _br_lut [cnt] = br_index;
-
1012 }
-
1013}
-
1014
-
1015
-
1016
-
1017template <class DT>
-
1018void FFTReal <DT>::init_trigo_lut ()
-
1019{
-
1020 using namespace std;
-
1021
-
1022 if (_nbr_bits > 3)
-
1023 {
-
1024 const long total_len = (1L << (_nbr_bits - 1)) - 4;
-
1025 _trigo_lut.resize (total_len);
-
1026
-
1027 for (int level = 3; level < _nbr_bits; ++level)
-
1028 {
-
1029 const long level_len = 1L << (level - 1);
-
1030 DataType * const level_ptr =
-
1031 &_trigo_lut [get_trigo_level_index (level)];
-
1032 const double mul = PI / (level_len << 1);
+
1011
+
1012template <class DT>
+
1013void FFTReal <DT>::init_br_lut ()
+
1014{
+
1015 const long length = 1L << _nbr_bits;
+
1016 _br_lut.resize (length);
+
1017
+
1018 _br_lut [0] = 0;
+
1019 long br_index = 0;
+
1020 for (long cnt = 1; cnt < length; ++cnt)
+
1021 {
+
1022 // ++br_index (bit reversed)
+
1023 long bit = length >> 1;
+
1024 while (((br_index ^= bit) & bit) == 0)
+
1025 {
+
1026 bit >>= 1;
+
1027 }
+
1028
+
1029 _br_lut [cnt] = br_index;
+
1030 }
+
1031}
+
1032
1033
-
1034 for (long i = 0; i < level_len; ++ i)
-
1035 {
-
1036 level_ptr [i] = static_cast <DataType> (cos (i * mul));
-
1037 }
-
1038 }
-
1039 }
-
1040}
-
1041
-
1042
-
1043
-
1044template <class DT>
-
1045void FFTReal <DT>::init_trigo_osc ()
-
1046{
-
1047 const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT;
-
1048 if (nbr_osc > 0)
-
1049 {
-
1050 _trigo_osc.resize (nbr_osc);
+
1034
+
1035template <class DT>
+
1036void FFTReal <DT>::init_trigo_lut ()
+
1037{
+
1038 using namespace std;
+
1039
+
1040 if (_nbr_bits > 3)
+
1041 {
+
1042 const long total_len = (1L << (_nbr_bits - 1)) - 4;
+
1043 _trigo_lut.resize (total_len);
+
1044
+
1045 for (int level = 3; level < _nbr_bits; ++level)
+
1046 {
+
1047 const long level_len = 1L << (level - 1);
+
1048 DataType * const level_ptr =
+
1049 &_trigo_lut [get_trigo_level_index (level)];
+
1050 const double mul = PI / (level_len << 1);
1051
-
1052 for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt)
-
1053 {
-
1054 OscType & osc = _trigo_osc [osc_cnt];
-
1055
-
1056 const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt);
-
1057 const double mul = (0.5 * PI) / len;
-
1058 osc.set_step (mul);
-
1059 }
-
1060 }
-
1061}
-
1062
-
1063
-
1064
-
1065template <class DT>
-
1066const long * FFTReal <DT>::get_br_ptr () const
-
1067{
-
1068 return (&_br_lut [0]);
-
1069}
-
1070
-
1071
-
1072
-
1073template <class DT>
-
1074const typename FFTReal <DT>::DataType * FFTReal <DT>::get_trigo_ptr (int level) const
-
1075{
-
1076 assert (level >= 3);
-
1077
-
1078 return (&_trigo_lut [get_trigo_level_index (level)]);
+
1052 for (long i = 0; i < level_len; ++ i)
+
1053 {
+
1054 level_ptr [i] = static_cast <DataType> (cos (i * mul));
+
1055 }
+
1056 }
+
1057 }
+
1058}
+
1059
+
1060
+
1061
+
1062template <class DT>
+
1063void FFTReal <DT>::init_trigo_osc ()
+
1064{
+
1065 const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT;
+
1066 if (nbr_osc > 0)
+
1067 {
+
1068 _trigo_osc.resize (nbr_osc);
+
1069
+
1070 for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt)
+
1071 {
+
1072 OscType & osc = _trigo_osc [osc_cnt];
+
1073
+
1074 const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt);
+
1075 const double mul = (0.5 * PI) / len;
+
1076 osc.set_step (mul);
+
1077 }
+
1078 }
1079}
1080
1081
1082
1083template <class DT>
-
1084long FFTReal <DT>::get_trigo_level_index (int level) const
+
1084const long * FFTReal <DT>::get_br_ptr () const
1085{
-
1086 assert (level >= 3);
-
1087
-
1088 return ((1L << (level - 1)) - 4);
-
1089}
+
1086 return (&_br_lut [0]);
+
1087}
+
1088
+
1089
1090
-
1091
-
1092
-
1093// Transform in several passes
-
1094template <class DT>
-
1095void FFTReal <DT>::compute_fft_general (DataType f [], const DataType x []) const
-
1096{
-
1097 assert (f != 0);
-
1098 assert (f != use_buffer ());
-
1099 assert (x != 0);
-
1100 assert (x != use_buffer ());
-
1101 assert (x != f);
-
1102
-
1103 DataType * sf;
-
1104 DataType * df;
+
1091template <class DT>
+
1092const typename FFTReal <DT>::DataType * FFTReal <DT>::get_trigo_ptr (int level) const
+
1093{
+
1094 assert (level >= 3);
+
1095
+
1096 return (&_trigo_lut [get_trigo_level_index (level)]);
+
1097}
+
1098
+
1099
+
1100
+
1101template <class DT>
+
1102long FFTReal <DT>::get_trigo_level_index (int level) const
+
1103{
+
1104 assert (level >= 3);
1105
-
1106 if ((_nbr_bits & 1) != 0)
-
1107 {
-
1108 df = use_buffer ();
-
1109 sf = f;
-
1110 }
-
1111 else
-
1112 {
-
1113 df = f;
-
1114 sf = use_buffer ();
-
1115 }
-
1116
-
1117 compute_direct_pass_1_2 (df, x);
-
1118 compute_direct_pass_3 (sf, df);
-
1119
-
1120 for (int pass = 3; pass < _nbr_bits; ++ pass)
-
1121 {
-
1122 compute_direct_pass_n (df, sf, pass);
+
1106 return ((1L << (level - 1)) - 4);
+
1107}
+
1108
+
1109
+
1110
+
1111// Transform in several passes
+
1112template <class DT>
+
1113void FFTReal <DT>::compute_fft_general (DataType f [], const DataType x []) const
+
1114{
+
1115 assert (f != 0);
+
1116 assert (f != use_buffer ());
+
1117 assert (x != 0);
+
1118 assert (x != use_buffer ());
+
1119 assert (x != f);
+
1120
+
1121 DataType * sf;
+
1122 DataType * df;
1123
-
1124 DataType * const temp_ptr = df;
-
1125 df = sf;
-
1126 sf = temp_ptr;
-
1127 }
-
1128}
-
1129
-
1130
-
1131
-
1132template <class DT>
-
1133void FFTReal <DT>::compute_direct_pass_1_2 (DataType df [], const DataType x []) const
-
1134{
-
1135 assert (df != 0);
-
1136 assert (x != 0);
-
1137 assert (df != x);
-
1138
-
1139 const long * const bit_rev_lut_ptr = get_br_ptr ();
-
1140 long coef_index = 0;
-
1141 do
-
1142 {
-
1143 const long rev_index_0 = bit_rev_lut_ptr [coef_index];
-
1144 const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1];
-
1145 const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2];
-
1146 const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3];
+
1124 if ((_nbr_bits & 1) != 0)
+
1125 {
+
1126 df = use_buffer ();
+
1127 sf = f;
+
1128 }
+
1129 else
+
1130 {
+
1131 df = f;
+
1132 sf = use_buffer ();
+
1133 }
+
1134
+
1135 compute_direct_pass_1_2 (df, x);
+
1136 compute_direct_pass_3 (sf, df);
+
1137
+
1138 for (int pass = 3; pass < _nbr_bits; ++ pass)
+
1139 {
+
1140 compute_direct_pass_n (df, sf, pass);
+
1141
+
1142 DataType * const temp_ptr = df;
+
1143 df = sf;
+
1144 sf = temp_ptr;
+
1145 }
+
1146}
1147
-
1148 DataType * const df2 = df + coef_index;
-
1149 df2 [1] = x [rev_index_0] - x [rev_index_1];
-
1150 df2 [3] = x [rev_index_2] - x [rev_index_3];
-
1151
-
1152 const DataType sf_0 = x [rev_index_0] + x [rev_index_1];
-
1153 const DataType sf_2 = x [rev_index_2] + x [rev_index_3];
-
1154
-
1155 df2 [0] = sf_0 + sf_2;
-
1156 df2 [2] = sf_0 - sf_2;
-
1157
-
1158 coef_index += 4;
-
1159 }
-
1160 while (coef_index < _length);
-
1161}
-
1162
-
1163
-
1164
-
1165template <class DT>
-
1166void FFTReal <DT>::compute_direct_pass_3 (DataType df [], const DataType sf []) const
-
1167{
-
1168 assert (df != 0);
-
1169 assert (sf != 0);
-
1170 assert (df != sf);
-
1171
-
1172 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
-
1173 long coef_index = 0;
-
1174 do
-
1175 {
-
1176 DataType v;
-
1177
-
1178 df [coef_index] = sf [coef_index] + sf [coef_index + 4];
-
1179 df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4];
-
1180 df [coef_index + 2] = sf [coef_index + 2];
-
1181 df [coef_index + 6] = sf [coef_index + 6];
+
1148
+
1149
+
1150template <class DT>
+
1151void FFTReal <DT>::compute_direct_pass_1_2 (DataType df [], const DataType x []) const
+
1152{
+
1153 assert (df != 0);
+
1154 assert (x != 0);
+
1155 assert (df != x);
+
1156
+
1157 const long * const bit_rev_lut_ptr = get_br_ptr ();
+
1158 long coef_index = 0;
+
1159 do
+
1160 {
+
1161 const long rev_index_0 = bit_rev_lut_ptr [coef_index];
+
1162 const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1];
+
1163 const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2];
+
1164 const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3];
+
1165
+
1166 DataType * const df2 = df + coef_index;
+
1167 df2 [1] = x [rev_index_0] - x [rev_index_1];
+
1168 df2 [3] = x [rev_index_2] - x [rev_index_3];
+
1169
+
1170 const DataType sf_0 = x [rev_index_0] + x [rev_index_1];
+
1171 const DataType sf_2 = x [rev_index_2] + x [rev_index_3];
+
1172
+
1173 df2 [0] = sf_0 + sf_2;
+
1174 df2 [2] = sf_0 - sf_2;
+
1175
+
1176 coef_index += 4;
+
1177 }
+
1178 while (coef_index < _length);
+
1179}
+
1180
+
1181
1182
-
1183 v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2;
-
1184 df [coef_index + 1] = sf [coef_index + 1] + v;
-
1185 df [coef_index + 3] = sf [coef_index + 1] - v;
-
1186
-
1187 v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2;
-
1188 df [coef_index + 5] = v + sf [coef_index + 3];
-
1189 df [coef_index + 7] = v - sf [coef_index + 3];
-
1190
-
1191 coef_index += 8;
-
1192 }
-
1193 while (coef_index < _length);
-
1194}
+
1183template <class DT>
+
1184void FFTReal <DT>::compute_direct_pass_3 (DataType df [], const DataType sf []) const
+
1185{
+
1186 assert (df != 0);
+
1187 assert (sf != 0);
+
1188 assert (df != sf);
+
1189
+
1190 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
+
1191 long coef_index = 0;
+
1192 do
+
1193 {
+
1194 DataType v;
1195
-
1196
-
1197
-
1198template <class DT>
-
1199void FFTReal <DT>::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const
-
1200{
-
1201 assert (df != 0);
-
1202 assert (sf != 0);
-
1203 assert (df != sf);
-
1204 assert (pass >= 3);
-
1205 assert (pass < _nbr_bits);
-
1206
-
1207 if (pass <= TRIGO_BD_LIMIT)
-
1208 {
-
1209 compute_direct_pass_n_lut (df, sf, pass);
+
1196 df [coef_index] = sf [coef_index] + sf [coef_index + 4];
+
1197 df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4];
+
1198 df [coef_index + 2] = sf [coef_index + 2];
+
1199 df [coef_index + 6] = sf [coef_index + 6];
+
1200
+
1201 v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2;
+
1202 df [coef_index + 1] = sf [coef_index + 1] + v;
+
1203 df [coef_index + 3] = sf [coef_index + 1] - v;
+
1204
+
1205 v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2;
+
1206 df [coef_index + 5] = v + sf [coef_index + 3];
+
1207 df [coef_index + 7] = v - sf [coef_index + 3];
+
1208
+
1209 coef_index += 8;
1210 }
-
1211 else
-
1212 {
-
1213 compute_direct_pass_n_osc (df, sf, pass);
-
1214 }
-
1215}
-
1216
-
1217
-
1218
-
1219template <class DT>
-
1220void FFTReal <DT>::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const
-
1221{
-
1222 assert (df != 0);
-
1223 assert (sf != 0);
-
1224 assert (df != sf);
-
1225 assert (pass >= 3);
-
1226 assert (pass < _nbr_bits);
-
1227
-
1228 const long nbr_coef = 1 << pass;
-
1229 const long h_nbr_coef = nbr_coef >> 1;
-
1230 const long d_nbr_coef = nbr_coef << 1;
-
1231 long coef_index = 0;
-
1232 const DataType * const cos_ptr = get_trigo_ptr (pass);
-
1233 do
-
1234 {
-
1235 const DataType * const sf1r = sf + coef_index;
-
1236 const DataType * const sf2r = sf1r + nbr_coef;
-
1237 DataType * const dfr = df + coef_index;
-
1238 DataType * const dfi = dfr + nbr_coef;
-
1239
-
1240 // Extreme coefficients are always real
-
1241 dfr [0] = sf1r [0] + sf2r [0];
-
1242 dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] =
-
1243 dfr [h_nbr_coef] = sf1r [h_nbr_coef];
-
1244 dfi [h_nbr_coef] = sf2r [h_nbr_coef];
+
1211 while (coef_index < _length);
+
1212}
+
1213
+
1214
+
1215
+
1216template <class DT>
+
1217void FFTReal <DT>::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const
+
1218{
+
1219 assert (df != 0);
+
1220 assert (sf != 0);
+
1221 assert (df != sf);
+
1222 assert (pass >= 3);
+
1223 assert (pass < _nbr_bits);
+
1224
+
1225 if (pass <= TRIGO_BD_LIMIT)
+
1226 {
+
1227 compute_direct_pass_n_lut (df, sf, pass);
+
1228 }
+
1229 else
+
1230 {
+
1231 compute_direct_pass_n_osc (df, sf, pass);
+
1232 }
+
1233}
+
1234
+
1235
+
1236
+
1237template <class DT>
+
1238void FFTReal <DT>::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const
+
1239{
+
1240 assert (df != 0);
+
1241 assert (sf != 0);
+
1242 assert (df != sf);
+
1243 assert (pass >= 3);
+
1244 assert (pass < _nbr_bits);
1245
-
1246 // Others are conjugate complex numbers
-
1247 const DataType * const sf1i = sf1r + h_nbr_coef;
-
1248 const DataType * const sf2i = sf1i + nbr_coef;
-
1249 for (long i = 1; i < h_nbr_coef; ++ i)
-
1250 {
-
1251 const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef);
-
1252 const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef);
-
1253 DataType v;
-
1254
-
1255 v = sf2r [i] * c - sf2i [i] * s;
-
1256 dfr [i] = sf1r [i] + v;
-
1257 dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] =
-
1258
-
1259 v = sf2r [i] * s + sf2i [i] * c;
-
1260 dfi [i] = v + sf1i [i];
-
1261 dfi [nbr_coef - i] = v - sf1i [i];
-
1262 }
+
1246 const long nbr_coef = 1 << pass;
+
1247 const long h_nbr_coef = nbr_coef >> 1;
+
1248 const long d_nbr_coef = nbr_coef << 1;
+
1249 long coef_index = 0;
+
1250 const DataType * const cos_ptr = get_trigo_ptr (pass);
+
1251 do
+
1252 {
+
1253 const DataType * const sf1r = sf + coef_index;
+
1254 const DataType * const sf2r = sf1r + nbr_coef;
+
1255 DataType * const dfr = df + coef_index;
+
1256 DataType * const dfi = dfr + nbr_coef;
+
1257
+
1258 // Extreme coefficients are always real
+
1259 dfr [0] = sf1r [0] + sf2r [0];
+
1260 dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] =
+
1261 dfr [h_nbr_coef] = sf1r [h_nbr_coef];
+
1262 dfi [h_nbr_coef] = sf2r [h_nbr_coef];
1263
-
1264 coef_index += d_nbr_coef;
-
1265 }
-
1266 while (coef_index < _length);
-
1267}
-
1268
-
1269
-
1270
-
1271template <class DT>
-
1272void FFTReal <DT>::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const
-
1273{
-
1274 assert (df != 0);
-
1275 assert (sf != 0);
-
1276 assert (df != sf);
-
1277 assert (pass > TRIGO_BD_LIMIT);
-
1278 assert (pass < _nbr_bits);
-
1279
-
1280 const long nbr_coef = 1 << pass;
-
1281 const long h_nbr_coef = nbr_coef >> 1;
-
1282 const long d_nbr_coef = nbr_coef << 1;
-
1283 long coef_index = 0;
-
1284 OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)];
-
1285 do
-
1286 {
-
1287 const DataType * const sf1r = sf + coef_index;
-
1288 const DataType * const sf2r = sf1r + nbr_coef;
-
1289 DataType * const dfr = df + coef_index;
-
1290 DataType * const dfi = dfr + nbr_coef;
-
1291
-
1292 osc.clear_buffers ();
-
1293
-
1294 // Extreme coefficients are always real
-
1295 dfr [0] = sf1r [0] + sf2r [0];
-
1296 dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] =
-
1297 dfr [h_nbr_coef] = sf1r [h_nbr_coef];
-
1298 dfi [h_nbr_coef] = sf2r [h_nbr_coef];
-
1299
-
1300 // Others are conjugate complex numbers
-
1301 const DataType * const sf1i = sf1r + h_nbr_coef;
-
1302 const DataType * const sf2i = sf1i + nbr_coef;
-
1303 for (long i = 1; i < h_nbr_coef; ++ i)
-
1304 {
-
1305 osc.step ();
-
1306 const DataType c = osc.get_cos ();
-
1307 const DataType s = osc.get_sin ();
-
1308 DataType v;
+
1264 // Others are conjugate complex numbers
+
1265 const DataType * const sf1i = sf1r + h_nbr_coef;
+
1266 const DataType * const sf2i = sf1i + nbr_coef;
+
1267 for (long i = 1; i < h_nbr_coef; ++ i)
+
1268 {
+
1269 const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef);
+
1270 const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef);
+
1271 DataType v;
+
1272
+
1273 v = sf2r [i] * c - sf2i [i] * s;
+
1274 dfr [i] = sf1r [i] + v;
+
1275 dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] =
+
1276
+
1277 v = sf2r [i] * s + sf2i [i] * c;
+
1278 dfi [i] = v + sf1i [i];
+
1279 dfi [nbr_coef - i] = v - sf1i [i];
+
1280 }
+
1281
+
1282 coef_index += d_nbr_coef;
+
1283 }
+
1284 while (coef_index < _length);
+
1285}
+
1286
+
1287
+
1288
+
1289template <class DT>
+
1290void FFTReal <DT>::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const
+
1291{
+
1292 assert (df != 0);
+
1293 assert (sf != 0);
+
1294 assert (df != sf);
+
1295 assert (pass > TRIGO_BD_LIMIT);
+
1296 assert (pass < _nbr_bits);
+
1297
+
1298 const long nbr_coef = 1 << pass;
+
1299 const long h_nbr_coef = nbr_coef >> 1;
+
1300 const long d_nbr_coef = nbr_coef << 1;
+
1301 long coef_index = 0;
+
1302 OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)];
+
1303 do
+
1304 {
+
1305 const DataType * const sf1r = sf + coef_index;
+
1306 const DataType * const sf2r = sf1r + nbr_coef;
+
1307 DataType * const dfr = df + coef_index;
+
1308 DataType * const dfi = dfr + nbr_coef;
1309
-
1310 v = sf2r [i] * c - sf2i [i] * s;
-
1311 dfr [i] = sf1r [i] + v;
-
1312 dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] =
-
1313
-
1314 v = sf2r [i] * s + sf2i [i] * c;
-
1315 dfi [i] = v + sf1i [i];
-
1316 dfi [nbr_coef - i] = v - sf1i [i];
-
1317 }
-
1318
-
1319 coef_index += d_nbr_coef;
-
1320 }
-
1321 while (coef_index < _length);
-
1322}
-
1323
-
1324
-
1325
-
1326// Transform in several pass
-
1327template <class DT>
-
1328void FFTReal <DT>::compute_ifft_general (const DataType f [], DataType x []) const
-
1329{
-
1330 assert (f != 0);
-
1331 assert (f != use_buffer ());
-
1332 assert (x != 0);
-
1333 assert (x != use_buffer ());
-
1334 assert (x != f);
-
1335
-
1336 DataType * sf = const_cast <DataType *> (f);
-
1337 DataType * df;
-
1338 DataType * df_temp;
-
1339
-
1340 if (_nbr_bits & 1)
-
1341 {
-
1342 df = use_buffer ();
-
1343 df_temp = x;
-
1344 }
-
1345 else
-
1346 {
-
1347 df = x;
-
1348 df_temp = use_buffer ();
-
1349 }
-
1350
-
1351 for (int pass = _nbr_bits - 1; pass >= 3; -- pass)
-
1352 {
-
1353 compute_inverse_pass_n (df, sf, pass);
-
1354
-
1355 if (pass < _nbr_bits - 1)
-
1356 {
-
1357 DataType * const temp_ptr = df;
-
1358 df = sf;
-
1359 sf = temp_ptr;
-
1360 }
-
1361 else
-
1362 {
-
1363 sf = df;
-
1364 df = df_temp;
-
1365 }
-
1366 }
-
1367
-
1368 compute_inverse_pass_3 (df, sf);
-
1369 compute_inverse_pass_1_2 (x, df);
-
1370}
-
1371
+
1310 osc.clear_buffers ();
+
1311
+
1312 // Extreme coefficients are always real
+
1313 dfr [0] = sf1r [0] + sf2r [0];
+
1314 dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] =
+
1315 dfr [h_nbr_coef] = sf1r [h_nbr_coef];
+
1316 dfi [h_nbr_coef] = sf2r [h_nbr_coef];
+
1317
+
1318 // Others are conjugate complex numbers
+
1319 const DataType * const sf1i = sf1r + h_nbr_coef;
+
1320 const DataType * const sf2i = sf1i + nbr_coef;
+
1321 for (long i = 1; i < h_nbr_coef; ++ i)
+
1322 {
+
1323 osc.step ();
+
1324 const DataType c = osc.get_cos ();
+
1325 const DataType s = osc.get_sin ();
+
1326 DataType v;
+
1327
+
1328 v = sf2r [i] * c - sf2i [i] * s;
+
1329 dfr [i] = sf1r [i] + v;
+
1330 dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] =
+
1331
+
1332 v = sf2r [i] * s + sf2i [i] * c;
+
1333 dfi [i] = v + sf1i [i];
+
1334 dfi [nbr_coef - i] = v - sf1i [i];
+
1335 }
+
1336
+
1337 coef_index += d_nbr_coef;
+
1338 }
+
1339 while (coef_index < _length);
+
1340}
+
1341
+
1342
+
1343
+
1344// Transform in several pass
+
1345template <class DT>
+
1346void FFTReal <DT>::compute_ifft_general (const DataType f [], DataType x []) const
+
1347{
+
1348 assert (f != 0);
+
1349 assert (f != use_buffer ());
+
1350 assert (x != 0);
+
1351 assert (x != use_buffer ());
+
1352 assert (x != f);
+
1353
+
1354 DataType * sf = const_cast <DataType *> (f);
+
1355 DataType * df;
+
1356 DataType * df_temp;
+
1357
+
1358 if (_nbr_bits & 1)
+
1359 {
+
1360 df = use_buffer ();
+
1361 df_temp = x;
+
1362 }
+
1363 else
+
1364 {
+
1365 df = x;
+
1366 df_temp = use_buffer ();
+
1367 }
+
1368
+
1369 for (int pass = _nbr_bits - 1; pass >= 3; -- pass)
+
1370 {
+
1371 compute_inverse_pass_n (df, sf, pass);
1372
-
1373
-
1374template <class DT>
-
1375void FFTReal <DT>::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const
-
1376{
-
1377 assert (df != 0);
-
1378 assert (sf != 0);
-
1379 assert (df != sf);
-
1380 assert (pass >= 3);
-
1381 assert (pass < _nbr_bits);
-
1382
-
1383 if (pass <= TRIGO_BD_LIMIT)
-
1384 {
-
1385 compute_inverse_pass_n_lut (df, sf, pass);
-
1386 }
-
1387 else
-
1388 {
-
1389 compute_inverse_pass_n_osc (df, sf, pass);
-
1390 }
-
1391}
-
1392
-
1393
-
1394
-
1395template <class DT>
-
1396void FFTReal <DT>::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const
-
1397{
-
1398 assert (df != 0);
-
1399 assert (sf != 0);
-
1400 assert (df != sf);
-
1401 assert (pass >= 3);
-
1402 assert (pass < _nbr_bits);
-
1403
-
1404 const long nbr_coef = 1 << pass;
-
1405 const long h_nbr_coef = nbr_coef >> 1;
-
1406 const long d_nbr_coef = nbr_coef << 1;
-
1407 long coef_index = 0;
-
1408 const DataType * const cos_ptr = get_trigo_ptr (pass);
-
1409 do
-
1410 {
-
1411 const DataType * const sfr = sf + coef_index;
-
1412 const DataType * const sfi = sfr + nbr_coef;
-
1413 DataType * const df1r = df + coef_index;
-
1414 DataType * const df2r = df1r + nbr_coef;
-
1415
-
1416 // Extreme coefficients are always real
-
1417 df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef]
-
1418 df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef]
-
1419 df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2;
-
1420 df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2;
+
1373 if (pass < _nbr_bits - 1)
+
1374 {
+
1375 DataType * const temp_ptr = df;
+
1376 df = sf;
+
1377 sf = temp_ptr;
+
1378 }
+
1379 else
+
1380 {
+
1381 sf = df;
+
1382 df = df_temp;
+
1383 }
+
1384 }
+
1385
+
1386 compute_inverse_pass_3 (df, sf);
+
1387 compute_inverse_pass_1_2 (x, df);
+
1388}
+
1389
+
1390
+
1391
+
1392template <class DT>
+
1393void FFTReal <DT>::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const
+
1394{
+
1395 assert (df != 0);
+
1396 assert (sf != 0);
+
1397 assert (df != sf);
+
1398 assert (pass >= 3);
+
1399 assert (pass < _nbr_bits);
+
1400
+
1401 if (pass <= TRIGO_BD_LIMIT)
+
1402 {
+
1403 compute_inverse_pass_n_lut (df, sf, pass);
+
1404 }
+
1405 else
+
1406 {
+
1407 compute_inverse_pass_n_osc (df, sf, pass);
+
1408 }
+
1409}
+
1410
+
1411
+
1412
+
1413template <class DT>
+
1414void FFTReal <DT>::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const
+
1415{
+
1416 assert (df != 0);
+
1417 assert (sf != 0);
+
1418 assert (df != sf);
+
1419 assert (pass >= 3);
+
1420 assert (pass < _nbr_bits);
1421
-
1422 // Others are conjugate complex numbers
-
1423 DataType * const df1i = df1r + h_nbr_coef;
-
1424 DataType * const df2i = df1i + nbr_coef;
-
1425 for (long i = 1; i < h_nbr_coef; ++ i)
-
1426 {
-
1427 df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i]
-
1428 df1i [i] = sfi [i] - sfi [nbr_coef - i];
-
1429
-
1430 const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef);
-
1431 const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef);
-
1432 const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i]
-
1433 const DataType vi = sfi [i] + sfi [nbr_coef - i];
-
1434
-
1435 df2r [i] = vr * c + vi * s;
-
1436 df2i [i] = vi * c - vr * s;
-
1437 }
-
1438
-
1439 coef_index += d_nbr_coef;
-
1440 }
-
1441 while (coef_index < _length);
-
1442}
-
1443
-
1444
-
1445
-
1446template <class DT>
-
1447void FFTReal <DT>::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const
-
1448{
-
1449 assert (df != 0);
-
1450 assert (sf != 0);
-
1451 assert (df != sf);
-
1452 assert (pass > TRIGO_BD_LIMIT);
-
1453 assert (pass < _nbr_bits);
-
1454
-
1455 const long nbr_coef = 1 << pass;
-
1456 const long h_nbr_coef = nbr_coef >> 1;
-
1457 const long d_nbr_coef = nbr_coef << 1;
-
1458 long coef_index = 0;
-
1459 OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)];
-
1460 do
-
1461 {
-
1462 const DataType * const sfr = sf + coef_index;
-
1463 const DataType * const sfi = sfr + nbr_coef;
-
1464 DataType * const df1r = df + coef_index;
-
1465 DataType * const df2r = df1r + nbr_coef;
-
1466
-
1467 osc.clear_buffers ();
-
1468
-
1469 // Extreme coefficients are always real
-
1470 df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef]
-
1471 df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef]
-
1472 df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2;
-
1473 df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2;
-
1474
-
1475 // Others are conjugate complex numbers
-
1476 DataType * const df1i = df1r + h_nbr_coef;
-
1477 DataType * const df2i = df1i + nbr_coef;
-
1478 for (long i = 1; i < h_nbr_coef; ++ i)
-
1479 {
-
1480 df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i]
-
1481 df1i [i] = sfi [i] - sfi [nbr_coef - i];
-
1482
-
1483 osc.step ();
-
1484 const DataType c = osc.get_cos ();
-
1485 const DataType s = osc.get_sin ();
-
1486 const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i]
-
1487 const DataType vi = sfi [i] + sfi [nbr_coef - i];
-
1488
-
1489 df2r [i] = vr * c + vi * s;
-
1490 df2i [i] = vi * c - vr * s;
-
1491 }
+
1422 const long nbr_coef = 1 << pass;
+
1423 const long h_nbr_coef = nbr_coef >> 1;
+
1424 const long d_nbr_coef = nbr_coef << 1;
+
1425 long coef_index = 0;
+
1426 const DataType * const cos_ptr = get_trigo_ptr (pass);
+
1427 do
+
1428 {
+
1429 const DataType * const sfr = sf + coef_index;
+
1430 const DataType * const sfi = sfr + nbr_coef;
+
1431 DataType * const df1r = df + coef_index;
+
1432 DataType * const df2r = df1r + nbr_coef;
+
1433
+
1434 // Extreme coefficients are always real
+
1435 df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef]
+
1436 df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef]
+
1437 df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2;
+
1438 df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2;
+
1439
+
1440 // Others are conjugate complex numbers
+
1441 DataType * const df1i = df1r + h_nbr_coef;
+
1442 DataType * const df2i = df1i + nbr_coef;
+
1443 for (long i = 1; i < h_nbr_coef; ++ i)
+
1444 {
+
1445 df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i]
+
1446 df1i [i] = sfi [i] - sfi [nbr_coef - i];
+
1447
+
1448 const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef);
+
1449 const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef);
+
1450 const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i]
+
1451 const DataType vi = sfi [i] + sfi [nbr_coef - i];
+
1452
+
1453 df2r [i] = vr * c + vi * s;
+
1454 df2i [i] = vi * c - vr * s;
+
1455 }
+
1456
+
1457 coef_index += d_nbr_coef;
+
1458 }
+
1459 while (coef_index < _length);
+
1460}
+
1461
+
1462
+
1463
+
1464template <class DT>
+
1465void FFTReal <DT>::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const
+
1466{
+
1467 assert (df != 0);
+
1468 assert (sf != 0);
+
1469 assert (df != sf);
+
1470 assert (pass > TRIGO_BD_LIMIT);
+
1471 assert (pass < _nbr_bits);
+
1472
+
1473 const long nbr_coef = 1 << pass;
+
1474 const long h_nbr_coef = nbr_coef >> 1;
+
1475 const long d_nbr_coef = nbr_coef << 1;
+
1476 long coef_index = 0;
+
1477 OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)];
+
1478 do
+
1479 {
+
1480 const DataType * const sfr = sf + coef_index;
+
1481 const DataType * const sfi = sfr + nbr_coef;
+
1482 DataType * const df1r = df + coef_index;
+
1483 DataType * const df2r = df1r + nbr_coef;
+
1484
+
1485 osc.clear_buffers ();
+
1486
+
1487 // Extreme coefficients are always real
+
1488 df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef]
+
1489 df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef]
+
1490 df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2;
+
1491 df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2;
1492
-
1493 coef_index += d_nbr_coef;
-
1494 }
-
1495 while (coef_index < _length);
-
1496}
-
1497
-
1498
-
1499
-
1500template <class DT>
-
1501void FFTReal <DT>::compute_inverse_pass_3 (DataType df [], const DataType sf []) const
-
1502{
-
1503 assert (df != 0);
-
1504 assert (sf != 0);
-
1505 assert (df != sf);
+
1493 // Others are conjugate complex numbers
+
1494 DataType * const df1i = df1r + h_nbr_coef;
+
1495 DataType * const df2i = df1i + nbr_coef;
+
1496 for (long i = 1; i < h_nbr_coef; ++ i)
+
1497 {
+
1498 df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i]
+
1499 df1i [i] = sfi [i] - sfi [nbr_coef - i];
+
1500
+
1501 osc.step ();
+
1502 const DataType c = osc.get_cos ();
+
1503 const DataType s = osc.get_sin ();
+
1504 const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i]
+
1505 const DataType vi = sfi [i] + sfi [nbr_coef - i];
1506
-
1507 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
-
1508 long coef_index = 0;
-
1509 do
-
1510 {
-
1511 df [coef_index] = sf [coef_index] + sf [coef_index + 4];
-
1512 df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4];
-
1513 df [coef_index + 2] = sf [coef_index + 2] * 2;
-
1514 df [coef_index + 6] = sf [coef_index + 6] * 2;
+
1507 df2r [i] = vr * c + vi * s;
+
1508 df2i [i] = vi * c - vr * s;
+
1509 }
+
1510
+
1511 coef_index += d_nbr_coef;
+
1512 }
+
1513 while (coef_index < _length);
+
1514}
1515
-
1516 df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3];
-
1517 df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7];
-
1518
-
1519 const DataType vr = sf [coef_index + 1] - sf [coef_index + 3];
-
1520 const DataType vi = sf [coef_index + 5] + sf [coef_index + 7];
-
1521
-
1522 df [coef_index + 5] = (vr + vi) * sqrt2_2;
-
1523 df [coef_index + 7] = (vi - vr) * sqrt2_2;
+
1516
+
1517
+
1518template <class DT>
+
1519void FFTReal <DT>::compute_inverse_pass_3 (DataType df [], const DataType sf []) const
+
1520{
+
1521 assert (df != 0);
+
1522 assert (sf != 0);
+
1523 assert (df != sf);
1524
-
1525 coef_index += 8;
-
1526 }
-
1527 while (coef_index < _length);
-
1528}
-
1529
-
1530
-
1531
-
1532template <class DT>
-
1533void FFTReal <DT>::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const
-
1534{
-
1535 assert (x != 0);
-
1536 assert (sf != 0);
-
1537 assert (x != sf);
-
1538
-
1539 const long * bit_rev_lut_ptr = get_br_ptr ();
-
1540 const DataType * sf2 = sf;
-
1541 long coef_index = 0;
-
1542 do
-
1543 {
-
1544 {
-
1545 const DataType b_0 = sf2 [0] + sf2 [2];
-
1546 const DataType b_2 = sf2 [0] - sf2 [2];
-
1547 const DataType b_1 = sf2 [1] * 2;
-
1548 const DataType b_3 = sf2 [3] * 2;
+
1525 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
+
1526 long coef_index = 0;
+
1527 do
+
1528 {
+
1529 df [coef_index] = sf [coef_index] + sf [coef_index + 4];
+
1530 df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4];
+
1531 df [coef_index + 2] = sf [coef_index + 2] * 2;
+
1532 df [coef_index + 6] = sf [coef_index + 6] * 2;
+
1533
+
1534 df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3];
+
1535 df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7];
+
1536
+
1537 const DataType vr = sf [coef_index + 1] - sf [coef_index + 3];
+
1538 const DataType vi = sf [coef_index + 5] + sf [coef_index + 7];
+
1539
+
1540 df [coef_index + 5] = (vr + vi) * sqrt2_2;
+
1541 df [coef_index + 7] = (vi - vr) * sqrt2_2;
+
1542
+
1543 coef_index += 8;
+
1544 }
+
1545 while (coef_index < _length);
+
1546}
+
1547
+
1548
1549
-
1550 x [bit_rev_lut_ptr [0]] = b_0 + b_1;
-
1551 x [bit_rev_lut_ptr [1]] = b_0 - b_1;
-
1552 x [bit_rev_lut_ptr [2]] = b_2 + b_3;
-
1553 x [bit_rev_lut_ptr [3]] = b_2 - b_3;
-
1554 }
-
1555 {
-
1556 const DataType b_0 = sf2 [4] + sf2 [6];
-
1557 const DataType b_2 = sf2 [4] - sf2 [6];
-
1558 const DataType b_1 = sf2 [5] * 2;
-
1559 const DataType b_3 = sf2 [7] * 2;
-
1560
-
1561 x [bit_rev_lut_ptr [4]] = b_0 + b_1;
-
1562 x [bit_rev_lut_ptr [5]] = b_0 - b_1;
-
1563 x [bit_rev_lut_ptr [6]] = b_2 + b_3;
-
1564 x [bit_rev_lut_ptr [7]] = b_2 - b_3;
-
1565 }
-
1566
-
1567 sf2 += 8;
-
1568 coef_index += 8;
-
1569 bit_rev_lut_ptr += 8;
-
1570 }
-
1571 while (coef_index < _length);
-
1572}
-
1573
-
1574
-
1575
-
1576} // namespace ffft
-
1577
+
1550template <class DT>
+
1551void FFTReal <DT>::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const
+
1552{
+
1553 assert (x != 0);
+
1554 assert (sf != 0);
+
1555 assert (x != sf);
+
1556
+
1557 const long * bit_rev_lut_ptr = get_br_ptr ();
+
1558 const DataType * sf2 = sf;
+
1559 long coef_index = 0;
+
1560 do
+
1561 {
+
1562 {
+
1563 const DataType b_0 = sf2 [0] + sf2 [2];
+
1564 const DataType b_2 = sf2 [0] - sf2 [2];
+
1565 const DataType b_1 = sf2 [1] * 2;
+
1566 const DataType b_3 = sf2 [3] * 2;
+
1567
+
1568 x [bit_rev_lut_ptr [0]] = b_0 + b_1;
+
1569 x [bit_rev_lut_ptr [1]] = b_0 - b_1;
+
1570 x [bit_rev_lut_ptr [2]] = b_2 + b_3;
+
1571 x [bit_rev_lut_ptr [3]] = b_2 - b_3;
+
1572 }
+
1573 {
+
1574 const DataType b_0 = sf2 [4] + sf2 [6];
+
1575 const DataType b_2 = sf2 [4] - sf2 [6];
+
1576 const DataType b_1 = sf2 [5] * 2;
+
1577 const DataType b_3 = sf2 [7] * 2;
1578
-
1579
-
1580#endif // ffft_FFTReal_CODEHEADER_INCLUDED
-
1581
-
1582#undef ffft_FFTReal_CURRENT_CODEHEADER
-
1583
+
1579 x [bit_rev_lut_ptr [4]] = b_0 + b_1;
+
1580 x [bit_rev_lut_ptr [5]] = b_0 - b_1;
+
1581 x [bit_rev_lut_ptr [6]] = b_2 + b_3;
+
1582 x [bit_rev_lut_ptr [7]] = b_2 - b_3;
+
1583 }
1584
-
1585
-
1586/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1587
-
1588
-
1589
-
1590
-
1591#endif // ffft_FFTReal_HEADER_INCLUDED
+
1585 sf2 += 8;
+
1586 coef_index += 8;
+
1587 bit_rev_lut_ptr += 8;
+
1588 }
+
1589 while (coef_index < _length);
+
1590}
+
1591
1592
1593
-
1594
-
1595/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1594} // namespace ffft
+
1595
1596
-
1597/*****************************************************************************
-
1598
-
1599 FFTRealFixLen.h
-
1600 By Laurent de Soras
-
1601
-
1602--- Legal stuff ---
-
1603
-
1604This program is free software. It comes without any warranty, to
-
1605the extent permitted by applicable law. You can redistribute it
-
1606and/or modify it under the terms of the Do What The Fuck You Want
-
1607To Public License, Version 2, as published by Sam Hocevar. See
-
1608http://sam.zoy.org/wtfpl/COPYING for more details.
-
1609
-
1610*Tab=3***********************************************************************/
+
1597
+
1598#endif // ffft_FFTReal_CODEHEADER_INCLUDED
+
1599
+
1600#undef ffft_FFTReal_CURRENT_CODEHEADER
+
1601
+
1602
+
1603
+
1604/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1605
+
1606
+
1607
+
1608
+
1609#endif // ffft_FFTReal_HEADER_INCLUDED
+
1610
1611
1612
-
1613
-
1614#if ! defined (ffft_FFTRealFixLen_HEADER_INCLUDED)
-
1615#define ffft_FFTRealFixLen_HEADER_INCLUDED
-
1616
-
1617#if defined (_MSC_VER)
-
1618 #pragma once
-
1619 #pragma warning (4 : 4250) // "Inherits via dominance."
-
1620#endif
-
1621
-
1622
-
1623
-
1624/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1625
-
1626/*****************************************************************************
+
1613/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1614
+
1615/*****************************************************************************
+
1616
+
1617 FFTRealFixLen.h
+
1618 By Laurent de Soras
+
1619
+
1620--- Legal stuff ---
+
1621
+
1622This program is free software. It comes without any warranty, to
+
1623the extent permitted by applicable law. You can redistribute it
+
1624and/or modify it under the terms of the Do What The Fuck You Want
+
1625To Public License, Version 2, as published by Sam Hocevar. See
+
1626http://sam.zoy.org/wtfpl/COPYING for more details.
1627
-
1628 Array.h
-
1629 By Laurent de Soras
-
1630
-
1631--- Legal stuff ---
-
1632
-
1633This program is free software. It comes without any warranty, to
-
1634the extent permitted by applicable law. You can redistribute it
-
1635and/or modify it under the terms of the Do What The Fuck You Want
-
1636To Public License, Version 2, as published by Sam Hocevar. See
-
1637http://sam.zoy.org/wtfpl/COPYING for more details.
-
1638
-
1639*Tab=3***********************************************************************/
+
1628*Tab=3***********************************************************************/
+
1629
+
1630
+
1631
+
1632#if ! defined (ffft_FFTRealFixLen_HEADER_INCLUDED)
+
1633#define ffft_FFTRealFixLen_HEADER_INCLUDED
+
1634
+
1635#if defined (_MSC_VER)
+
1636 #pragma once
+
1637 #pragma warning (4 : 4250) // "Inherits via dominance."
+
1638#endif
+
1639
1640
1641
-
1642
-
1643#if ! defined (ffft_Array_HEADER_INCLUDED)
-
1644#define ffft_Array_HEADER_INCLUDED
-
1645
-
1646#if defined (_MSC_VER)
-
1647 #pragma once
-
1648 #pragma warning (4 : 4250) // "Inherits via dominance."
-
1649#endif
-
1650
-
1651
-
1652
-
1653/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1654
-
1655
-
1656
-
1657namespace ffft
-
1658{
+
1642/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1643
+
1644/*****************************************************************************
+
1645
+
1646 Array.h
+
1647 By Laurent de Soras
+
1648
+
1649--- Legal stuff ---
+
1650
+
1651This program is free software. It comes without any warranty, to
+
1652the extent permitted by applicable law. You can redistribute it
+
1653and/or modify it under the terms of the Do What The Fuck You Want
+
1654To Public License, Version 2, as published by Sam Hocevar. See
+
1655http://sam.zoy.org/wtfpl/COPYING for more details.
+
1656
+
1657*Tab=3***********************************************************************/
+
1658
1659
1660
-
1661
-
1662template <class T, long LEN>
-
- -
1664{
-
1665
-
1666/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1667
-
1668public:
+
1661#if ! defined (ffft_Array_HEADER_INCLUDED)
+
1662#define ffft_Array_HEADER_INCLUDED
+
1663
+
1664#if defined (_MSC_VER)
+
1665 #pragma once
+
1666 #pragma warning (4 : 4250) // "Inherits via dominance."
+
1667#endif
+
1668
1669
-
1670 typedef T DataType;
-
1671
-
1672 Array ();
+
1670
+
1671/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1672
1673
-
1674 inline const DataType &
-
1675 operator [] (long pos) const;
-
1676 inline DataType &
-
1677 operator [] (long pos);
+
1674
+
1675namespace ffft
+
1676{
+
1677
1678
-
1679 static inline long
-
1680 size ();
-
1681
-
1682
+
1679
+
1680template <class T, long LEN>
+
+ +
1682{
1683
-
1684/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1684/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
1685
-
1686protected:
+
1686public:
1687
-
1688
+
1688 typedef T DataType;
1689
-
1690/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1690 Array ();
1691
-
1692private:
-
1693
-
1694 DataType _data_arr [LEN];
-
1695
+
1692 inline const DataType &
+
1693 operator [] (long pos) const;
+
1694 inline DataType &
+
1695 operator [] (long pos);
1696
-
1697
-
1698/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
1697 static inline long
+
1698 size ();
1699
-
1700private:
+
1700
1701
-
1702 Array (const Array &other);
-
1703 Array & operator = (const Array &other);
-
1704 bool operator == (const Array &other);
-
1705 bool operator != (const Array &other);
+
1702/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1703
+
1704protected:
+
1705
1706
-
1707}; // class Array
-
-
1708
+
1707
+
1708/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
1709
-
1710
-
1711} // namespace ffft
-
1712
+
1710private:
+
1711
+
1712 DataType _data_arr [LEN];
1713
1714
-
1715/*****************************************************************************
-
1716
-
1717 Array.hpp
-
1718 By Laurent de Soras
-
1719
-
1720--- Legal stuff ---
-
1721
-
1722This program is free software. It comes without any warranty, to
-
1723the extent permitted by applicable law. You can redistribute it
-
1724and/or modify it under the terms of the Do What The Fuck You Want
-
1725To Public License, Version 2, as published by Sam Hocevar. See
-
1726http://sam.zoy.org/wtfpl/COPYING for more details.
-
1727
-
1728*Tab=3***********************************************************************/
-
1729
+
1715
+
1716/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
1717
+
1718private:
+
1719
+
1720 Array (const Array &other);
+
1721 Array & operator = (const Array &other);
+
1722 bool operator == (const Array &other);
+
1723 bool operator != (const Array &other);
+
1724
+
1725}; // class Array
+
+
1726
+
1727
+
1728
+
1729} // namespace ffft
1730
1731
-
1732#if defined (ffft_Array_CURRENT_CODEHEADER)
-
1733 #error Recursive inclusion of Array code header.
-
1734#endif
-
1735#define ffft_Array_CURRENT_CODEHEADER
-
1736
-
1737#if ! defined (ffft_Array_CODEHEADER_INCLUDED)
-
1738#define ffft_Array_CODEHEADER_INCLUDED
-
1739
-
1740
-
1741
-
1742/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1743
-
1744#include <cassert>
-
1745
-
1746
+
1732
+
1733/*****************************************************************************
+
1734
+
1735 Array.hpp
+
1736 By Laurent de Soras
+
1737
+
1738--- Legal stuff ---
+
1739
+
1740This program is free software. It comes without any warranty, to
+
1741the extent permitted by applicable law. You can redistribute it
+
1742and/or modify it under the terms of the Do What The Fuck You Want
+
1743To Public License, Version 2, as published by Sam Hocevar. See
+
1744http://sam.zoy.org/wtfpl/COPYING for more details.
+
1745
+
1746*Tab=3***********************************************************************/
1747
-
1748namespace ffft
-
1749{
-
1750
-
1751
-
1752
-
1753/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1748
+
1749
+
1750#if defined (ffft_Array_CURRENT_CODEHEADER)
+
1751 #error Recursive inclusion of Array code header.
+
1752#endif
+
1753#define ffft_Array_CURRENT_CODEHEADER
1754
-
1755
-
1756
-
1757template <class T, long LEN>
-
1758Array <T, LEN>::Array ()
-
1759{
-
1760 // Nothing
-
1761}
-
1762
+
1755#if ! defined (ffft_Array_CODEHEADER_INCLUDED)
+
1756#define ffft_Array_CODEHEADER_INCLUDED
+
1757
+
1758
+
1759
+
1760/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1761
+
1762#include <cassert>
1763
1764
-
1765template <class T, long LEN>
-
1766const typename Array <T, LEN>::DataType & Array <T, LEN>::operator [] (long pos) const
+
1765
+
1766namespace ffft
1767{
-
1768 assert (pos >= 0);
-
1769 assert (pos < LEN);
+
1768
+
1769
1770
-
1771 return (_data_arr [pos]);
-
1772}
+
1771/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1772
1773
1774
-
1775
-
1776template <class T, long LEN>
-
1777typename Array <T, LEN>::DataType & Array <T, LEN>::operator [] (long pos)
-
1778{
-
1779 assert (pos >= 0);
-
1780 assert (pos < LEN);
+
1775template <class T, long LEN>
+
1776Array <T, LEN>::Array ()
+
1777{
+
1778 // Nothing
+
1779}
+
1780
1781
-
1782 return (_data_arr [pos]);
-
1783}
-
1784
-
1785
-
1786
-
1787template <class T, long LEN>
-
1788long Array <T, LEN>::size ()
-
1789{
-
1790 return (LEN);
-
1791}
+
1782
+
1783template <class T, long LEN>
+
1784const typename Array <T, LEN>::DataType & Array <T, LEN>::operator [] (long pos) const
+
1785{
+
1786 assert (pos >= 0);
+
1787 assert (pos < LEN);
+
1788
+
1789 return (_data_arr [pos]);
+
1790}
+
1791
1792
1793
-
1794
-
1795/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1796
-
1797
-
1798
-
1799/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1800
-
1801
+
1794template <class T, long LEN>
+
1795typename Array <T, LEN>::DataType & Array <T, LEN>::operator [] (long pos)
+
1796{
+
1797 assert (pos >= 0);
+
1798 assert (pos < LEN);
+
1799
+
1800 return (_data_arr [pos]);
+
1801}
1802
-
1803} // namespace ffft
+
1803
1804
-
1805
-
1806
-
1807#endif // ffft_Array_CODEHEADER_INCLUDED
-
1808
-
1809#undef ffft_Array_CURRENT_CODEHEADER
+
1805template <class T, long LEN>
+
1806long Array <T, LEN>::size ()
+
1807{
+
1808 return (LEN);
+
1809}
1810
1811
1812
-
1813/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1813/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
1814
1815
1816
-
1817
-
1818#endif // ffft_Array_HEADER_INCLUDED
+
1817/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1818
1819
1820
-
1821
-
1822/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1821} // namespace ffft
+
1822
1823
-
1824/*****************************************************************************
-
1825
-
1826 DynArray.h
-
1827 By Laurent de Soras
-
1828
-
1829--- Legal stuff ---
-
1830
-
1831This program is free software. It comes without any warranty, to
-
1832the extent permitted by applicable law. You can redistribute it
-
1833and/or modify it under the terms of the Do What The Fuck You Want
-
1834To Public License, Version 2, as published by Sam Hocevar. See
-
1835http://sam.zoy.org/wtfpl/COPYING for more details.
-
1836
-
1837*Tab=3***********************************************************************/
+
1824
+
1825#endif // ffft_Array_CODEHEADER_INCLUDED
+
1826
+
1827#undef ffft_Array_CURRENT_CODEHEADER
+
1828
+
1829
+
1830
+
1831/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1832
+
1833
+
1834
+
1835
+
1836#endif // ffft_Array_HEADER_INCLUDED
+
1837
1838
1839
-
1840
-
1841#if ! defined (ffft_DynArray_HEADER_INCLUDED)
-
1842#define ffft_DynArray_HEADER_INCLUDED
-
1843
-
1844#if defined (_MSC_VER)
-
1845 #pragma once
-
1846 #pragma warning (4 : 4250) // "Inherits via dominance."
-
1847#endif
-
1848
-
1849
-
1850
-
1851/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1852
-
1853
-
1854
-
1855namespace ffft
-
1856{
+
1840/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1841
+
1842/*****************************************************************************
+
1843
+
1844 DynArray.h
+
1845 By Laurent de Soras
+
1846
+
1847--- Legal stuff ---
+
1848
+
1849This program is free software. It comes without any warranty, to
+
1850the extent permitted by applicable law. You can redistribute it
+
1851and/or modify it under the terms of the Do What The Fuck You Want
+
1852To Public License, Version 2, as published by Sam Hocevar. See
+
1853http://sam.zoy.org/wtfpl/COPYING for more details.
+
1854
+
1855*Tab=3***********************************************************************/
+
1856
1857
1858
-
1859
-
1860template <class T>
-
1861class DynArray
-
1862{
-
1863
-
1864/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1865
-
1866public:
+
1859#if ! defined (ffft_DynArray_HEADER_INCLUDED)
+
1860#define ffft_DynArray_HEADER_INCLUDED
+
1861
+
1862#if defined (_MSC_VER)
+
1863 #pragma once
+
1864 #pragma warning (4 : 4250) // "Inherits via dominance."
+
1865#endif
+
1866
1867
-
1868 typedef T DataType;
-
1869
-
1870 DynArray ();
-
1871 explicit DynArray (long size);
-
1872 ~DynArray ();
-
1873
-
1874 inline long size () const;
-
1875 inline void resize (long size);
+
1868
+
1869/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1870
+
1871
+
1872
+
1873namespace ffft
+
1874{
+
1875
1876
-
1877 inline const DataType &
-
1878 operator [] (long pos) const;
-
1879 inline DataType &
-
1880 operator [] (long pos);
+
1877
+
1878template <class T>
+
1879class DynArray
+
1880{
1881
-
1882
+
1882/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
1883
-
1884/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1884public:
1885
-
1886protected:
+
1886 typedef T DataType;
1887
-
1888
-
1889
-
1890/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1888 DynArray ();
+
1889 explicit DynArray (long size);
+
1890 ~DynArray ();
1891
-
1892private:
-
1893
-
1894 DataType * _data_ptr;
-
1895 long _len;
-
1896
-
1897
-
1898
-
1899/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
1892 inline long size () const;
+
1893 inline void resize (long size);
+
1894
+
1895 inline const DataType &
+
1896 operator [] (long pos) const;
+
1897 inline DataType &
+
1898 operator [] (long pos);
+
1899
1900
-
1901private:
-
1902
-
1903 DynArray (const DynArray &other);
-
1904 DynArray & operator = (const DynArray &other);
-
1905 bool operator == (const DynArray &other);
-
1906 bool operator != (const DynArray &other);
+
1901
+
1902/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1903
+
1904protected:
+
1905
+
1906
1907
-
1908}; // class DynArray
+
1908/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
1909
-
1910
+
1910private:
1911
-
1912} // namespace ffft
-
1913
+
1912 DataType * _data_ptr;
+
1913 long _len;
1914
1915
-
1916/*****************************************************************************
-
1917
-
1918 DynArray.hpp
-
1919 By Laurent de Soras
-
1920
-
1921--- Legal stuff ---
-
1922
-
1923This program is free software. It comes without any warranty, to
-
1924the extent permitted by applicable law. You can redistribute it
-
1925and/or modify it under the terms of the Do What The Fuck You Want
-
1926To Public License, Version 2, as published by Sam Hocevar. See
-
1927http://sam.zoy.org/wtfpl/COPYING for more details.
-
1928
-
1929*Tab=3***********************************************************************/
-
1930
+
1916
+
1917/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
1918
+
1919private:
+
1920
+
1921 DynArray (const DynArray &other);
+
1922 DynArray & operator = (const DynArray &other);
+
1923 bool operator == (const DynArray &other);
+
1924 bool operator != (const DynArray &other);
+
1925
+
1926}; // class DynArray
+
1927
+
1928
+
1929
+
1930} // namespace ffft
1931
1932
-
1933#if defined (ffft_DynArray_CURRENT_CODEHEADER)
-
1934 #error Recursive inclusion of DynArray code header.
-
1935#endif
-
1936#define ffft_DynArray_CURRENT_CODEHEADER
-
1937
-
1938#if ! defined (ffft_DynArray_CODEHEADER_INCLUDED)
-
1939#define ffft_DynArray_CODEHEADER_INCLUDED
-
1940
-
1941
-
1942
-
1943/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
1944
-
1945#include <cassert>
-
1946
-
1947
+
1933
+
1934/*****************************************************************************
+
1935
+
1936 DynArray.hpp
+
1937 By Laurent de Soras
+
1938
+
1939--- Legal stuff ---
+
1940
+
1941This program is free software. It comes without any warranty, to
+
1942the extent permitted by applicable law. You can redistribute it
+
1943and/or modify it under the terms of the Do What The Fuck You Want
+
1944To Public License, Version 2, as published by Sam Hocevar. See
+
1945http://sam.zoy.org/wtfpl/COPYING for more details.
+
1946
+
1947*Tab=3***********************************************************************/
1948
-
1949namespace ffft
-
1950{
-
1951
-
1952
-
1953
-
1954/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1949
+
1950
+
1951#if defined (ffft_DynArray_CURRENT_CODEHEADER)
+
1952 #error Recursive inclusion of DynArray code header.
+
1953#endif
+
1954#define ffft_DynArray_CURRENT_CODEHEADER
1955
-
1956
-
1957
-
1958template <class T>
-
1959DynArray <T>::DynArray ()
-
1960: _data_ptr (0)
-
1961, _len (0)
-
1962{
-
1963 // Nothing
-
1964}
+
1956#if ! defined (ffft_DynArray_CODEHEADER_INCLUDED)
+
1957#define ffft_DynArray_CODEHEADER_INCLUDED
+
1958
+
1959
+
1960
+
1961/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1962
+
1963#include <cassert>
+
1964
1965
1966
-
1967
-
1968template <class T>
-
1969DynArray <T>::DynArray (long size)
-
1970: _data_ptr (0)
-
1971, _len (0)
-
1972{
-
1973 assert (size >= 0);
-
1974 if (size > 0)
-
1975 {
-
1976 _data_ptr = new DataType [size];
-
1977 _len = size;
-
1978 }
-
1979}
-
1980
-
1981
-
1982
-
1983template <class T>
-
1984DynArray <T>::~DynArray ()
-
1985{
-
1986 delete [] _data_ptr;
-
1987 _data_ptr = 0;
-
1988 _len = 0;
-
1989}
-
1990
-
1991
-
1992
-
1993template <class T>
-
1994long DynArray <T>::size () const
-
1995{
-
1996 return (_len);
-
1997}
-
1998
-
1999
-
2000
-
2001template <class T>
-
2002void DynArray <T>::resize (long size)
-
2003{
-
2004 assert (size >= 0);
-
2005 if (size > 0)
-
2006 {
-
2007 DataType * old_data_ptr = _data_ptr;
-
2008 DataType * tmp_data_ptr = new DataType [size];
-
2009
-
2010 _data_ptr = tmp_data_ptr;
-
2011 _len = size;
-
2012
-
2013 delete [] old_data_ptr;
-
2014 }
+
1967namespace ffft
+
1968{
+
1969
+
1970
+
1971
+
1972/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
1973
+
1974
+
1975
+
1976template <class T>
+
1977DynArray <T>::DynArray ()
+
1978: _data_ptr (0)
+
1979, _len (0)
+
1980{
+
1981 // Nothing
+
1982}
+
1983
+
1984
+
1985
+
1986template <class T>
+
1987DynArray <T>::DynArray (long size)
+
1988: _data_ptr (0)
+
1989, _len (0)
+
1990{
+
1991 assert (size >= 0);
+
1992 if (size > 0)
+
1993 {
+
1994#ifdef FFT_CUSTOM_ALLOC
+
1995 _data_ptr = FFT_CUSTOM_ALLOC.createArray<DataType>(size);
+
1996#else
+
1997 _data_ptr = new DataType [size];
+
1998#endif
+
1999 _len = size;
+
2000 }
+
2001}
+
2002
+
2003
+
2004
+
2005template <class T>
+
2006DynArray <T>::~DynArray ()
+
2007{
+
2008#ifdef FFT_CUSTOM_ALLOC
+
2009 FFT_CUSTOM_ALLOC.removeArray<T>(_data_ptr, _len);
+
2010#else
+
2011 delete [] _data_ptr;
+
2012#endif
+
2013 _data_ptr = 0;
+
2014 _len = 0;
2015}
2016
2017
2018
2019template <class T>
-
2020const typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos) const
+
2020long DynArray <T>::size () const
2021{
-
2022 assert (pos >= 0);
-
2023 assert (pos < _len);
+
2022 return (_len);
+
2023}
2024
-
2025 return (_data_ptr [pos]);
-
2026}
-
2027
-
2028
-
2029
-
2030template <class T>
-
2031typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos)
-
2032{
-
2033 assert (pos >= 0);
-
2034 assert (pos < _len);
-
2035
-
2036 return (_data_ptr [pos]);
-
2037}
+
2025
+
2026
+
2027template <class T>
+
2028void DynArray <T>::resize (long size)
+
2029{
+
2030 assert (size >= 0);
+
2031 if (size > 0)
+
2032 {
+
2033 DataType * old_data_ptr = _data_ptr;
+
2034#ifdef FFT_CUSTOM_ALLOC
+
2035#else
+
2036 DataType * tmp_data_ptr = new DataType [size];
+
2037#endif
2038
-
2039
-
2040
-
2041/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2042
-
2043
-
2044
-
2045/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2046
-
2047
+
2039 _data_ptr = tmp_data_ptr;
+
2040 _len = size;
+
2041
+
2042#ifdef FFT_CUSTOM_ALLOC
+
2043#else
+
2044 delete [] old_data_ptr;
+
2045#endif
+
2046 }
+
2047}
2048
-
2049} // namespace ffft
+
2049
2050
-
2051
-
2052
-
2053#endif // ffft_DynArray_CODEHEADER_INCLUDED
-
2054
-
2055#undef ffft_DynArray_CURRENT_CODEHEADER
+
2051template <class T>
+
2052const typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos) const
+
2053{
+
2054 assert (pos >= 0);
+
2055 assert (pos < _len);
2056
-
2057
-
2058
-
2059/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2057 return (_data_ptr [pos]);
+
2058}
+
2059
2060
2061
-
2062
-
2063
-
2064#endif // ffft_DynArray_HEADER_INCLUDED
-
2065
-
2066
+
2062template <class T>
+
2063typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos)
+
2064{
+
2065 assert (pos >= 0);
+
2066 assert (pos < _len);
2067
-
2068/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2069
-
2070/*****************************************************************************
-
2071
-
2072 FFTRealFixLenParam.h
-
2073 By Laurent de Soras
-
2074
-
2075--- Legal stuff ---
-
2076
-
2077This program is free software. It comes without any warranty, to
-
2078the extent permitted by applicable law. You can redistribute it
-
2079and/or modify it under the terms of the Do What The Fuck You Want
-
2080To Public License, Version 2, as published by Sam Hocevar. See
-
2081http://sam.zoy.org/wtfpl/COPYING for more details.
-
2082
-
2083*Tab=3***********************************************************************/
+
2068 return (_data_ptr [pos]);
+
2069}
+
2070
+
2071
+
2072
+
2073/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2074
+
2075
+
2076
+
2077/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2078
+
2079
+
2080
+
2081} // namespace ffft
+
2082
+
2083
2084
-
2085
+
2085#endif // ffft_DynArray_CODEHEADER_INCLUDED
2086
-
2087#if ! defined (ffft_FFTRealFixLenParam_HEADER_INCLUDED)
-
2088#define ffft_FFTRealFixLenParam_HEADER_INCLUDED
+
2087#undef ffft_DynArray_CURRENT_CODEHEADER
+
2088
2089
-
2090#if defined (_MSC_VER)
-
2091 #pragma once
-
2092 #pragma warning (4 : 4250) // "Inherits via dominance."
-
2093#endif
+
2090
+
2091/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2092
+
2093
2094
2095
-
2096
-
2097/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2096#endif // ffft_DynArray_HEADER_INCLUDED
+
2097
2098
2099
-
2100
-
2101namespace ffft
-
2102{
-
2103
-
2104
-
2105
-
- -
2107{
-
2108
-
2109/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2110
-
2111public:
-
2112
-
2113 // Over this bit depth, we use direct calculation for sin/cos
-
2114 enum { TRIGO_BD_LIMIT = 12 };
-
2115
-
2116 typedef float DataType;
+
2100/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2101
+
2102/*****************************************************************************
+
2103
+
2104 FFTRealFixLenParam.h
+
2105 By Laurent de Soras
+
2106
+
2107--- Legal stuff ---
+
2108
+
2109This program is free software. It comes without any warranty, to
+
2110the extent permitted by applicable law. You can redistribute it
+
2111and/or modify it under the terms of the Do What The Fuck You Want
+
2112To Public License, Version 2, as published by Sam Hocevar. See
+
2113http://sam.zoy.org/wtfpl/COPYING for more details.
+
2114
+
2115*Tab=3***********************************************************************/
+
2116
2117
2118
-
2119
-
2120/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2119#if ! defined (ffft_FFTRealFixLenParam_HEADER_INCLUDED)
+
2120#define ffft_FFTRealFixLenParam_HEADER_INCLUDED
2121
-
2122protected:
-
2123
-
2124
-
2125
-
2126/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2122#if defined (_MSC_VER)
+
2123 #pragma once
+
2124 #pragma warning (4 : 4250) // "Inherits via dominance."
+
2125#endif
+
2126
2127
-
2128private:
-
2129
+
2128
+
2129/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2130
2131
-
2132/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
-
2133
-
2134private:
+
2132
+
2133namespace ffft
+
2134{
2135
- - - -
2139 operator = (const FFTRealFixLenParam &other);
-
2140 bool operator == (const FFTRealFixLenParam &other);
-
2141 bool operator != (const FFTRealFixLenParam &other);
+
2136
+
2137
+
+ +
2139{
+
2140
+
2141/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2142
-
2143}; // class FFTRealFixLenParam
-
+
2143public:
2144
-
2145
-
2146
-
2147} // namespace ffft
-
2148
+
2145 // Over this bit depth, we use direct calculation for sin/cos
+
2146 enum { TRIGO_BD_LIMIT = 12 };
+
2147
+
2148 typedef float DataType;
2149
2150
-
2151//#include "ffft/FFTRealFixLenParam.hpp"
-
2152
+
2151
+
2152/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2153
-
2154
-
2155#endif // ffft_FFTRealFixLenParam_HEADER_INCLUDED
+
2154protected:
+
2155
2156
2157
-
2158
-
2159/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2160
-
2161/*****************************************************************************
-
2162
-
2163 OscSinCos.h
-
2164 By Laurent de Soras
-
2165
-
2166--- Legal stuff ---
-
2167
-
2168This program is free software. It comes without any warranty, to
-
2169the extent permitted by applicable law. You can redistribute it
-
2170and/or modify it under the terms of the Do What The Fuck You Want
-
2171To Public License, Version 2, as published by Sam Hocevar. See
-
2172http://sam.zoy.org/wtfpl/COPYING for more details.
-
2173
-
2174*Tab=3***********************************************************************/
-
2175
+
2158/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2159
+
2160private:
+
2161
+
2162
+
2163
+
2164/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
2165
+
2166private:
+
2167
+ + + +
2171 operator = (const FFTRealFixLenParam &other);
+
2172 bool operator == (const FFTRealFixLenParam &other);
+
2173 bool operator != (const FFTRealFixLenParam &other);
+
2174
+
2175}; // class FFTRealFixLenParam
+
2176
2177
-
2178#if ! defined (ffft_OscSinCos_HEADER_INCLUDED)
-
2179#define ffft_OscSinCos_HEADER_INCLUDED
+
2178
+
2179} // namespace ffft
2180
-
2181#if defined (_MSC_VER)
-
2182 #pragma once
-
2183 #pragma warning (4 : 4250) // "Inherits via dominance."
-
2184#endif
+
2181
+
2182
+
2183//#include "ffft/FFTRealFixLenParam.hpp"
+
2184
2185
2186
-
2187
-
2188/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2187#endif // ffft_FFTRealFixLenParam_HEADER_INCLUDED
+
2188
2189
2190
-
2191
+
2191/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2192
-
2193
-
2194namespace ffft
-
2195{
-
2196
-
2197
-
2198
-
2199template <class T>
-
2200class OscSinCos
-
2201{
-
2202
-
2203/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2204
-
2205public:
-
2206
-
2207 typedef T DataType;
+
2193/*****************************************************************************
+
2194
+
2195 OscSinCos.h
+
2196 By Laurent de Soras
+
2197
+
2198--- Legal stuff ---
+
2199
+
2200This program is free software. It comes without any warranty, to
+
2201the extent permitted by applicable law. You can redistribute it
+
2202and/or modify it under the terms of the Do What The Fuck You Want
+
2203To Public License, Version 2, as published by Sam Hocevar. See
+
2204http://sam.zoy.org/wtfpl/COPYING for more details.
+
2205
+
2206*Tab=3***********************************************************************/
+
2207
2208
-
2209 OscSinCos ();
-
2210
-
2211 ffft_FORCEINLINE void
-
2212 set_step (double angle_rad);
-
2213
-
2214 ffft_FORCEINLINE DataType
-
2215 get_cos () const;
-
2216 ffft_FORCEINLINE DataType
-
2217 get_sin () const;
-
2218 ffft_FORCEINLINE void
-
2219 step ();
-
2220 ffft_FORCEINLINE void
-
2221 clear_buffers ();
+
2209
+
2210#if ! defined (ffft_OscSinCos_HEADER_INCLUDED)
+
2211#define ffft_OscSinCos_HEADER_INCLUDED
+
2212
+
2213#if defined (_MSC_VER)
+
2214 #pragma once
+
2215 #pragma warning (4 : 4250) // "Inherits via dominance."
+
2216#endif
+
2217
+
2218
+
2219
+
2220/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2221
2222
2223
2224
-
2225/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2226
-
2227protected:
+
2225
+
2226namespace ffft
+
2227{
2228
2229
2230
-
2231/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2232
-
2233private:
+
2231template <class T>
+
2232class OscSinCos
+
2233{
2234
-
2235 DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1]
-
2236 DataType _pos_sin; // -
-
2237 DataType _step_cos; // Phase increment per step, [-1 ; 1]
-
2238 DataType _step_sin; // -
-
2239
+
2235/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2236
+
2237public:
+
2238
+
2239 typedef T DataType;
2240
-
2241
-
2242/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
-
2243
-
2244private:
+
2241 OscSinCos ();
+
2242
+
2243 ffft_FORCEINLINE void
+
2244 set_step (double angle_rad);
2245
-
2246 OscSinCos (const OscSinCos &other);
-
2247 OscSinCos & operator = (const OscSinCos &other);
-
2248 bool operator == (const OscSinCos &other);
-
2249 bool operator != (const OscSinCos &other);
-
2250
-
2251}; // class OscSinCos
-
2252
-
2253
+
2246 ffft_FORCEINLINE DataType
+
2247 get_cos () const;
+
2248 ffft_FORCEINLINE DataType
+
2249 get_sin () const;
+
2250 ffft_FORCEINLINE void
+
2251 step ();
+
2252 ffft_FORCEINLINE void
+
2253 clear_buffers ();
2254
-
2255} // namespace ffft
+
2255
2256
-
2257
+
2257/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2258
-
2259/*****************************************************************************
-
2260
-
2261 OscSinCos.hpp
-
2262 By Laurent de Soras
-
2263
-
2264--- Legal stuff ---
-
2265
-
2266This program is free software. It comes without any warranty, to
-
2267the extent permitted by applicable law. You can redistribute it
-
2268and/or modify it under the terms of the Do What The Fuck You Want
-
2269To Public License, Version 2, as published by Sam Hocevar. See
-
2270http://sam.zoy.org/wtfpl/COPYING for more details.
-
2271
-
2272*Tab=3***********************************************************************/
+
2259protected:
+
2260
+
2261
+
2262
+
2263/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2264
+
2265private:
+
2266
+
2267 DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1]
+
2268 DataType _pos_sin; // -
+
2269 DataType _step_cos; // Phase increment per step, [-1 ; 1]
+
2270 DataType _step_sin; // -
+
2271
+
2272
2273
-
2274
+
2274/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
2275
-
2276#if defined (ffft_OscSinCos_CURRENT_CODEHEADER)
-
2277 #error Recursive inclusion of OscSinCos code header.
-
2278#endif
-
2279#define ffft_OscSinCos_CURRENT_CODEHEADER
-
2280
-
2281#if ! defined (ffft_OscSinCos_CODEHEADER_INCLUDED)
-
2282#define ffft_OscSinCos_CODEHEADER_INCLUDED
-
2283
+
2276private:
+
2277
+
2278 OscSinCos (const OscSinCos &other);
+
2279 OscSinCos & operator = (const OscSinCos &other);
+
2280 bool operator == (const OscSinCos &other);
+
2281 bool operator != (const OscSinCos &other);
+
2282
+
2283}; // class OscSinCos
2284
2285
-
2286/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2287
-
2288#include <cmath>
+
2286
+
2287} // namespace ffft
+
2288
2289
-
2290namespace std { }
-
2291
-
2292
-
2293
-
2294namespace ffft
-
2295{
-
2296
-
2297
-
2298
-
2299/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2300
-
2301
-
2302
-
2303template <class T>
-
2304OscSinCos <T>::OscSinCos ()
-
2305: _pos_cos (1)
-
2306, _pos_sin (0)
-
2307, _step_cos (1)
-
2308, _step_sin (0)
-
2309{
-
2310 // Nothing
-
2311}
+
2290
+
2291/*****************************************************************************
+
2292
+
2293 OscSinCos.hpp
+
2294 By Laurent de Soras
+
2295
+
2296--- Legal stuff ---
+
2297
+
2298This program is free software. It comes without any warranty, to
+
2299the extent permitted by applicable law. You can redistribute it
+
2300and/or modify it under the terms of the Do What The Fuck You Want
+
2301To Public License, Version 2, as published by Sam Hocevar. See
+
2302http://sam.zoy.org/wtfpl/COPYING for more details.
+
2303
+
2304*Tab=3***********************************************************************/
+
2305
+
2306
+
2307
+
2308#if defined (ffft_OscSinCos_CURRENT_CODEHEADER)
+
2309 #error Recursive inclusion of OscSinCos code header.
+
2310#endif
+
2311#define ffft_OscSinCos_CURRENT_CODEHEADER
2312
-
2313
-
2314
-
2315template <class T>
-
2316void OscSinCos <T>::set_step (double angle_rad)
-
2317{
-
2318 using namespace std;
+
2313#if ! defined (ffft_OscSinCos_CODEHEADER_INCLUDED)
+
2314#define ffft_OscSinCos_CODEHEADER_INCLUDED
+
2315
+
2316
+
2317
+
2318/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2319
-
2320 _step_cos = static_cast <DataType> (cos (angle_rad));
-
2321 _step_sin = static_cast <DataType> (sin (angle_rad));
-
2322}
+
2320#include <cmath>
+
2321
+
2322namespace std { }
2323
2324
2325
-
2326template <class T>
-
2327typename OscSinCos <T>::DataType OscSinCos <T>::get_cos () const
-
2328{
-
2329 return (_pos_cos);
-
2330}
-
2331
+
2326namespace ffft
+
2327{
+
2328
+
2329
+
2330
+
2331/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2332
2333
-
2334template <class T>
-
2335typename OscSinCos <T>::DataType OscSinCos <T>::get_sin () const
-
2336{
-
2337 return (_pos_sin);
-
2338}
-
2339
-
2340
-
2341
-
2342template <class T>
-
2343void OscSinCos <T>::step ()
-
2344{
-
2345 const DataType old_cos = _pos_cos;
-
2346 const DataType old_sin = _pos_sin;
-
2347
-
2348 _pos_cos = old_cos * _step_cos - old_sin * _step_sin;
-
2349 _pos_sin = old_cos * _step_sin + old_sin * _step_cos;
-
2350}
+
2334
+
2335template <class T>
+
2336OscSinCos <T>::OscSinCos ()
+
2337: _pos_cos (1)
+
2338, _pos_sin (0)
+
2339, _step_cos (1)
+
2340, _step_sin (0)
+
2341{
+
2342 // Nothing
+
2343}
+
2344
+
2345
+
2346
+
2347template <class T>
+
2348void OscSinCos <T>::set_step (double angle_rad)
+
2349{
+
2350 using namespace std;
2351
-
2352
-
2353
-
2354template <class T>
-
2355void OscSinCos <T>::clear_buffers ()
-
2356{
-
2357 _pos_cos = static_cast <DataType> (1);
-
2358 _pos_sin = static_cast <DataType> (0);
-
2359}
-
2360
-
2361
-
2362
-
2363/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2352 _step_cos = static_cast <DataType> (cos (angle_rad));
+
2353 _step_sin = static_cast <DataType> (sin (angle_rad));
+
2354}
+
2355
+
2356
+
2357
+
2358template <class T>
+
2359typename OscSinCos <T>::DataType OscSinCos <T>::get_cos () const
+
2360{
+
2361 return (_pos_cos);
+
2362}
+
2363
2364
2365
-
2366
-
2367/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2368
-
2369
-
2370
-
2371} // namespace ffft
+
2366template <class T>
+
2367typename OscSinCos <T>::DataType OscSinCos <T>::get_sin () const
+
2368{
+
2369 return (_pos_sin);
+
2370}
+
2371
2372
2373
-
2374
-
2375#endif // ffft_OscSinCos_CODEHEADER_INCLUDED
-
2376
-
2377#undef ffft_OscSinCos_CURRENT_CODEHEADER
-
2378
+
2374template <class T>
+
2375void OscSinCos <T>::step ()
+
2376{
+
2377 const DataType old_cos = _pos_cos;
+
2378 const DataType old_sin = _pos_sin;
2379
-
2380
-
2381/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2382
+
2380 _pos_cos = old_cos * _step_cos - old_sin * _step_sin;
+
2381 _pos_sin = old_cos * _step_sin + old_sin * _step_cos;
+
2382}
2383
2384
2385
-
2386#endif // ffft_OscSinCos_HEADER_INCLUDED
-
2387
-
2388
-
2389
-
2390/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2391
+
2386template <class T>
+
2387void OscSinCos <T>::clear_buffers ()
+
2388{
+
2389 _pos_cos = static_cast <DataType> (1);
+
2390 _pos_sin = static_cast <DataType> (0);
+
2391}
2392
2393
2394
-
2395namespace ffft
-
2396{
+
2395/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2396
2397
2398
-
2399
-
2400template <int LL2>
-
- -
2402{
-
2403 typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1];
-
2404 typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1];
+
2399/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2400
+
2401
+
2402
+
2403} // namespace ffft
+
2404
2405
-
2406/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2407
-
2408public:
-
2409
-
2410 typedef FFTRealFixLenParam::DataType DataType;
-
2411 typedef OscSinCos <DataType> OscType;
+
2406
+
2407#endif // ffft_OscSinCos_CODEHEADER_INCLUDED
+
2408
+
2409#undef ffft_OscSinCos_CURRENT_CODEHEADER
+
2410
+
2411
2412
-
2413 enum { FFT_LEN_L2 = LL2 };
-
2414 enum { FFT_LEN = 1 << FFT_LEN_L2 };
+
2413/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2414
2415
-
2416 FFTRealFixLen ();
+
2416
2417
-
2418 inline long get_length () const;
-
2419 void do_fft (DataType f [], const DataType x []);
-
2420 void do_ifft (const DataType f [], DataType x []);
-
2421 void rescale (DataType x []) const;
-
2422
+
2418#endif // ffft_OscSinCos_HEADER_INCLUDED
+
2419
+
2420
+
2421
+
2422/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2423
2424
-
2425/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2425
2426
-
2427protected:
-
2428
+
2427namespace ffft
+
2428{
2429
2430
-
2431/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2432
-
2433private:
-
2434
-
2435 enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT };
-
2436
-
2437 enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) };
-
2438 enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 };
+
2431
+
2432template <int LL2>
+
+ +
2434{
+
2435 typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1];
+
2436 typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1];
+
2437
+
2438/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2439
-
2440 enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0)
-
2441 ? (int)FFT_LEN_L2
-
2442 : (int)TRIGO_BD_LIMIT };
-
2443 enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) };
-
2444 enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 };
-
2445
-
2446 enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD };
-
2447 enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 };
-
2448
-
2449 void build_br_lut ();
-
2450 void build_trigo_lut ();
-
2451 void build_trigo_osc ();
-
2452
-
2453 DynArray <DataType>
-
2454 _buffer;
-
2455 DynArray <long>
-
2456 _br_data;
-
2457 DynArray <DataType>
-
2458 _trigo_data;
-
2459 Array <OscType, TRIGO_OSC_ARR_SIZE>
-
2460 _trigo_osc;
+
2440public:
+
2441
+
2442 typedef FFTRealFixLenParam::DataType DataType;
+
2443 typedef OscSinCos <DataType> OscType;
+
2444
+
2445 enum { FFT_LEN_L2 = LL2 };
+
2446 enum { FFT_LEN = 1 << FFT_LEN_L2 };
+
2447
+
2448 FFTRealFixLen ();
+
2449
+
2450 inline long get_length () const;
+
2451 void do_fft (DataType f [], const DataType x []);
+
2452 void do_ifft (const DataType f [], DataType x []);
+
2453 void rescale (DataType x []) const;
+
2454
+
2455
+
2456
+
2457/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2458
+
2459protected:
+
2460
2461
2462
-
2463
-
2464/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
-
2465
-
2466private:
-
2467
-
2468 FFTRealFixLen (const FFTRealFixLen &other);
-
2469 FFTRealFixLen& operator = (const FFTRealFixLen &other);
-
2470 bool operator == (const FFTRealFixLen &other);
-
2471 bool operator != (const FFTRealFixLen &other);
-
2472
-
2473}; // class FFTRealFixLen
-
-
2474
-
2475
-
2476
-
2477} // namespace ffft
-
2478
-
2479
+
2463/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2464
+
2465private:
+
2466
+
2467 enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT };
+
2468
+
2469 enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) };
+
2470 enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 };
+
2471
+
2472 enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0)
+
2473 ? (int)FFT_LEN_L2
+
2474 : (int)TRIGO_BD_LIMIT };
+
2475 enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) };
+
2476 enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 };
+
2477
+
2478 enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD };
+
2479 enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 };
2480
-
2481/*****************************************************************************
-
2482
-
2483 FFTRealFixLen.hpp
-
2484 By Laurent de Soras
-
2485
-
2486--- Legal stuff ---
-
2487
-
2488This program is free software. It comes without any warranty, to
-
2489the extent permitted by applicable law. You can redistribute it
-
2490and/or modify it under the terms of the Do What The Fuck You Want
-
2491To Public License, Version 2, as published by Sam Hocevar. See
-
2492http://sam.zoy.org/wtfpl/COPYING for more details.
-
2493
-
2494*Tab=3***********************************************************************/
+
2481 void build_br_lut ();
+
2482 void build_trigo_lut ();
+
2483 void build_trigo_osc ();
+
2484
+
2485 DynArray <DataType>
+
2486 _buffer;
+
2487 DynArray <long>
+
2488 _br_data;
+
2489 DynArray <DataType>
+
2490 _trigo_data;
+
2491 Array <OscType, TRIGO_OSC_ARR_SIZE>
+
2492 _trigo_osc;
+
2493
+
2494
2495
-
2496
+
2496/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
2497
-
2498#if defined (ffft_FFTRealFixLen_CURRENT_CODEHEADER)
-
2499 #error Recursive inclusion of FFTRealFixLen code header.
-
2500#endif
-
2501#define ffft_FFTRealFixLen_CURRENT_CODEHEADER
-
2502
-
2503#if ! defined (ffft_FFTRealFixLen_CODEHEADER_INCLUDED)
-
2504#define ffft_FFTRealFixLen_CODEHEADER_INCLUDED
-
2505
+
2498private:
+
2499
+
2500 FFTRealFixLen (const FFTRealFixLen &other);
+
2501 FFTRealFixLen& operator = (const FFTRealFixLen &other);
+
2502 bool operator == (const FFTRealFixLen &other);
+
2503 bool operator != (const FFTRealFixLen &other);
+
2504
+
2505}; // class FFTRealFixLen
+
2506
2507
-
2508/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2509
+
2508
+
2509} // namespace ffft
2510
-
2511/*****************************************************************************
-
2512
-
2513 FFTRealPassDirect.h
-
2514 By Laurent de Soras
-
2515
-
2516--- Legal stuff ---
+
2511
+
2512
+
2513/*****************************************************************************
+
2514
+
2515 FFTRealFixLen.hpp
+
2516 By Laurent de Soras
2517
-
2518This program is free software. It comes without any warranty, to
-
2519the extent permitted by applicable law. You can redistribute it
-
2520and/or modify it under the terms of the Do What The Fuck You Want
-
2521To Public License, Version 2, as published by Sam Hocevar. See
-
2522http://sam.zoy.org/wtfpl/COPYING for more details.
-
2523
-
2524*Tab=3***********************************************************************/
-
2525
-
2526
+
2518--- Legal stuff ---
+
2519
+
2520This program is free software. It comes without any warranty, to
+
2521the extent permitted by applicable law. You can redistribute it
+
2522and/or modify it under the terms of the Do What The Fuck You Want
+
2523To Public License, Version 2, as published by Sam Hocevar. See
+
2524http://sam.zoy.org/wtfpl/COPYING for more details.
+
2525
+
2526*Tab=3***********************************************************************/
2527
-
2528#if ! defined (ffft_FFTRealPassDirect_HEADER_INCLUDED)
-
2529#define ffft_FFTRealPassDirect_HEADER_INCLUDED
-
2530
-
2531#if defined (_MSC_VER)
-
2532 #pragma once
-
2533 #pragma warning (4 : 4250) // "Inherits via dominance."
-
2534#endif
-
2535
-
2536
+
2528
+
2529
+
2530#if defined (ffft_FFTRealFixLen_CURRENT_CODEHEADER)
+
2531 #error Recursive inclusion of FFTRealFixLen code header.
+
2532#endif
+
2533#define ffft_FFTRealFixLen_CURRENT_CODEHEADER
+
2534
+
2535#if ! defined (ffft_FFTRealFixLen_CODEHEADER_INCLUDED)
+
2536#define ffft_FFTRealFixLen_CODEHEADER_INCLUDED
2537
-
2538/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2538
2539
-
2540
+
2540/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2541
2542
-
2543
-
2544
-
2545
-
2546namespace ffft
-
2547{
-
2548
-
2549
-
2550
-
2551template <int PASS>
-
- -
2553{
-
2554
-
2555/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2556
-
2557public:
+
2543/*****************************************************************************
+
2544
+
2545 FFTRealPassDirect.h
+
2546 By Laurent de Soras
+
2547
+
2548--- Legal stuff ---
+
2549
+
2550This program is free software. It comes without any warranty, to
+
2551the extent permitted by applicable law. You can redistribute it
+
2552and/or modify it under the terms of the Do What The Fuck You Want
+
2553To Public License, Version 2, as published by Sam Hocevar. See
+
2554http://sam.zoy.org/wtfpl/COPYING for more details.
+
2555
+
2556*Tab=3***********************************************************************/
+
2557
2558
-
2559 typedef FFTRealFixLenParam::DataType DataType;
-
2560 typedef OscSinCos <DataType> OscType;
-
2561
-
2562 ffft_FORCEINLINE static void
-
2563 process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
-
2564
-
2565
-
2566
-
2567/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2559
+
2560#if ! defined (ffft_FFTRealPassDirect_HEADER_INCLUDED)
+
2561#define ffft_FFTRealPassDirect_HEADER_INCLUDED
+
2562
+
2563#if defined (_MSC_VER)
+
2564 #pragma once
+
2565 #pragma warning (4 : 4250) // "Inherits via dominance."
+
2566#endif
+
2567
2568
-
2569protected:
-
2570
+
2569
+
2570/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2571
2572
-
2573/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2573
2574
-
2575private:
+
2575
2576
2577
-
2578
-
2579/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
2578namespace ffft
+
2579{
2580
-
2581private:
+
2581
2582
- -
2584 FFTRealPassDirect (const FFTRealPassDirect &other);
- -
2586 operator = (const FFTRealPassDirect &other);
-
2587 bool operator == (const FFTRealPassDirect &other);
-
2588 bool operator != (const FFTRealPassDirect &other);
-
2589
-
2590}; // class FFTRealPassDirect
-
-
2591
-
2592
+
2583template <int PASS>
+
+ +
2585{
+
2586
+
2587/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2588
+
2589public:
+
2590
+
2591 typedef FFTRealFixLenParam::DataType DataType;
+
2592 typedef OscSinCos <DataType> OscType;
2593
-
2594} // namespace ffft
-
2595
+
2594 ffft_FORCEINLINE static void
+
2595 process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
2596
2597
-
2598/*****************************************************************************
-
2599
-
2600 FFTRealPassDirect.hpp
-
2601 By Laurent de Soras
-
2602
-
2603--- Legal stuff ---
-
2604
-
2605This program is free software. It comes without any warranty, to
-
2606the extent permitted by applicable law. You can redistribute it
-
2607and/or modify it under the terms of the Do What The Fuck You Want
-
2608To Public License, Version 2, as published by Sam Hocevar. See
-
2609http://sam.zoy.org/wtfpl/COPYING for more details.
-
2610
-
2611*Tab=3***********************************************************************/
+
2598
+
2599/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2600
+
2601protected:
+
2602
+
2603
+
2604
+
2605/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2606
+
2607private:
+
2608
+
2609
+
2610
+
2611/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
2612
-
2613
+
2613private:
2614
-
2615#if defined (ffft_FFTRealPassDirect_CURRENT_CODEHEADER)
-
2616 #error Recursive inclusion of FFTRealPassDirect code header.
-
2617#endif
-
2618#define ffft_FFTRealPassDirect_CURRENT_CODEHEADER
-
2619
-
2620#if ! defined (ffft_FFTRealPassDirect_CODEHEADER_INCLUDED)
-
2621#define ffft_FFTRealPassDirect_CODEHEADER_INCLUDED
-
2622
+ +
2616 FFTRealPassDirect (const FFTRealPassDirect &other);
+ +
2618 operator = (const FFTRealPassDirect &other);
+
2619 bool operator == (const FFTRealPassDirect &other);
+
2620 bool operator != (const FFTRealPassDirect &other);
+
2621
+
2622}; // class FFTRealPassDirect
+
2623
2624
-
2625/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2626
-
2627/*****************************************************************************
-
2628
-
2629 FFTRealUseTrigo.h
-
2630 By Laurent de Soras
+
2625
+
2626} // namespace ffft
+
2627
+
2628
+
2629
+
2630/*****************************************************************************
2631
-
2632--- Legal stuff ---
-
2633
-
2634This program is free software. It comes without any warranty, to
-
2635the extent permitted by applicable law. You can redistribute it
-
2636and/or modify it under the terms of the Do What The Fuck You Want
-
2637To Public License, Version 2, as published by Sam Hocevar. See
-
2638http://sam.zoy.org/wtfpl/COPYING for more details.
-
2639
-
2640*Tab=3***********************************************************************/
-
2641
-
2642
-
2643
-
2644#if ! defined (ffft_FFTRealUseTrigo_HEADER_INCLUDED)
-
2645#define ffft_FFTRealUseTrigo_HEADER_INCLUDED
+
2632 FFTRealPassDirect.hpp
+
2633 By Laurent de Soras
+
2634
+
2635--- Legal stuff ---
+
2636
+
2637This program is free software. It comes without any warranty, to
+
2638the extent permitted by applicable law. You can redistribute it
+
2639and/or modify it under the terms of the Do What The Fuck You Want
+
2640To Public License, Version 2, as published by Sam Hocevar. See
+
2641http://sam.zoy.org/wtfpl/COPYING for more details.
+
2642
+
2643*Tab=3***********************************************************************/
+
2644
+
2645
2646
-
2647#if defined (_MSC_VER)
-
2648 #pragma once
-
2649 #pragma warning (4 : 4250) // "Inherits via dominance."
-
2650#endif
+
2647#if defined (ffft_FFTRealPassDirect_CURRENT_CODEHEADER)
+
2648 #error Recursive inclusion of FFTRealPassDirect code header.
+
2649#endif
+
2650#define ffft_FFTRealPassDirect_CURRENT_CODEHEADER
2651
-
2652
-
2653
-
2654/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2652#if ! defined (ffft_FFTRealPassDirect_CODEHEADER_INCLUDED)
+
2653#define ffft_FFTRealPassDirect_CODEHEADER_INCLUDED
+
2654
2655
2656
-
2657
+
2657/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2658
-
2659
-
2660
-
2661
-
2662namespace ffft
-
2663{
-
2664
-
2665
-
2666
-
2667template <int ALGO>
-
- -
2669{
-
2670
-
2671/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2672
-
2673public:
+
2659/*****************************************************************************
+
2660
+
2661 FFTRealUseTrigo.h
+
2662 By Laurent de Soras
+
2663
+
2664--- Legal stuff ---
+
2665
+
2666This program is free software. It comes without any warranty, to
+
2667the extent permitted by applicable law. You can redistribute it
+
2668and/or modify it under the terms of the Do What The Fuck You Want
+
2669To Public License, Version 2, as published by Sam Hocevar. See
+
2670http://sam.zoy.org/wtfpl/COPYING for more details.
+
2671
+
2672*Tab=3***********************************************************************/
+
2673
2674
-
2675 typedef FFTRealFixLenParam::DataType DataType;
-
2676 typedef OscSinCos <DataType> OscType;
-
2677
-
2678 ffft_FORCEINLINE static void
-
2679 prepare (OscType &osc);
-
2680 ffft_FORCEINLINE static void
-
2681 iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s);
-
2682
+
2675
+
2676#if ! defined (ffft_FFTRealUseTrigo_HEADER_INCLUDED)
+
2677#define ffft_FFTRealUseTrigo_HEADER_INCLUDED
+
2678
+
2679#if defined (_MSC_VER)
+
2680 #pragma once
+
2681 #pragma warning (4 : 4250) // "Inherits via dominance."
+
2682#endif
2683
2684
-
2685/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2686
-
2687protected:
+
2685
+
2686/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2687
2688
2689
2690
-
2691/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2691
2692
-
2693private:
-
2694
-
2695
+
2693
+
2694namespace ffft
+
2695{
2696
-
2697/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
2697
2698
-
2699private:
-
2700
-
2701 FFTRealUseTrigo ();
- -
2703 FFTRealUseTrigo (const FFTRealUseTrigo &other);
- -
2705 operator = (const FFTRealUseTrigo &other);
-
2706 bool operator == (const FFTRealUseTrigo &other);
-
2707 bool operator != (const FFTRealUseTrigo &other);
-
2708
-
2709}; // class FFTRealUseTrigo
-
-
2710
-
2711
-
2712
-
2713} // namespace ffft
+
2699template <int ALGO>
+
+ +
2701{
+
2702
+
2703/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2704
+
2705public:
+
2706
+
2707 typedef FFTRealFixLenParam::DataType DataType;
+
2708 typedef OscSinCos <DataType> OscType;
+
2709
+
2710 ffft_FORCEINLINE static void
+
2711 prepare (OscType &osc);
+
2712 ffft_FORCEINLINE static void
+
2713 iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s);
2714
2715
2716
-
2717/*****************************************************************************
-
2718
-
2719 FFTRealUseTrigo.hpp
-
2720 By Laurent de Soras
-
2721
-
2722--- Legal stuff ---
-
2723
-
2724This program is free software. It comes without any warranty, to
-
2725the extent permitted by applicable law. You can redistribute it
-
2726and/or modify it under the terms of the Do What The Fuck You Want
-
2727To Public License, Version 2, as published by Sam Hocevar. See
-
2728http://sam.zoy.org/wtfpl/COPYING for more details.
-
2729
-
2730*Tab=3***********************************************************************/
-
2731
+
2717/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2718
+
2719protected:
+
2720
+
2721
+
2722
+
2723/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2724
+
2725private:
+
2726
+
2727
+
2728
+
2729/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
2730
+
2731private:
2732
-
2733
-
2734#if defined (ffft_FFTRealUseTrigo_CURRENT_CODEHEADER)
-
2735 #error Recursive inclusion of FFTRealUseTrigo code header.
-
2736#endif
-
2737#define ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
-
2738
-
2739#if ! defined (ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED)
-
2740#define ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
-
2741
+
2733 FFTRealUseTrigo ();
+ +
2735 FFTRealUseTrigo (const FFTRealUseTrigo &other);
+ +
2737 operator = (const FFTRealUseTrigo &other);
+
2738 bool operator == (const FFTRealUseTrigo &other);
+
2739 bool operator != (const FFTRealUseTrigo &other);
+
2740
+
2741}; // class FFTRealUseTrigo
+
2742
2743
-
2744/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2745
+
2744
+
2745} // namespace ffft
2746
2747
2748
-
2749
-
2750namespace ffft
-
2751{
-
2752
-
2753
-
2754
-
2755/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2756
-
2757
-
2758
-
2759template <int ALGO>
-
2760void FFTRealUseTrigo <ALGO>::prepare (OscType &osc)
-
2761{
-
2762 osc.clear_buffers ();
-
2763}
+
2749/*****************************************************************************
+
2750
+
2751 FFTRealUseTrigo.hpp
+
2752 By Laurent de Soras
+
2753
+
2754--- Legal stuff ---
+
2755
+
2756This program is free software. It comes without any warranty, to
+
2757the extent permitted by applicable law. You can redistribute it
+
2758and/or modify it under the terms of the Do What The Fuck You Want
+
2759To Public License, Version 2, as published by Sam Hocevar. See
+
2760http://sam.zoy.org/wtfpl/COPYING for more details.
+
2761
+
2762*Tab=3***********************************************************************/
+
2763
2764
-
2765template <>
-
2766inline void FFTRealUseTrigo <0>::prepare (OscType &osc)
-
2767{
-
2768 // Nothing
-
2769}
+
2765
+
2766#if defined (ffft_FFTRealUseTrigo_CURRENT_CODEHEADER)
+
2767 #error Recursive inclusion of FFTRealUseTrigo code header.
+
2768#endif
+
2769#define ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
2770
-
2771
-
2772
-
2773template <int ALGO>
-
2774void FFTRealUseTrigo <ALGO>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
-
2775{
-
2776 osc.step ();
-
2777 c = osc.get_cos ();
-
2778 s = osc.get_sin ();
-
2779}
+
2771#if ! defined (ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED)
+
2772#define ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
+
2773
+
2774
+
2775
+
2776/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2777
+
2778
+
2779
2780
-
2781template <>
-
2782inline void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
+
2781
+
2782namespace ffft
2783{
-
2784 c = cos_ptr [index_c];
-
2785 s = cos_ptr [index_s];
-
2786}
-
2787
+
2784
+
2785
+
2786
+
2787/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2788
2789
-
2790/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2791
-
2792
-
2793
-
2794/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2795
+
2790
+
2791template <int ALGO>
+
2792void FFTRealUseTrigo <ALGO>::prepare (OscType &osc)
+
2793{
+
2794 osc.clear_buffers ();
+
2795}
2796
-
2797
-
2798} // namespace ffft
-
2799
-
2800
-
2801
-
2802#endif // ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
+
2797template <>
+
2798inline void FFTRealUseTrigo <0>::prepare (OscType &osc)
+
2799{
+
2800 // Nothing
+
2801}
+
2802
2803
-
2804#undef ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
-
2805
-
2806
-
2807
-
2808/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2809
-
2810
-
2811
+
2804
+
2805template <int ALGO>
+
2806void FFTRealUseTrigo <ALGO>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
+
2807{
+
2808 osc.step ();
+
2809 c = osc.get_cos ();
+
2810 s = osc.get_sin ();
+
2811}
2812
-
2813#endif // ffft_FFTRealUseTrigo_HEADER_INCLUDED
-
2814
-
2815
-
2816
-
2817/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2818
+
2813template <>
+
2814inline void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
+
2815{
+
2816 c = cos_ptr [index_c];
+
2817 s = cos_ptr [index_s];
+
2818}
2819
2820
2821
-
2822namespace ffft
-
2823{
+
2822/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2823
2824
2825
-
2826
-
2827/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2826/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2827
2828
2829
-
2830
-
2831template <>
-
2832inline void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
2833{
-
2834 // First and second pass at once
-
2835 const long qlen = len >> 2;
-
2836
-
2837 long coef_index = 0;
-
2838 do
-
2839 {
-
2840 // To do: unroll the loop (2x).
-
2841 const long ri_0 = br_ptr [coef_index >> 2];
-
2842 const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1];
-
2843 const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2];
-
2844 const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3];
-
2845
-
2846 DataType * const df2 = dest_ptr + coef_index;
-
2847 df2 [1] = x_ptr [ri_0] - x_ptr [ri_1];
-
2848 df2 [3] = x_ptr [ri_2] - x_ptr [ri_3];
-
2849
-
2850 const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1];
-
2851 const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3];
+
2830} // namespace ffft
+
2831
+
2832
+
2833
+
2834#endif // ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
+
2835
+
2836#undef ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
+
2837
+
2838
+
2839
+
2840/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2841
+
2842
+
2843
+
2844
+
2845#endif // ffft_FFTRealUseTrigo_HEADER_INCLUDED
+
2846
+
2847
+
2848
+
2849/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2850
+
2851
2852
-
2853 df2 [0] = sf_0 + sf_2;
-
2854 df2 [2] = sf_0 - sf_2;
-
2855
-
2856 coef_index += 4;
-
2857 }
-
2858 while (coef_index < len);
-
2859}
+
2853
+
2854namespace ffft
+
2855{
+
2856
+
2857
+
2858
+
2859/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
2860
-
2861template <>
-
2862inline void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
2863{
-
2864 // Executes "previous" passes first. Inverts source and destination buffers
-
2865 FFTRealPassDirect <1>::process (
-
2866 len,
-
2867 src_ptr,
-
2868 dest_ptr,
-
2869 x_ptr,
-
2870 cos_ptr,
-
2871 cos_len,
-
2872 br_ptr,
-
2873 osc_list
-
2874 );
-
2875
-
2876 // Third pass
-
2877 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
-
2878
-
2879 long coef_index = 0;
-
2880 do
-
2881 {
-
2882 dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4];
-
2883 dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4];
-
2884 dest_ptr [coef_index + 2] = src_ptr [coef_index + 2];
-
2885 dest_ptr [coef_index + 6] = src_ptr [coef_index + 6];
-
2886
-
2887 DataType v;
-
2888
-
2889 v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2;
-
2890 dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v;
-
2891 dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v;
+
2861
+
2862
+
2863template <>
+
2864inline void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
2865{
+
2866 // First and second pass at once
+
2867 const long qlen = len >> 2;
+
2868
+
2869 long coef_index = 0;
+
2870 do
+
2871 {
+
2872 // To do: unroll the loop (2x).
+
2873 const long ri_0 = br_ptr [coef_index >> 2];
+
2874 const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1];
+
2875 const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2];
+
2876 const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3];
+
2877
+
2878 DataType * const df2 = dest_ptr + coef_index;
+
2879 df2 [1] = x_ptr [ri_0] - x_ptr [ri_1];
+
2880 df2 [3] = x_ptr [ri_2] - x_ptr [ri_3];
+
2881
+
2882 const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1];
+
2883 const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3];
+
2884
+
2885 df2 [0] = sf_0 + sf_2;
+
2886 df2 [2] = sf_0 - sf_2;
+
2887
+
2888 coef_index += 4;
+
2889 }
+
2890 while (coef_index < len);
+
2891}
2892
-
2893 v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2;
-
2894 dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3];
-
2895 dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3];
-
2896
-
2897 coef_index += 8;
-
2898 }
-
2899 while (coef_index < len);
-
2900}
-
2901
-
2902template <int PASS>
-
2903void FFTRealPassDirect <PASS>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
2904{
-
2905 // Executes "previous" passes first. Inverts source and destination buffers
-
2906 FFTRealPassDirect <PASS - 1>::process (
-
2907 len,
-
2908 src_ptr,
-
2909 dest_ptr,
-
2910 x_ptr,
-
2911 cos_ptr,
-
2912 cos_len,
-
2913 br_ptr,
-
2914 osc_list
-
2915 );
-
2916
-
2917 const long dist = 1L << (PASS - 1);
-
2918 const long c1_r = 0;
-
2919 const long c1_i = dist;
-
2920 const long c2_r = dist * 2;
-
2921 const long c2_i = dist * 3;
-
2922 const long cend = dist * 4;
-
2923 const long table_step = cos_len >> (PASS - 1);
+
2893template <>
+
2894inline void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
2895{
+
2896 // Executes "previous" passes first. Inverts source and destination buffers
+
2897 FFTRealPassDirect <1>::process (
+
2898 len,
+
2899 src_ptr,
+
2900 dest_ptr,
+
2901 x_ptr,
+
2902 cos_ptr,
+
2903 cos_len,
+
2904 br_ptr,
+
2905 osc_list
+
2906 );
+
2907
+
2908 // Third pass
+
2909 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
+
2910
+
2911 long coef_index = 0;
+
2912 do
+
2913 {
+
2914 dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4];
+
2915 dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4];
+
2916 dest_ptr [coef_index + 2] = src_ptr [coef_index + 2];
+
2917 dest_ptr [coef_index + 6] = src_ptr [coef_index + 6];
+
2918
+
2919 DataType v;
+
2920
+
2921 v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2;
+
2922 dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v;
+
2923 dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v;
2924
-
2925 enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT };
-
2926 enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 };
-
2927
-
2928 long coef_index = 0;
-
2929 do
-
2930 {
-
2931 const DataType * const sf = src_ptr + coef_index;
-
2932 DataType * const df = dest_ptr + coef_index;
+
2925 v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2;
+
2926 dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3];
+
2927 dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3];
+
2928
+
2929 coef_index += 8;
+
2930 }
+
2931 while (coef_index < len);
+
2932}
2933
-
2934 // Extreme coefficients are always real
-
2935 df [c1_r] = sf [c1_r] + sf [c2_r];
-
2936 df [c2_r] = sf [c1_r] - sf [c2_r];
-
2937 df [c1_i] = sf [c1_i];
-
2938 df [c2_i] = sf [c2_i];
-
2939
-
2940 FFTRealUseTrigo <TRIGO_DIRECT>::prepare (osc_list [TRIGO_OSC]);
-
2941
-
2942 // Others are conjugate complex numbers
-
2943 for (long i = 1; i < dist; ++ i)
-
2944 {
-
2945 DataType c;
-
2946 DataType s;
-
2947 FFTRealUseTrigo <TRIGO_DIRECT>::iterate (
-
2948 osc_list [TRIGO_OSC],
-
2949 c,
-
2950 s,
-
2951 cos_ptr,
-
2952 i * table_step,
-
2953 (dist - i) * table_step
-
2954 );
-
2955
-
2956 const DataType sf_r_i = sf [c1_r + i];
-
2957 const DataType sf_i_i = sf [c1_i + i];
-
2958
-
2959 const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s;
-
2960 df [c1_r + i] = sf_r_i + v1;
-
2961 df [c2_r - i] = sf_r_i - v1;
-
2962
-
2963 const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c;
-
2964 df [c2_r + i] = v2 + sf_i_i;
-
2965 df [cend - i] = v2 - sf_i_i;
-
2966 }
-
2967
-
2968 coef_index += cend;
-
2969 }
-
2970 while (coef_index < len);
-
2971}
-
2972
+
2934template <int PASS>
+
2935void FFTRealPassDirect <PASS>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
2936{
+
2937 // Executes "previous" passes first. Inverts source and destination buffers
+
2938 FFTRealPassDirect <PASS - 1>::process (
+
2939 len,
+
2940 src_ptr,
+
2941 dest_ptr,
+
2942 x_ptr,
+
2943 cos_ptr,
+
2944 cos_len,
+
2945 br_ptr,
+
2946 osc_list
+
2947 );
+
2948
+
2949 const long dist = 1L << (PASS - 1);
+
2950 const long c1_r = 0;
+
2951 const long c1_i = dist;
+
2952 const long c2_r = dist * 2;
+
2953 const long c2_i = dist * 3;
+
2954 const long cend = dist * 4;
+
2955 const long table_step = cos_len >> (PASS - 1);
+
2956
+
2957 enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT };
+
2958 enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 };
+
2959
+
2960 long coef_index = 0;
+
2961 do
+
2962 {
+
2963 const DataType * const sf = src_ptr + coef_index;
+
2964 DataType * const df = dest_ptr + coef_index;
+
2965
+
2966 // Extreme coefficients are always real
+
2967 df [c1_r] = sf [c1_r] + sf [c2_r];
+
2968 df [c2_r] = sf [c1_r] - sf [c2_r];
+
2969 df [c1_i] = sf [c1_i];
+
2970 df [c2_i] = sf [c2_i];
+
2971
+
2972 FFTRealUseTrigo <TRIGO_DIRECT>::prepare (osc_list [TRIGO_OSC]);
2973
-
2974
-
2975/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2976
-
2977
-
2978
-
2979/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
2980
-
2981
-
2982
-
2983} // namespace ffft
-
2984
-
2985
-
2986
-
2987#endif // ffft_FFTRealPassDirect_CODEHEADER_INCLUDED
-
2988
-
2989#undef ffft_FFTRealPassDirect_CURRENT_CODEHEADER
+
2974 // Others are conjugate complex numbers
+
2975 for (long i = 1; i < dist; ++ i)
+
2976 {
+
2977 DataType c;
+
2978 DataType s;
+
2979 FFTRealUseTrigo <TRIGO_DIRECT>::iterate (
+
2980 osc_list [TRIGO_OSC],
+
2981 c,
+
2982 s,
+
2983 cos_ptr,
+
2984 i * table_step,
+
2985 (dist - i) * table_step
+
2986 );
+
2987
+
2988 const DataType sf_r_i = sf [c1_r + i];
+
2989 const DataType sf_i_i = sf [c1_i + i];
2990
-
2991
-
2992
-
2993/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
2991 const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s;
+
2992 df [c1_r + i] = sf_r_i + v1;
+
2993 df [c2_r - i] = sf_r_i - v1;
2994
-
2995
-
2996
-
2997
-
2998#endif // ffft_FFTRealPassDirect_HEADER_INCLUDED
+
2995 const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c;
+
2996 df [c2_r + i] = v2 + sf_i_i;
+
2997 df [cend - i] = v2 - sf_i_i;
+
2998 }
2999
-
3000
-
3001
-
3002/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3003
-
3004/*****************************************************************************
-
3005
-
3006 FFTRealPassInverse.h
-
3007 By Laurent de Soras
-
3008
-
3009--- Legal stuff ---
-
3010
-
3011This program is free software. It comes without any warranty, to
-
3012the extent permitted by applicable law. You can redistribute it
-
3013and/or modify it under the terms of the Do What The Fuck You Want
-
3014To Public License, Version 2, as published by Sam Hocevar. See
-
3015http://sam.zoy.org/wtfpl/COPYING for more details.
-
3016
-
3017*Tab=3***********************************************************************/
+
3000 coef_index += cend;
+
3001 }
+
3002 while (coef_index < len);
+
3003}
+
3004
+
3005
+
3006
+
3007/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3008
+
3009
+
3010
+
3011/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3012
+
3013
+
3014
+
3015} // namespace ffft
+
3016
+
3017
3018
-
3019
+
3019#endif // ffft_FFTRealPassDirect_CODEHEADER_INCLUDED
3020
-
3021#if ! defined (ffft_FFTRealPassInverse_HEADER_INCLUDED)
-
3022#define ffft_FFTRealPassInverse_HEADER_INCLUDED
+
3021#undef ffft_FFTRealPassDirect_CURRENT_CODEHEADER
+
3022
3023
-
3024#if defined (_MSC_VER)
-
3025 #pragma once
-
3026 #pragma warning (4 : 4250) // "Inherits via dominance."
-
3027#endif
+
3024
+
3025/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3026
+
3027
3028
3029
-
3030
-
3031/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3030#endif // ffft_FFTRealPassDirect_HEADER_INCLUDED
+
3031
3032
3033
-
3034
+
3034/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
3035
-
3036
-
3037
-
3038
-
3039
-
3040namespace ffft
-
3041{
-
3042
-
3043
-
3044
-
3045template <int PASS>
-
- -
3047{
-
3048
-
3049/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3036/*****************************************************************************
+
3037
+
3038 FFTRealPassInverse.h
+
3039 By Laurent de Soras
+
3040
+
3041--- Legal stuff ---
+
3042
+
3043This program is free software. It comes without any warranty, to
+
3044the extent permitted by applicable law. You can redistribute it
+
3045and/or modify it under the terms of the Do What The Fuck You Want
+
3046To Public License, Version 2, as published by Sam Hocevar. See
+
3047http://sam.zoy.org/wtfpl/COPYING for more details.
+
3048
+
3049*Tab=3***********************************************************************/
3050
-
3051public:
+
3051
3052
-
3053 typedef FFTRealFixLenParam::DataType DataType;
-
3054 typedef OscSinCos <DataType> OscType;
+
3053#if ! defined (ffft_FFTRealPassInverse_HEADER_INCLUDED)
+
3054#define ffft_FFTRealPassInverse_HEADER_INCLUDED
3055
-
3056 ffft_FORCEINLINE static void
-
3057 process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
-
3058 ffft_FORCEINLINE static void
-
3059 process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
-
3060 ffft_FORCEINLINE static void
-
3061 process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
+
3056#if defined (_MSC_VER)
+
3057 #pragma once
+
3058 #pragma warning (4 : 4250) // "Inherits via dominance."
+
3059#endif
+
3060
+
3061
3062
-
3063
+
3063/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
3064
-
3065/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3065
3066
-
3067protected:
+
3067
3068
3069
3070
-
3071/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3072
-
3073private:
+
3071
+
3072namespace ffft
+
3073{
3074
3075
3076
-
3077/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
-
3078
-
3079private:
+
3077template <int PASS>
+
+ +
3079{
3080
- - - -
3084 operator = (const FFTRealPassInverse &other);
-
3085 bool operator == (const FFTRealPassInverse &other);
-
3086 bool operator != (const FFTRealPassInverse &other);
+
3081/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3082
+
3083public:
+
3084
+
3085 typedef FFTRealFixLenParam::DataType DataType;
+
3086 typedef OscSinCos <DataType> OscType;
3087
-
3088}; // class FFTRealPassInverse
-
-
3089
-
3090
-
3091
-
3092} // namespace ffft
-
3093
+
3088 ffft_FORCEINLINE static void
+
3089 process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
+
3090 ffft_FORCEINLINE static void
+
3091 process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
+
3092 ffft_FORCEINLINE static void
+
3093 process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []);
3094
3095
-
3096/*****************************************************************************
-
3097
-
3098 FFTRealPassInverse.hpp
-
3099 By Laurent de Soras
-
3100
-
3101--- Legal stuff ---
-
3102
-
3103This program is free software. It comes without any warranty, to
-
3104the extent permitted by applicable law. You can redistribute it
-
3105and/or modify it under the terms of the Do What The Fuck You Want
-
3106To Public License, Version 2, as published by Sam Hocevar. See
-
3107http://sam.zoy.org/wtfpl/COPYING for more details.
-
3108
-
3109*Tab=3***********************************************************************/
+
3096
+
3097/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3098
+
3099protected:
+
3100
+
3101
+
3102
+
3103/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3104
+
3105private:
+
3106
+
3107
+
3108
+
3109/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
3110
-
3111
+
3111private:
3112
-
3113#if defined (ffft_FFTRealPassInverse_CURRENT_CODEHEADER)
-
3114 #error Recursive inclusion of FFTRealPassInverse code header.
-
3115#endif
-
3116#define ffft_FFTRealPassInverse_CURRENT_CODEHEADER
-
3117
-
3118#if ! defined (ffft_FFTRealPassInverse_CODEHEADER_INCLUDED)
-
3119#define ffft_FFTRealPassInverse_CODEHEADER_INCLUDED
-
3120
+ + + +
3116 operator = (const FFTRealPassInverse &other);
+
3117 bool operator == (const FFTRealPassInverse &other);
+
3118 bool operator != (const FFTRealPassInverse &other);
+
3119
+
3120}; // class FFTRealPassInverse
+
3121
3122
-
3123/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3124
-
3125/*****************************************************************************
-
3126
-
3127 FFTRealUseTrigo.h
-
3128 By Laurent de Soras
+
3123
+
3124} // namespace ffft
+
3125
+
3126
+
3127
+
3128/*****************************************************************************
3129
-
3130--- Legal stuff ---
-
3131
-
3132This program is free software. It comes without any warranty, to
-
3133the extent permitted by applicable law. You can redistribute it
-
3134and/or modify it under the terms of the Do What The Fuck You Want
-
3135To Public License, Version 2, as published by Sam Hocevar. See
-
3136http://sam.zoy.org/wtfpl/COPYING for more details.
-
3137
-
3138*Tab=3***********************************************************************/
-
3139
-
3140
-
3141
-
3142#if ! defined (ffft_FFTRealUseTrigo_HEADER_INCLUDED)
-
3143#define ffft_FFTRealUseTrigo_HEADER_INCLUDED
+
3130 FFTRealPassInverse.hpp
+
3131 By Laurent de Soras
+
3132
+
3133--- Legal stuff ---
+
3134
+
3135This program is free software. It comes without any warranty, to
+
3136the extent permitted by applicable law. You can redistribute it
+
3137and/or modify it under the terms of the Do What The Fuck You Want
+
3138To Public License, Version 2, as published by Sam Hocevar. See
+
3139http://sam.zoy.org/wtfpl/COPYING for more details.
+
3140
+
3141*Tab=3***********************************************************************/
+
3142
+
3143
3144
-
3145#if defined (_MSC_VER)
-
3146 #pragma once
-
3147 #pragma warning (4 : 4250) // "Inherits via dominance."
-
3148#endif
+
3145#if defined (ffft_FFTRealPassInverse_CURRENT_CODEHEADER)
+
3146 #error Recursive inclusion of FFTRealPassInverse code header.
+
3147#endif
+
3148#define ffft_FFTRealPassInverse_CURRENT_CODEHEADER
3149
-
3150
-
3151
-
3152/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3150#if ! defined (ffft_FFTRealPassInverse_CODEHEADER_INCLUDED)
+
3151#define ffft_FFTRealPassInverse_CODEHEADER_INCLUDED
+
3152
3153
3154
-
3155
+
3155/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
3156
-
3157
-
3158
-
3159
-
3160namespace ffft
-
3161{
-
3162
-
3163
-
3164
-
3165template <int ALGO>
-
3166class FFTRealUseTrigo
-
3167{
-
3168
-
3169/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3170
-
3171public:
+
3157/*****************************************************************************
+
3158
+
3159 FFTRealUseTrigo.h
+
3160 By Laurent de Soras
+
3161
+
3162--- Legal stuff ---
+
3163
+
3164This program is free software. It comes without any warranty, to
+
3165the extent permitted by applicable law. You can redistribute it
+
3166and/or modify it under the terms of the Do What The Fuck You Want
+
3167To Public License, Version 2, as published by Sam Hocevar. See
+
3168http://sam.zoy.org/wtfpl/COPYING for more details.
+
3169
+
3170*Tab=3***********************************************************************/
+
3171
3172
-
3173 typedef FFTRealFixLenParam::DataType DataType;
-
3174 typedef OscSinCos <DataType> OscType;
-
3175
-
3176 ffft_FORCEINLINE static void
-
3177 prepare (OscType &osc);
-
3178 ffft_FORCEINLINE static void
-
3179 iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s);
-
3180
+
3173
+
3174#if ! defined (ffft_FFTRealUseTrigo_HEADER_INCLUDED)
+
3175#define ffft_FFTRealUseTrigo_HEADER_INCLUDED
+
3176
+
3177#if defined (_MSC_VER)
+
3178 #pragma once
+
3179 #pragma warning (4 : 4250) // "Inherits via dominance."
+
3180#endif
3181
3182
-
3183/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3184
-
3185protected:
+
3183
+
3184/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3185
3186
3187
3188
-
3189/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3189
3190
-
3191private:
-
3192
-
3193
+
3191
+
3192namespace ffft
+
3193{
3194
-
3195/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
3195
3196
-
3197private:
-
3198
-
3199 FFTRealUseTrigo ();
-
3200 ~FFTRealUseTrigo ();
-
3201 FFTRealUseTrigo (const FFTRealUseTrigo &other);
-
3202 FFTRealUseTrigo &
-
3203 operator = (const FFTRealUseTrigo &other);
-
3204 bool operator == (const FFTRealUseTrigo &other);
-
3205 bool operator != (const FFTRealUseTrigo &other);
-
3206
-
3207}; // class FFTRealUseTrigo
-
3208
-
3209
-
3210
-
3211} // namespace ffft
+
3197template <int ALGO>
+
3198class FFTRealUseTrigo
+
3199{
+
3200
+
3201/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3202
+
3203public:
+
3204
+
3205 typedef FFTRealFixLenParam::DataType DataType;
+
3206 typedef OscSinCos <DataType> OscType;
+
3207
+
3208 ffft_FORCEINLINE static void
+
3209 prepare (OscType &osc);
+
3210 ffft_FORCEINLINE static void
+
3211 iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s);
3212
3213
3214
-
3215/*****************************************************************************
-
3216
-
3217 FFTRealUseTrigo.hpp
-
3218 By Laurent de Soras
-
3219
-
3220--- Legal stuff ---
-
3221
-
3222This program is free software. It comes without any warranty, to
-
3223the extent permitted by applicable law. You can redistribute it
-
3224and/or modify it under the terms of the Do What The Fuck You Want
-
3225To Public License, Version 2, as published by Sam Hocevar. See
-
3226http://sam.zoy.org/wtfpl/COPYING for more details.
-
3227
-
3228*Tab=3***********************************************************************/
-
3229
+
3215/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3216
+
3217protected:
+
3218
+
3219
+
3220
+
3221/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3222
+
3223private:
+
3224
+
3225
+
3226
+
3227/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
3228
+
3229private:
3230
-
3231
-
3232#if defined (ffft_FFTRealUseTrigo_CURRENT_CODEHEADER)
-
3233 #error Recursive inclusion of FFTRealUseTrigo code header.
-
3234#endif
-
3235#define ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
-
3236
-
3237#if ! defined (ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED)
-
3238#define ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
-
3239
+
3231 FFTRealUseTrigo ();
+
3232 ~FFTRealUseTrigo ();
+
3233 FFTRealUseTrigo (const FFTRealUseTrigo &other);
+
3234 FFTRealUseTrigo &
+
3235 operator = (const FFTRealUseTrigo &other);
+
3236 bool operator == (const FFTRealUseTrigo &other);
+
3237 bool operator != (const FFTRealUseTrigo &other);
+
3238
+
3239}; // class FFTRealUseTrigo
3240
3241
-
3242/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3243
+
3242
+
3243} // namespace ffft
3244
3245
3246
-
3247
-
3248namespace ffft
-
3249{
-
3250
-
3251
-
3252
-
3253/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3254
-
3255
-
3256
-
3257template <int ALGO>
-
3258void FFTRealUseTrigo <ALGO>::prepare (OscType &osc)
-
3259{
-
3260 osc.clear_buffers ();
-
3261}
+
3247/*****************************************************************************
+
3248
+
3249 FFTRealUseTrigo.hpp
+
3250 By Laurent de Soras
+
3251
+
3252--- Legal stuff ---
+
3253
+
3254This program is free software. It comes without any warranty, to
+
3255the extent permitted by applicable law. You can redistribute it
+
3256and/or modify it under the terms of the Do What The Fuck You Want
+
3257To Public License, Version 2, as published by Sam Hocevar. See
+
3258http://sam.zoy.org/wtfpl/COPYING for more details.
+
3259
+
3260*Tab=3***********************************************************************/
+
3261
3262
-
3263template <>
-
3264inline void FFTRealUseTrigo <0>::prepare (OscType &osc)
-
3265{
-
3266 // Nothing
-
3267}
+
3263
+
3264#if defined (ffft_FFTRealUseTrigo_CURRENT_CODEHEADER)
+
3265 #error Recursive inclusion of FFTRealUseTrigo code header.
+
3266#endif
+
3267#define ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
3268
-
3269
-
3270
-
3271template <int ALGO>
-
3272void FFTRealUseTrigo <ALGO>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
-
3273{
-
3274 osc.step ();
-
3275 c = osc.get_cos ();
-
3276 s = osc.get_sin ();
-
3277}
+
3269#if ! defined (ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED)
+
3270#define ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
+
3271
+
3272
+
3273
+
3274/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3275
+
3276
+
3277
3278
-
3279template <>
-
3280inline void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
+
3279
+
3280namespace ffft
3281{
-
3282 c = cos_ptr [index_c];
-
3283 s = cos_ptr [index_s];
-
3284}
-
3285
+
3282
+
3283
+
3284
+
3285/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
3286
3287
-
3288/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3289
-
3290
-
3291
-
3292/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3293
+
3288
+
3289template <int ALGO>
+
3290void FFTRealUseTrigo <ALGO>::prepare (OscType &osc)
+
3291{
+
3292 osc.clear_buffers ();
+
3293}
3294
-
3295
-
3296} // namespace ffft
-
3297
-
3298
-
3299
-
3300#endif // ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
+
3295template <>
+
3296inline void FFTRealUseTrigo <0>::prepare (OscType &osc)
+
3297{
+
3298 // Nothing
+
3299}
+
3300
3301
-
3302#undef ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
-
3303
-
3304
-
3305
-
3306/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3307
-
3308
-
3309
+
3302
+
3303template <int ALGO>
+
3304void FFTRealUseTrigo <ALGO>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
+
3305{
+
3306 osc.step ();
+
3307 c = osc.get_cos ();
+
3308 s = osc.get_sin ();
+
3309}
3310
-
3311#endif // ffft_FFTRealUseTrigo_HEADER_INCLUDED
-
3312
-
3313
-
3314
-
3315/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3316
+
3311template <>
+
3312inline void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s)
+
3313{
+
3314 c = cos_ptr [index_c];
+
3315 s = cos_ptr [index_s];
+
3316}
3317
3318
3319
-
3320namespace ffft
-
3321{
+
3320/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3321
3322
3323
-
3324
-
3325/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3324/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3325
3326
3327
-
3328
-
3329template <int PASS>
-
3330void FFTRealPassInverse <PASS>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
3331{
-
3332 process_internal (
-
3333 len,
-
3334 dest_ptr,
-
3335 f_ptr,
-
3336 cos_ptr,
-
3337 cos_len,
-
3338 br_ptr,
-
3339 osc_list
-
3340 );
-
3341 FFTRealPassInverse <PASS - 1>::process_rec (
-
3342 len,
-
3343 src_ptr,
-
3344 dest_ptr,
-
3345 cos_ptr,
-
3346 cos_len,
-
3347 br_ptr,
-
3348 osc_list
-
3349 );
-
3350}
+
3328} // namespace ffft
+
3329
+
3330
+
3331
+
3332#endif // ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED
+
3333
+
3334#undef ffft_FFTRealUseTrigo_CURRENT_CODEHEADER
+
3335
+
3336
+
3337
+
3338/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3339
+
3340
+
3341
+
3342
+
3343#endif // ffft_FFTRealUseTrigo_HEADER_INCLUDED
+
3344
+
3345
+
3346
+
3347/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3348
+
3349
+
3350
3351
-
3352
-
3353
-
3354template <int PASS>
-
3355void FFTRealPassInverse <PASS>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
3356{
-
3357 process_internal (
-
3358 len,
-
3359 dest_ptr,
-
3360 src_ptr,
-
3361 cos_ptr,
-
3362 cos_len,
-
3363 br_ptr,
-
3364 osc_list
-
3365 );
-
3366 FFTRealPassInverse <PASS - 1>::process_rec (
-
3367 len,
-
3368 src_ptr,
-
3369 dest_ptr,
-
3370 cos_ptr,
-
3371 cos_len,
-
3372 br_ptr,
-
3373 osc_list
-
3374 );
-
3375}
-
3376
-
3377template <>
-
3378inline void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
3379{
-
3380 // Stops recursion
-
3381}
-
3382
+
3352namespace ffft
+
3353{
+
3354
+
3355
+
3356
+
3357/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3358
+
3359
+
3360
+
3361template <int PASS>
+
3362void FFTRealPassInverse <PASS>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
3363{
+
3364 process_internal (
+
3365 len,
+
3366 dest_ptr,
+
3367 f_ptr,
+
3368 cos_ptr,
+
3369 cos_len,
+
3370 br_ptr,
+
3371 osc_list
+
3372 );
+
3373 FFTRealPassInverse <PASS - 1>::process_rec (
+
3374 len,
+
3375 src_ptr,
+
3376 dest_ptr,
+
3377 cos_ptr,
+
3378 cos_len,
+
3379 br_ptr,
+
3380 osc_list
+
3381 );
+
3382}
3383
3384
-
3385template <int PASS>
-
3386void FFTRealPassInverse <PASS>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
3387{
-
3388 const long dist = 1L << (PASS - 1);
-
3389 const long c1_r = 0;
-
3390 const long c1_i = dist;
-
3391 const long c2_r = dist * 2;
-
3392 const long c2_i = dist * 3;
-
3393 const long cend = dist * 4;
-
3394 const long table_step = cos_len >> (PASS - 1);
-
3395
-
3396 enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT };
-
3397 enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 };
-
3398
-
3399 long coef_index = 0;
-
3400 do
-
3401 {
-
3402 const DataType * const sf = src_ptr + coef_index;
-
3403 DataType * const df = dest_ptr + coef_index;
-
3404
-
3405 // Extreme coefficients are always real
-
3406 df [c1_r] = sf [c1_r] + sf [c2_r];
-
3407 df [c2_r] = sf [c1_r] - sf [c2_r];
-
3408 df [c1_i] = sf [c1_i] * 2;
-
3409 df [c2_i] = sf [c2_i] * 2;
-
3410
-
3411 FFTRealUseTrigo <TRIGO_DIRECT>::prepare (osc_list [TRIGO_OSC]);
-
3412
-
3413 // Others are conjugate complex numbers
-
3414 for (long i = 1; i < dist; ++ i)
-
3415 {
-
3416 df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i];
-
3417 df [c1_i + i] = sf [c2_r + i] - sf [cend - i];
-
3418
-
3419 DataType c;
-
3420 DataType s;
-
3421 FFTRealUseTrigo <TRIGO_DIRECT>::iterate (
-
3422 osc_list [TRIGO_OSC],
-
3423 c,
-
3424 s,
-
3425 cos_ptr,
-
3426 i * table_step,
-
3427 (dist - i) * table_step
-
3428 );
-
3429
-
3430 const DataType vr = sf [c1_r + i] - sf [c2_r - i];
-
3431 const DataType vi = sf [c2_r + i] + sf [cend - i];
-
3432
-
3433 df [c2_r + i] = vr * c + vi * s;
-
3434 df [c2_i + i] = vi * c - vr * s;
-
3435 }
+
3385
+
3386template <int PASS>
+
3387void FFTRealPassInverse <PASS>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
3388{
+
3389 process_internal (
+
3390 len,
+
3391 dest_ptr,
+
3392 src_ptr,
+
3393 cos_ptr,
+
3394 cos_len,
+
3395 br_ptr,
+
3396 osc_list
+
3397 );
+
3398 FFTRealPassInverse <PASS - 1>::process_rec (
+
3399 len,
+
3400 src_ptr,
+
3401 dest_ptr,
+
3402 cos_ptr,
+
3403 cos_len,
+
3404 br_ptr,
+
3405 osc_list
+
3406 );
+
3407}
+
3408
+
3409template <>
+
3410inline void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
3411{
+
3412 // Stops recursion
+
3413}
+
3414
+
3415
+
3416
+
3417template <int PASS>
+
3418void FFTRealPassInverse <PASS>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
3419{
+
3420 const long dist = 1L << (PASS - 1);
+
3421 const long c1_r = 0;
+
3422 const long c1_i = dist;
+
3423 const long c2_r = dist * 2;
+
3424 const long c2_i = dist * 3;
+
3425 const long cend = dist * 4;
+
3426 const long table_step = cos_len >> (PASS - 1);
+
3427
+
3428 enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT };
+
3429 enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 };
+
3430
+
3431 long coef_index = 0;
+
3432 do
+
3433 {
+
3434 const DataType * const sf = src_ptr + coef_index;
+
3435 DataType * const df = dest_ptr + coef_index;
3436
-
3437 coef_index += cend;
-
3438 }
-
3439 while (coef_index < len);
-
3440}
-
3441
-
3442template <>
-
3443inline void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
3444{
-
3445 // Antepenultimate pass
-
3446 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
-
3447
-
3448 long coef_index = 0;
-
3449 do
-
3450 {
-
3451 dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4];
-
3452 dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4];
-
3453 dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2;
-
3454 dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2;
-
3455
-
3456 dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3];
-
3457 dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7];
-
3458
-
3459 const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3];
-
3460 const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7];
+
3437 // Extreme coefficients are always real
+
3438 df [c1_r] = sf [c1_r] + sf [c2_r];
+
3439 df [c2_r] = sf [c1_r] - sf [c2_r];
+
3440 df [c1_i] = sf [c1_i] * 2;
+
3441 df [c2_i] = sf [c2_i] * 2;
+
3442
+
3443 FFTRealUseTrigo <TRIGO_DIRECT>::prepare (osc_list [TRIGO_OSC]);
+
3444
+
3445 // Others are conjugate complex numbers
+
3446 for (long i = 1; i < dist; ++ i)
+
3447 {
+
3448 df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i];
+
3449 df [c1_i + i] = sf [c2_r + i] - sf [cend - i];
+
3450
+
3451 DataType c;
+
3452 DataType s;
+
3453 FFTRealUseTrigo <TRIGO_DIRECT>::iterate (
+
3454 osc_list [TRIGO_OSC],
+
3455 c,
+
3456 s,
+
3457 cos_ptr,
+
3458 i * table_step,
+
3459 (dist - i) * table_step
+
3460 );
3461
-
3462 dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2;
-
3463 dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2;
+
3462 const DataType vr = sf [c1_r + i] - sf [c2_r - i];
+
3463 const DataType vi = sf [c2_r + i] + sf [cend - i];
3464
-
3465 coef_index += 8;
-
3466 }
-
3467 while (coef_index < len);
-
3468}
-
3469
-
3470template <>
-
3471inline void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
-
3472{
-
3473 // Penultimate and last pass at once
-
3474 const long qlen = len >> 2;
-
3475
-
3476 long coef_index = 0;
-
3477 do
-
3478 {
-
3479 const long ri_0 = br_ptr [coef_index >> 2];
-
3480
-
3481 const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2];
-
3482 const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2];
-
3483 const DataType b_1 = src_ptr [coef_index + 1] * 2;
-
3484 const DataType b_3 = src_ptr [coef_index + 3] * 2;
-
3485
-
3486 dest_ptr [ri_0 ] = b_0 + b_1;
-
3487 dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1;
-
3488 dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3;
-
3489 dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3;
+
3465 df [c2_r + i] = vr * c + vi * s;
+
3466 df [c2_i + i] = vi * c - vr * s;
+
3467 }
+
3468
+
3469 coef_index += cend;
+
3470 }
+
3471 while (coef_index < len);
+
3472}
+
3473
+
3474template <>
+
3475inline void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
3476{
+
3477 // Antepenultimate pass
+
3478 const DataType sqrt2_2 = DataType (SQRT2 * 0.5);
+
3479
+
3480 long coef_index = 0;
+
3481 do
+
3482 {
+
3483 dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4];
+
3484 dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4];
+
3485 dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2;
+
3486 dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2;
+
3487
+
3488 dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3];
+
3489 dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7];
3490
-
3491 coef_index += 4;
-
3492 }
-
3493 while (coef_index < len);
-
3494}
-
3495
+
3491 const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3];
+
3492 const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7];
+
3493
+
3494 dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2;
+
3495 dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2;
3496
-
3497
-
3498/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3499
-
3500
+
3497 coef_index += 8;
+
3498 }
+
3499 while (coef_index < len);
+
3500}
3501
-
3502/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3503
-
3504
-
3505
-
3506} // namespace ffft
+
3502template <>
+
3503inline void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list [])
+
3504{
+
3505 // Penultimate and last pass at once
+
3506 const long qlen = len >> 2;
3507
-
3508
-
3509
-
3510#endif // ffft_FFTRealPassInverse_CODEHEADER_INCLUDED
-
3511
-
3512#undef ffft_FFTRealPassInverse_CURRENT_CODEHEADER
-
3513
-
3514
-
3515
-
3516/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3508 long coef_index = 0;
+
3509 do
+
3510 {
+
3511 const long ri_0 = br_ptr [coef_index >> 2];
+
3512
+
3513 const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2];
+
3514 const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2];
+
3515 const DataType b_1 = src_ptr [coef_index + 1] * 2;
+
3516 const DataType b_3 = src_ptr [coef_index + 3] * 2;
3517
-
3518
-
3519
-
3520
-
3521#endif // ffft_FFTRealPassInverse_HEADER_INCLUDED
+
3518 dest_ptr [ri_0 ] = b_0 + b_1;
+
3519 dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1;
+
3520 dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3;
+
3521 dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3;
3522
-
3523
-
3524
-
3525/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3526
-
3527/*****************************************************************************
-
3528
-
3529 FFTRealSelect.h
-
3530 By Laurent de Soras
-
3531
-
3532--- Legal stuff ---
-
3533
-
3534This program is free software. It comes without any warranty, to
-
3535the extent permitted by applicable law. You can redistribute it
-
3536and/or modify it under the terms of the Do What The Fuck You Want
-
3537To Public License, Version 2, as published by Sam Hocevar. See
-
3538http://sam.zoy.org/wtfpl/COPYING for more details.
-
3539
-
3540*Tab=3***********************************************************************/
+
3523 coef_index += 4;
+
3524 }
+
3525 while (coef_index < len);
+
3526}
+
3527
+
3528
+
3529
+
3530/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3531
+
3532
+
3533
+
3534/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3535
+
3536
+
3537
+
3538} // namespace ffft
+
3539
+
3540
3541
-
3542
+
3542#endif // ffft_FFTRealPassInverse_CODEHEADER_INCLUDED
3543
-
3544#if ! defined (ffft_FFTRealSelect_HEADER_INCLUDED)
-
3545#define ffft_FFTRealSelect_HEADER_INCLUDED
+
3544#undef ffft_FFTRealPassInverse_CURRENT_CODEHEADER
+
3545
3546
-
3547#if defined (_MSC_VER)
-
3548 #pragma once
-
3549#endif
+
3547
+
3548/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3549
3550
3551
3552
-
3553/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3553#endif // ffft_FFTRealPassInverse_HEADER_INCLUDED
3554
3555
3556
-
3557
+
3557/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
3558
-
3559namespace ffft
-
3560{
-
3561
-
3562
-
3563
-
3564template <int P>
-
- -
3566{
-
3567
-
3568/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3569
-
3570public:
-
3571
-
3572 ffft_FORCEINLINE static float *
-
3573 sel_bin (float *e_ptr, float *o_ptr);
+
3559/*****************************************************************************
+
3560
+
3561 FFTRealSelect.h
+
3562 By Laurent de Soras
+
3563
+
3564--- Legal stuff ---
+
3565
+
3566This program is free software. It comes without any warranty, to
+
3567the extent permitted by applicable law. You can redistribute it
+
3568and/or modify it under the terms of the Do What The Fuck You Want
+
3569To Public License, Version 2, as published by Sam Hocevar. See
+
3570http://sam.zoy.org/wtfpl/COPYING for more details.
+
3571
+
3572*Tab=3***********************************************************************/
+
3573
3574
3575
-
3576
-
3577/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
+
3576#if ! defined (ffft_FFTRealSelect_HEADER_INCLUDED)
+
3577#define ffft_FFTRealSelect_HEADER_INCLUDED
3578
-
3579private:
-
3580
-
3581 FFTRealSelect ();
-
3582 ~FFTRealSelect ();
-
3583 FFTRealSelect (const FFTRealSelect &other);
-
3584 FFTRealSelect& operator = (const FFTRealSelect &other);
-
3585 bool operator == (const FFTRealSelect &other);
-
3586 bool operator != (const FFTRealSelect &other);
+
3579#if defined (_MSC_VER)
+
3580 #pragma once
+
3581#endif
+
3582
+
3583
+
3584
+
3585/*\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3586
3587
-
3588}; // class FFTRealSelect
-
+
3588
3589
3590
-
3591
-
3592} // namespace ffft
+
3591namespace ffft
+
3592{
3593
3594
3595
-
3596/*****************************************************************************
-
3597
-
3598 FFTRealSelect.hpp
-
3599 By Laurent de Soras
-
3600
-
3601--- Legal stuff ---
-
3602
-
3603This program is free software. It comes without any warranty, to
-
3604the extent permitted by applicable law. You can redistribute it
-
3605and/or modify it under the terms of the Do What The Fuck You Want
-
3606To Public License, Version 2, as published by Sam Hocevar. See
-
3607http://sam.zoy.org/wtfpl/COPYING for more details.
-
3608
-
3609*Tab=3***********************************************************************/
+
3596template <int P>
+
+ +
3598{
+
3599
+
3600/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3601
+
3602public:
+
3603
+
3604 ffft_FORCEINLINE static float *
+
3605 sel_bin (float *e_ptr, float *o_ptr);
+
3606
+
3607
+
3608
+
3609/*\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\*/
3610
-
3611
+
3611private:
3612
-
3613#if defined (ffft_FFTRealSelect_CURRENT_CODEHEADER)
-
3614 #error Recursive inclusion of FFTRealSelect code header.
-
3615#endif
-
3616#define ffft_FFTRealSelect_CURRENT_CODEHEADER
-
3617
-
3618#if ! defined (ffft_FFTRealSelect_CODEHEADER_INCLUDED)
-
3619#define ffft_FFTRealSelect_CODEHEADER_INCLUDED
-
3620
+
3613 FFTRealSelect ();
+
3614 ~FFTRealSelect ();
+
3615 FFTRealSelect (const FFTRealSelect &other);
+
3616 FFTRealSelect& operator = (const FFTRealSelect &other);
+
3617 bool operator == (const FFTRealSelect &other);
+
3618 bool operator != (const FFTRealSelect &other);
+
3619
+
3620}; // class FFTRealSelect
+
3621
3622
-
3623namespace ffft
-
3624{
+
3623
+
3624} // namespace ffft
3625
3626
3627
-
3628/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3629
-
3630
-
3631
-
3632template <int P>
-
3633float * FFTRealSelect <P>::sel_bin (float *e_ptr, float *o_ptr)
-
3634{
-
3635 return (o_ptr);
-
3636}
-
3637
-
3638
-
3639
-
3640template <>
-
3641inline float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr)
-
3642{
-
3643 return (e_ptr);
-
3644}
-
3645
-
3646
-
3647
-
3648} // namespace ffft
+
3628/*****************************************************************************
+
3629
+
3630 FFTRealSelect.hpp
+
3631 By Laurent de Soras
+
3632
+
3633--- Legal stuff ---
+
3634
+
3635This program is free software. It comes without any warranty, to
+
3636the extent permitted by applicable law. You can redistribute it
+
3637and/or modify it under the terms of the Do What The Fuck You Want
+
3638To Public License, Version 2, as published by Sam Hocevar. See
+
3639http://sam.zoy.org/wtfpl/COPYING for more details.
+
3640
+
3641*Tab=3***********************************************************************/
+
3642
+
3643
+
3644
+
3645#if defined (ffft_FFTRealSelect_CURRENT_CODEHEADER)
+
3646 #error Recursive inclusion of FFTRealSelect code header.
+
3647#endif
+
3648#define ffft_FFTRealSelect_CURRENT_CODEHEADER
3649
-
3650
-
3651
-
3652#endif // ffft_FFTRealSelect_CODEHEADER_INCLUDED
+
3650#if ! defined (ffft_FFTRealSelect_CODEHEADER_INCLUDED)
+
3651#define ffft_FFTRealSelect_CODEHEADER_INCLUDED
+
3652
3653
-
3654#undef ffft_FFTRealSelect_CURRENT_CODEHEADER
-
3655
-
3656
+
3654
+
3655namespace ffft
+
3656{
3657
-
3658/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3658
3659
-
3660
+
3660/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
3661
3662
-
3663#endif // ffft_FFTRealSelect_HEADER_INCLUDED
-
3664
-
3665
-
3666
-
3667/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3668
+
3663
+
3664template <int P>
+
3665float * FFTRealSelect <P>::sel_bin (float *e_ptr, float *o_ptr)
+
3666{
+
3667 return (o_ptr);
+
3668}
3669
-
3670#include <cassert>
-
3671#include <cmath>
-
3672
-
3673namespace std { }
-
3674
-
3675
-
3676
-
3677namespace ffft
-
3678{
+
3670
+
3671
+
3672template <>
+
3673inline float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr)
+
3674{
+
3675 return (e_ptr);
+
3676}
+
3677
+
3678
3679
-
3680
+
3680} // namespace ffft
3681
-
3682/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3682
3683
-
3684
+
3684#endif // ffft_FFTRealSelect_CODEHEADER_INCLUDED
3685
-
3686template <int LL2>
-
3687FFTRealFixLen <LL2>::FFTRealFixLen ()
-
3688: _buffer (FFT_LEN)
-
3689, _br_data (BR_ARR_SIZE)
-
3690, _trigo_data (TRIGO_TABLE_ARR_SIZE)
-
3691, _trigo_osc ()
-
3692{
-
3693 build_br_lut ();
-
3694 build_trigo_lut ();
-
3695 build_trigo_osc ();
-
3696}
+
3686#undef ffft_FFTRealSelect_CURRENT_CODEHEADER
+
3687
+
3688
+
3689
+
3690/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3691
+
3692
+
3693
+
3694
+
3695#endif // ffft_FFTRealSelect_HEADER_INCLUDED
+
3696
3697
3698
-
3699
-
3700template <int LL2>
-
3701long FFTRealFixLen <LL2>::get_length () const
-
3702{
-
3703 return (FFT_LEN);
-
3704}
-
3705
+
3699/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3700
+
3701
+
3702#include <cassert>
+
3703#include <cmath>
+
3704
+
3705namespace std { }
3706
3707
-
3708// General case
-
3709template <int LL2>
-
3710void FFTRealFixLen <LL2>::do_fft (DataType f [], const DataType x [])
-
3711{
-
3712 assert (f != 0);
-
3713 assert (x != 0);
-
3714 assert (x != f);
-
3715 assert (FFT_LEN_L2 >= 3);
+
3708
+
3709namespace ffft
+
3710{
+
3711
+
3712
+
3713
+
3714/*\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3715
3716
-
3717 // Do the transform in several passes
-
3718 const DataType * cos_ptr = &_trigo_data [0];
-
3719 const long * br_ptr = &_br_data [0];
-
3720
-
3721 FFTRealPassDirect <FFT_LEN_L2 - 1>::process (
-
3722 FFT_LEN,
-
3723 f,
-
3724 &_buffer [0],
-
3725 x,
-
3726 cos_ptr,
-
3727 TRIGO_TABLE_ARR_SIZE,
-
3728 br_ptr,
-
3729 &_trigo_osc [0]
-
3730 );
-
3731}
-
3732
-
3733// 4-point FFT
-
3734template <>
-
3735inline void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x [])
-
3736{
-
3737 assert (f != 0);
-
3738 assert (x != 0);
-
3739 assert (x != f);
-
3740
-
3741 f [1] = x [0] - x [2];
-
3742 f [3] = x [1] - x [3];
-
3743
-
3744 const DataType b_0 = x [0] + x [2];
-
3745 const DataType b_2 = x [1] + x [3];
-
3746
-
3747 f [0] = b_0 + b_2;
-
3748 f [2] = b_0 - b_2;
-
3749}
-
3750
-
3751// 2-point FFT
-
3752template <>
-
3753inline void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x [])
-
3754{
-
3755 assert (f != 0);
-
3756 assert (x != 0);
-
3757 assert (x != f);
-
3758
-
3759 f [0] = x [0] + x [1];
-
3760 f [1] = x [0] - x [1];
-
3761}
-
3762
-
3763// 1-point FFT
-
3764template <>
-
3765inline void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x [])
-
3766{
-
3767 assert (f != 0);
-
3768 assert (x != 0);
-
3769
-
3770 f [0] = x [0];
-
3771}
+
3717
+
3718template <int LL2>
+
3719FFTRealFixLen <LL2>::FFTRealFixLen ()
+
3720: _buffer (FFT_LEN)
+
3721, _br_data (BR_ARR_SIZE)
+
3722, _trigo_data (TRIGO_TABLE_ARR_SIZE)
+
3723, _trigo_osc ()
+
3724{
+
3725 build_br_lut ();
+
3726 build_trigo_lut ();
+
3727 build_trigo_osc ();
+
3728}
+
3729
+
3730
+
3731
+
3732template <int LL2>
+
3733long FFTRealFixLen <LL2>::get_length () const
+
3734{
+
3735 return (FFT_LEN);
+
3736}
+
3737
+
3738
+
3739
+
3740// General case
+
3741template <int LL2>
+
3742void FFTRealFixLen <LL2>::do_fft (DataType f [], const DataType x [])
+
3743{
+
3744 assert (f != 0);
+
3745 assert (x != 0);
+
3746 assert (x != f);
+
3747 assert (FFT_LEN_L2 >= 3);
+
3748
+
3749 // Do the transform in several passes
+
3750 const DataType * cos_ptr = &_trigo_data [0];
+
3751 const long * br_ptr = &_br_data [0];
+
3752
+
3753 FFTRealPassDirect <FFT_LEN_L2 - 1>::process (
+
3754 FFT_LEN,
+
3755 f,
+
3756 &_buffer [0],
+
3757 x,
+
3758 cos_ptr,
+
3759 TRIGO_TABLE_ARR_SIZE,
+
3760 br_ptr,
+
3761 &_trigo_osc [0]
+
3762 );
+
3763}
+
3764
+
3765// 4-point FFT
+
3766template <>
+
3767inline void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x [])
+
3768{
+
3769 assert (f != 0);
+
3770 assert (x != 0);
+
3771 assert (x != f);
3772
-
3773
-
3774
-
3775// General case
-
3776template <int LL2>
-
3777void FFTRealFixLen <LL2>::do_ifft (const DataType f [], DataType x [])
-
3778{
-
3779 assert (f != 0);
-
3780 assert (x != 0);
-
3781 assert (x != f);
-
3782 assert (FFT_LEN_L2 >= 3);
-
3783
-
3784 // Do the transform in several passes
-
3785 DataType * s_ptr =
-
3786 FFTRealSelect <FFT_LEN_L2 & 1>::sel_bin (&_buffer [0], x);
-
3787 DataType * d_ptr =
-
3788 FFTRealSelect <FFT_LEN_L2 & 1>::sel_bin (x, &_buffer [0]);
-
3789 const DataType * cos_ptr = &_trigo_data [0];
-
3790 const long * br_ptr = &_br_data [0];
-
3791
-
3792 FFTRealPassInverse <FFT_LEN_L2 - 1>::process (
-
3793 FFT_LEN,
-
3794 d_ptr,
-
3795 s_ptr,
-
3796 f,
-
3797 cos_ptr,
-
3798 TRIGO_TABLE_ARR_SIZE,
-
3799 br_ptr,
-
3800 &_trigo_osc [0]
-
3801 );
-
3802}
-
3803
-
3804// 4-point IFFT
-
3805template <>
-
3806inline void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x [])
-
3807{
-
3808 assert (f != 0);
-
3809 assert (x != 0);
-
3810 assert (x != f);
-
3811
-
3812 const DataType b_0 = f [0] + f [2];
-
3813 const DataType b_2 = f [0] - f [2];
-
3814
-
3815 x [0] = b_0 + f [1] * 2;
-
3816 x [2] = b_0 - f [1] * 2;
-
3817 x [1] = b_2 + f [3] * 2;
-
3818 x [3] = b_2 - f [3] * 2;
-
3819}
-
3820
-
3821// 2-point IFFT
-
3822template <>
-
3823inline void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x [])
-
3824{
-
3825 assert (f != 0);
-
3826 assert (x != 0);
-
3827 assert (x != f);
-
3828
-
3829 x [0] = f [0] + f [1];
-
3830 x [1] = f [0] - f [1];
-
3831}
-
3832
-
3833// 1-point IFFT
-
3834template <>
-
3835inline void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x [])
-
3836{
-
3837 assert (f != 0);
-
3838 assert (x != 0);
-
3839 assert (x != f);
-
3840
-
3841 x [0] = f [0];
-
3842}
+
3773 f [1] = x [0] - x [2];
+
3774 f [3] = x [1] - x [3];
+
3775
+
3776 const DataType b_0 = x [0] + x [2];
+
3777 const DataType b_2 = x [1] + x [3];
+
3778
+
3779 f [0] = b_0 + b_2;
+
3780 f [2] = b_0 - b_2;
+
3781}
+
3782
+
3783// 2-point FFT
+
3784template <>
+
3785inline void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x [])
+
3786{
+
3787 assert (f != 0);
+
3788 assert (x != 0);
+
3789 assert (x != f);
+
3790
+
3791 f [0] = x [0] + x [1];
+
3792 f [1] = x [0] - x [1];
+
3793}
+
3794
+
3795// 1-point FFT
+
3796template <>
+
3797inline void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x [])
+
3798{
+
3799 assert (f != 0);
+
3800 assert (x != 0);
+
3801
+
3802 f [0] = x [0];
+
3803}
+
3804
+
3805
+
3806
+
3807// General case
+
3808template <int LL2>
+
3809void FFTRealFixLen <LL2>::do_ifft (const DataType f [], DataType x [])
+
3810{
+
3811 assert (f != 0);
+
3812 assert (x != 0);
+
3813 assert (x != f);
+
3814 assert (FFT_LEN_L2 >= 3);
+
3815
+
3816 // Do the transform in several passes
+
3817 DataType * s_ptr =
+
3818 FFTRealSelect <FFT_LEN_L2 & 1>::sel_bin (&_buffer [0], x);
+
3819 DataType * d_ptr =
+
3820 FFTRealSelect <FFT_LEN_L2 & 1>::sel_bin (x, &_buffer [0]);
+
3821 const DataType * cos_ptr = &_trigo_data [0];
+
3822 const long * br_ptr = &_br_data [0];
+
3823
+
3824 FFTRealPassInverse <FFT_LEN_L2 - 1>::process (
+
3825 FFT_LEN,
+
3826 d_ptr,
+
3827 s_ptr,
+
3828 f,
+
3829 cos_ptr,
+
3830 TRIGO_TABLE_ARR_SIZE,
+
3831 br_ptr,
+
3832 &_trigo_osc [0]
+
3833 );
+
3834}
+
3835
+
3836// 4-point IFFT
+
3837template <>
+
3838inline void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x [])
+
3839{
+
3840 assert (f != 0);
+
3841 assert (x != 0);
+
3842 assert (x != f);
3843
-
3844
-
3845
+
3844 const DataType b_0 = f [0] + f [2];
+
3845 const DataType b_2 = f [0] - f [2];
3846
-
3847template <int LL2>
-
3848void FFTRealFixLen <LL2>::rescale (DataType x []) const
-
3849{
-
3850 assert (x != 0);
-
3851
-
3852 const DataType mul = DataType (1.0 / FFT_LEN);
-
3853
-
3854 if (FFT_LEN < 4)
-
3855 {
-
3856 long i = FFT_LEN - 1;
-
3857 do
-
3858 {
-
3859 x [i] *= mul;
-
3860 --i;
-
3861 }
-
3862 while (i >= 0);
-
3863 }
+
3847 x [0] = b_0 + f [1] * 2;
+
3848 x [2] = b_0 - f [1] * 2;
+
3849 x [1] = b_2 + f [3] * 2;
+
3850 x [3] = b_2 - f [3] * 2;
+
3851}
+
3852
+
3853// 2-point IFFT
+
3854template <>
+
3855inline void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x [])
+
3856{
+
3857 assert (f != 0);
+
3858 assert (x != 0);
+
3859 assert (x != f);
+
3860
+
3861 x [0] = f [0] + f [1];
+
3862 x [1] = f [0] - f [1];
+
3863}
3864
-
3865 else
-
3866 {
-
3867 assert ((FFT_LEN & 3) == 0);
-
3868
-
3869 // Could be optimized with SIMD instruction sets (needs alignment check)
-
3870 long i = FFT_LEN - 4;
-
3871 do
-
3872 {
-
3873 x [i + 0] *= mul;
-
3874 x [i + 1] *= mul;
-
3875 x [i + 2] *= mul;
-
3876 x [i + 3] *= mul;
-
3877 i -= 4;
-
3878 }
-
3879 while (i >= 0);
-
3880 }
-
3881}
-
3882
+
3865// 1-point IFFT
+
3866template <>
+
3867inline void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x [])
+
3868{
+
3869 assert (f != 0);
+
3870 assert (x != 0);
+
3871 assert (x != f);
+
3872
+
3873 x [0] = f [0];
+
3874}
+
3875
+
3876
+
3877
+
3878
+
3879template <int LL2>
+
3880void FFTRealFixLen <LL2>::rescale (DataType x []) const
+
3881{
+
3882 assert (x != 0);
3883
-
3884
-
3885/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3886
-
3887
-
3888
-
3889/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3890
-
3891
-
3892
-
3893template <int LL2>
-
3894void FFTRealFixLen <LL2>::build_br_lut ()
-
3895{
-
3896 _br_data [0] = 0;
-
3897 for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt)
+
3884 const DataType mul = DataType (1.0 / FFT_LEN);
+
3885
+
3886 if (FFT_LEN < 4)
+
3887 {
+
3888 long i = FFT_LEN - 1;
+
3889 do
+
3890 {
+
3891 x [i] *= mul;
+
3892 --i;
+
3893 }
+
3894 while (i >= 0);
+
3895 }
+
3896
+
3897 else
3898 {
-
3899 long index = cnt << 2;
-
3900 long br_index = 0;
-
3901
-
3902 int bit_cnt = FFT_LEN_L2;
+
3899 assert ((FFT_LEN & 3) == 0);
+
3900
+
3901 // Could be optimized with SIMD instruction sets (needs alignment check)
+
3902 long i = FFT_LEN - 4;
3903 do
3904 {
-
3905 br_index <<= 1;
-
3906 br_index += (index & 1);
-
3907 index >>= 1;
-
3908
-
3909 -- bit_cnt;
+
3905 x [i + 0] *= mul;
+
3906 x [i + 1] *= mul;
+
3907 x [i + 2] *= mul;
+
3908 x [i + 3] *= mul;
+
3909 i -= 4;
3910 }
-
3911 while (bit_cnt > 0);
-
3912
-
3913 _br_data [cnt] = br_index;
-
3914 }
-
3915}
+
3911 while (i >= 0);
+
3912 }
+
3913}
+
3914
+
3915
3916
-
3917
+
3917/*\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
3918
-
3919template <int LL2>
-
3920void FFTRealFixLen <LL2>::build_trigo_lut ()
-
3921{
-
3922 const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE;
-
3923 for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i)
-
3924 {
-
3925 using namespace std;
-
3926
-
3927 _trigo_data [i] = DataType (cos (i * mul));
-
3928 }
-
3929}
-
3930
-
3931
-
3932
-
3933template <int LL2>
-
3934void FFTRealFixLen <LL2>::build_trigo_osc ()
-
3935{
-
3936 for (int i = 0; i < NBR_TRIGO_OSC; ++i)
-
3937 {
-
3938 OscType & osc = _trigo_osc [i];
-
3939
-
3940 const long len = static_cast <long> (TRIGO_TABLE_ARR_SIZE) << (i + 1);
-
3941 const double mul = (0.5 * PI) / len;
-
3942 osc.set_step (mul);
-
3943 }
-
3944}
-
3945
-
3946
-
3947
-
3948} // namespace ffft
+
3919
+
3920
+
3921/*\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3922
+
3923
+
3924
+
3925template <int LL2>
+
3926void FFTRealFixLen <LL2>::build_br_lut ()
+
3927{
+
3928 _br_data [0] = 0;
+
3929 for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt)
+
3930 {
+
3931 long index = cnt << 2;
+
3932 long br_index = 0;
+
3933
+
3934 int bit_cnt = FFT_LEN_L2;
+
3935 do
+
3936 {
+
3937 br_index <<= 1;
+
3938 br_index += (index & 1);
+
3939 index >>= 1;
+
3940
+
3941 -- bit_cnt;
+
3942 }
+
3943 while (bit_cnt > 0);
+
3944
+
3945 _br_data [cnt] = br_index;
+
3946 }
+
3947}
+
3948
3949
3950
-
3951
-
3952#endif // ffft_FFTRealFixLen_CODEHEADER_INCLUDED
-
3953
-
3954#undef ffft_FFTRealFixLen_CURRENT_CODEHEADER
-
3955
-
3956
-
3957
-
3958/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
3959
-
3960
-
3961
+
3951template <int LL2>
+
3952void FFTRealFixLen <LL2>::build_trigo_lut ()
+
3953{
+
3954 const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE;
+
3955 for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i)
+
3956 {
+
3957 using namespace std;
+
3958
+
3959 _trigo_data [i] = DataType (cos (i * mul));
+
3960 }
+
3961}
3962
-
3963#endif // ffft_FFTRealFixLen_HEADER_INCLUDED
+
3963
3964
-
3965
-
3966
-
3967/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
-
Definition FFTReal.h:1664
-
Definition FFTReal.h:129
-
Definition FFTReal.h:2402
-
Definition FFTReal.h:2107
-
Definition FFTReal.h:578
-
Definition FFTReal.h:2553
-
Definition FFTReal.h:3047
-
Definition FFTReal.h:3566
-
Definition FFTReal.h:2669
-
Definition FFTReal.h:377
-
AudioTools internal: FFT.
Definition FFTReal.h:61
+
3965template <int LL2>
+
3966void FFTRealFixLen <LL2>::build_trigo_osc ()
+
3967{
+
3968 for (int i = 0; i < NBR_TRIGO_OSC; ++i)
+
3969 {
+
3970 OscType & osc = _trigo_osc [i];
+
3971
+
3972 const long len = static_cast <long> (TRIGO_TABLE_ARR_SIZE) << (i + 1);
+
3973 const double mul = (0.5 * PI) / len;
+
3974 osc.set_step (mul);
+
3975 }
+
3976}
+
3977
+
3978
+
3979
+
3980} // namespace ffft
+
3981
+
3982
+
3983
+
3984#endif // ffft_FFTRealFixLen_CODEHEADER_INCLUDED
+
3985
+
3986#undef ffft_FFTRealFixLen_CURRENT_CODEHEADER
+
3987
+
3988
+
3989
+
3990/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
3991
+
3992
+
3993
+
3994
+
3995#endif // ffft_FFTRealFixLen_HEADER_INCLUDED
+
3996
+
3997
+
3998
+
3999/*\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
+
Definition FFTReal.h:1682
+
Definition FFTReal.h:132
+
Definition FFTReal.h:2434
+
Definition FFTReal.h:2139
+
Definition FFTReal.h:596
+
Definition FFTReal.h:2585
+
Definition FFTReal.h:3079
+
Definition FFTReal.h:3598
+
Definition FFTReal.h:2701
+
Definition FFTReal.h:395
+
AudioTools internal: FFT.
Definition FFTReal.h:64