diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/d_fftroutine.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/d_fftroutine.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/apps/plugins/pdbox/PDa/src/d_fftroutine.c b/apps/plugins/pdbox/PDa/src/d_fftroutine.c index 41948132d7..08888333fc 100644 --- a/apps/plugins/pdbox/PDa/src/d_fftroutine.c +++ b/apps/plugins/pdbox/PDa/src/d_fftroutine.c | |||
@@ -84,9 +84,14 @@ | |||
84 | /* INCLUDE FILES */ | 84 | /* INCLUDE FILES */ |
85 | /*****************************************************************************/ | 85 | /*****************************************************************************/ |
86 | 86 | ||
87 | #ifdef ROCKBOX | ||
88 | #include "plugin.h" | ||
89 | #include "pdbox.h" | ||
90 | #else /* ROCKBOX */ | ||
87 | #include <stdio.h> | 91 | #include <stdio.h> |
88 | #include <math.h> | 92 | #include <math.h> |
89 | #include <stdlib.h> | 93 | #include <stdlib.h> |
94 | #endif /* ROCKBOX */ | ||
90 | 95 | ||
91 | /* the following is needed only to declare pd_fft() as exportable in MSW */ | 96 | /* the following is needed only to declare pd_fft() as exportable in MSW */ |
92 | #include "m_pd.h" | 97 | #include "m_pd.h" |
@@ -280,7 +285,7 @@ void fft_clear(void) | |||
280 | nextnet = thisnet->next; | 285 | nextnet = thisnet->next; |
281 | net_dealloc(thisnet); | 286 | net_dealloc(thisnet); |
282 | free((char *)thisnet); | 287 | free((char *)thisnet); |
283 | } while (thisnet = nextnet); | 288 | } while ((thisnet = nextnet)); |
284 | } | 289 | } |
285 | } | 290 | } |
286 | 291 | ||
@@ -485,14 +490,21 @@ void load_registers(FFT_NET *fft_net, float *buf, int buf_form, | |||
485 | 490 | ||
486 | { | 491 | { |
487 | int *load_index = fft_net->load_index; | 492 | int *load_index = fft_net->load_index; |
493 | #ifdef ROCKBOX | ||
494 | SAMPLE *window = NULL; | ||
495 | int index, i = 0; | ||
496 | #else | ||
488 | SAMPLE *window; | 497 | SAMPLE *window; |
489 | int index, i = 0, n = fft_net->n; | 498 | int index, i = 0, n = fft_net->n; |
499 | #endif | ||
490 | 500 | ||
491 | if (trnsfrm_dir==FORWARD) window = fft_net->window; | 501 | if (trnsfrm_dir==FORWARD) window = fft_net->window; |
492 | else if (trnsfrm_dir==INVERSE) window = fft_net->inv_window; | 502 | else if (trnsfrm_dir==INVERSE) window = fft_net->inv_window; |
493 | else { | 503 | else { |
504 | #ifndef ROCKBOX | ||
494 | fprintf(stderr, "load_registers:illegal transform direction\n"); | 505 | fprintf(stderr, "load_registers:illegal transform direction\n"); |
495 | exit(0); | 506 | exit(0); |
507 | #endif | ||
496 | } | 508 | } |
497 | fft_net->direction = trnsfrm_dir; | 509 | fft_net->direction = trnsfrm_dir; |
498 | 510 | ||
@@ -539,8 +551,10 @@ void load_registers(FFT_NET *fft_net, float *buf, int buf_form, | |||
539 | } break; | 551 | } break; |
540 | 552 | ||
541 | default: { | 553 | default: { |
554 | #ifndef ROCKBOX | ||
542 | fprintf(stderr, "load_registers:illegal input form\n"); | 555 | fprintf(stderr, "load_registers:illegal input form\n"); |
543 | exit(0); | 556 | exit(0); |
557 | #endif | ||
544 | } break; | 558 | } break; |
545 | } | 559 | } |
546 | } break; | 560 | } break; |
@@ -591,15 +605,19 @@ void load_registers(FFT_NET *fft_net, float *buf, int buf_form, | |||
591 | } break; | 605 | } break; |
592 | 606 | ||
593 | default: { | 607 | default: { |
608 | #ifndef ROCKBOX | ||
594 | fprintf(stderr, "load_registers:illegal input form\n"); | 609 | fprintf(stderr, "load_registers:illegal input form\n"); |
595 | exit(0); | 610 | exit(0); |
611 | #endif | ||
596 | } break; | 612 | } break; |
597 | } | 613 | } |
598 | } break; | 614 | } break; |
599 | 615 | ||
600 | default: { | 616 | default: { |
617 | #ifndef ROCKBOX | ||
601 | fprintf(stderr, "load_registers:illegal input scale\n"); | 618 | fprintf(stderr, "load_registers:illegal input scale\n"); |
602 | exit(0); | 619 | exit(0); |
620 | #endif | ||
603 | } break; | 621 | } break; |
604 | } | 622 | } |
605 | } | 623 | } |
@@ -616,8 +634,15 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form, | |||
616 | */ | 634 | */ |
617 | 635 | ||
618 | { | 636 | { |
637 | #ifdef ROCKBOX | ||
638 | (void) debug; | ||
639 | #endif | ||
619 | int i; | 640 | int i; |
641 | #ifdef ROCKBOX | ||
642 | SAMPLE real, imag; | ||
643 | #else | ||
620 | SAMPLE real, imag, mag, phase; | 644 | SAMPLE real, imag, mag, phase; |
645 | #endif | ||
621 | int n; | 646 | int n; |
622 | 647 | ||
623 | i = 0; | 648 | i = 0; |
@@ -661,12 +686,21 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form, | |||
661 | if (real > .00001) | 686 | if (real > .00001) |
662 | *buf++ = (float)atan2(imag, real); | 687 | *buf++ = (float)atan2(imag, real); |
663 | else { /* deal with bad case */ | 688 | else { /* deal with bad case */ |
689 | #ifdef ROCKBOX | ||
690 | if (imag > 0){ *buf++ = PI / 2.; | ||
691 | } | ||
692 | else if (imag < 0){ *buf++ = -PI / 2.; | ||
693 | } | ||
694 | else { *buf++ = 0; | ||
695 | } | ||
696 | #else | ||
664 | if (imag > 0){ *buf++ = PI / 2.; | 697 | if (imag > 0){ *buf++ = PI / 2.; |
665 | if(debug) fprintf(stderr,"real=0 and imag > 0\n");} | 698 | if(debug) fprintf(stderr,"real=0 and imag > 0\n");} |
666 | else if (imag < 0){ *buf++ = -PI / 2.; | 699 | else if (imag < 0){ *buf++ = -PI / 2.; |
667 | if(debug) fprintf(stderr,"real=0 and imag < 0\n");} | 700 | if(debug) fprintf(stderr,"real=0 and imag < 0\n");} |
668 | else { *buf++ = 0; | 701 | else { *buf++ = 0; |
669 | if(debug) fprintf(stderr,"real=0 and imag=0\n");} | 702 | if(debug) fprintf(stderr,"real=0 and imag=0\n");} |
703 | #endif | ||
670 | } | 704 | } |
671 | } while (++i < n); | 705 | } while (++i < n); |
672 | } break; | 706 | } break; |
@@ -687,8 +721,10 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form, | |||
687 | } break; | 721 | } break; |
688 | 722 | ||
689 | default: { | 723 | default: { |
724 | #ifndef ROCKBOX | ||
690 | fprintf(stderr, "store_registers:illegal output form\n"); | 725 | fprintf(stderr, "store_registers:illegal output form\n"); |
691 | exit(0); | 726 | exit(0); |
727 | #endif | ||
692 | } break; | 728 | } break; |
693 | } | 729 | } |
694 | } break; | 730 | } break; |
@@ -753,15 +789,19 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form, | |||
753 | } break; | 789 | } break; |
754 | 790 | ||
755 | default: { | 791 | default: { |
792 | #ifndef ROCKBOX | ||
756 | fprintf(stderr, "store_registers:illegal output form\n"); | 793 | fprintf(stderr, "store_registers:illegal output form\n"); |
757 | exit(0); | 794 | exit(0); |
795 | #endif | ||
758 | } break; | 796 | } break; |
759 | } | 797 | } |
760 | } break; | 798 | } break; |
761 | 799 | ||
762 | default: { | 800 | default: { |
801 | #ifndef ROCKBOX | ||
763 | fprintf(stderr, "store_registers:illegal output scale\n"); | 802 | fprintf(stderr, "store_registers:illegal output scale\n"); |
764 | exit(0); | 803 | exit(0); |
804 | #endif | ||
765 | } break; | 805 | } break; |
766 | } | 806 | } |
767 | } | 807 | } |
@@ -992,7 +1032,11 @@ void short_to_float(short *short_buf, float *float_buf, int n) | |||
992 | void pd_fft(float *buf, int npoints, int inverse) | 1032 | void pd_fft(float *buf, int npoints, int inverse) |
993 | { | 1033 | { |
994 | double renorm; | 1034 | double renorm; |
1035 | #ifdef ROCKBOX | ||
1036 | float *fp; | ||
1037 | #else | ||
995 | float *fp, *fp2; | 1038 | float *fp, *fp2; |
1039 | #endif | ||
996 | int i; | 1040 | int i; |
997 | renorm = (inverse ? npoints : 1.); | 1041 | renorm = (inverse ? npoints : 1.); |
998 | cfft((inverse ? INVERSE : FORWARD), npoints, RECTANGULAR, | 1042 | cfft((inverse ? INVERSE : FORWARD), npoints, RECTANGULAR, |