libcm is a C development framework with an emphasis on audio signal processing applications.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

cmProcTemplateHdr.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //| Copyright: (C) 2009-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. /*
  4. enum
  5. {
  6. kNoConvertFftFl = 0x00, // do not fill magV or phsV (leave output in complexV)
  7. kToPolarFftFl = 0x01, // fill magV and phsV with the polar form of complexV
  8. kToRectFftFl = 0x02 // fill magV (real) and phsV (imag) with the rect. form of commplexV,
  9. };
  10. */
  11. //-----------------------------------------------------------------------------------------------------------
  12. // FFT
  13. //
  14. #ifndef CONST_GUARD
  15. #define CONST_GUARD
  16. enum
  17. {
  18. kNoConvertFftFl = 0x00, // do not fill magV or phsV (leave output in complexV)
  19. kToPolarFftFl = 0x01, // fill magV and phsV with the polar form of complexV
  20. kToRectFftFl = 0x02 // fill magV (real) and phsV (imag) with the rect. form of commplexV,
  21. };
  22. #endif
  23. typedef struct STRUCT(Fft)
  24. {
  25. cmObj obj;
  26. FFT_PLAN_T0 plan; // fftw plan
  27. T0* inPtr; //
  28. COMPLEX_T0* complexV; // fft output in complex form
  29. unsigned wndSmpCnt; // length of the fft input buffer
  30. T1* magV; // magnitude or real output (amplitude NOT power)
  31. T1* phsV; // phase or imag output
  32. unsigned binCnt; // length of magV and phsV
  33. unsigned flags;
  34. bool copyFl;
  35. cmMtxFile* mfp;
  36. } CLASS(Fft);
  37. CLASS(Fft)* MEMBER(FftAlloc)( cmCtx* c, CLASS(Fft)* p, T0* inPtr, unsigned wndSmpCnt, unsigned flags );
  38. cmRC_t MEMBER(FftFree)( CLASS(Fft)** pp );
  39. cmRC_t MEMBER(FftInit)( CLASS(Fft)* p, T0* inPtr, unsigned wndSmpCnt, unsigned flags );
  40. cmRC_t MEMBER(FftFinal)( CLASS(Fft)* p );
  41. /// Set sp to NULL if a fixed input buffer was given in the call to cmFftAlloc() or cmFftInit()
  42. cmRC_t MEMBER(FftExec)( CLASS(Fft)* p, const T0* sp, unsigned sn );
  43. //-----------------------------------------------------------------------------------------------------------
  44. // IFFT
  45. //
  46. typedef struct STRUCT(IFft)
  47. {
  48. cmObj obj;
  49. unsigned binCnt;
  50. unsigned outN;
  51. COMPLEX_T1* complexV; // the type of complexV should match the type of outV
  52. T1* outV;
  53. FFT_PLAN_T1 plan;
  54. } CLASS(IFft);
  55. CLASS(IFft)* MEMBER(IFftAlloc)( cmCtx* c, CLASS(IFft)* p, unsigned binCnt );
  56. cmRC_t MEMBER(IFftFree)( CLASS(IFft)** pp );
  57. cmRC_t MEMBER(IFftInit)( CLASS(IFft)* p, unsigned binCnt );
  58. cmRC_t MEMBER(IFftFinal)( CLASS(IFft)* p );
  59. // x must contain 'binCnt' elements.
  60. cmRC_t MEMBER(IFftExec)( CLASS(IFft)* p, COMPLEX_T0* x );
  61. cmRC_t MEMBER(IFftExecPolar)( CLASS(IFft)* p, const T0* magV, const T0* phsV );
  62. cmRC_t MEMBER(IFftExecRect)( CLASS(IFft)* p, const T0* rV, const T0* iV );