fork download
  1. #include <stdio.h>
  2. #include <vector>
  3. #define DPI (2*M_PI)
  4. using namespace std;
  5. vector<double> Re;// [出力] 実数部
  6. vector<double> Im;// [出力] 虚数部
  7. void dft(MONO_PCM pcm,size_t st, size_t ed)
  8. {
  9. // dft
  10. int N = ed-st;
  11. int* a = &pcm.s[st];
  12. Re.clear();
  13. Im.clear();
  14. for( int fq=0; fq<NN; fq++ )
  15. {
  16. double Re_sum = 0;
  17. double Im_sum = 0;
  18. for( int i=0; i<NN; ++i){
  19. double tht = DPI*fq*i/N;
  20. Re_sum += a[i] * cos( tht );
  21. Im_sum += a[i] * -sin( tht );
  22. }
  23. Re.push_back( Re_sum );
  24. Im.push_back( Im_sum );
  25. }
  26. return;
  27. }
  28. void idft(MONO_PCM& pcm,size_t N)
  29. {
  30. for( int fq=0; fq<N; fq++ )
  31. {
  32. double Re_sum = 0;
  33. double Im_sum = 0;
  34. for( int i=0; i<N; ++i){
  35. double tht = DPI*fq*i/N;
  36. Re_sum += Re[i] * cos(tht)
  37. -Im[i] * sin(tht);
  38. Im_sum += Re[i] * sin(tht)
  39. +Im[i] * cos(tht);
  40. }
  41. pcm.s.push_back(Re_sum/N);
  42. }
  43. return;
  44. }
  45.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:10: error: variable or field 'dft' declared void
 void dft(MONO_PCM pcm,size_t st, size_t ed)
          ^
prog.cpp:7:10: error: 'MONO_PCM' was not declared in this scope
prog.cpp:7:30: error: expected primary-expression before 'st'
 void dft(MONO_PCM pcm,size_t st, size_t ed)
                              ^
prog.cpp:7:41: error: expected primary-expression before 'ed'
 void dft(MONO_PCM pcm,size_t st, size_t ed)
                                         ^
stdout
Standard output is empty