libcm is a C development framework with an emphasis on audio signal processing applications.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cmProcTemplateHdr.h 2.6KB

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