libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmOnset.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef cmOnset_h
  2. #define cmOnset_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"Musical event onset detector." kw:[audio] }
  7. enum
  8. {
  9. kOkOnRC = cmOkRC,
  10. kDspProcFailOnRC,
  11. kDspAudioFileFailOnRC,
  12. kDspTextFileFailOnRC,
  13. };
  14. typedef cmRC_t cmOnRC_t;
  15. typedef cmHandle_t cmOnH_t;
  16. enum { kNoneFiltId, kSmoothFiltId, kMedianFiltId };
  17. typedef struct
  18. {
  19. double wndMs;
  20. unsigned hopFact;
  21. unsigned audioChIdx;
  22. unsigned wndFrmCnt; // Detection window length
  23. double preWndMult; // Detection window stretch factor prior to current location.
  24. double threshold; // Spectal flux detection threshold
  25. double maxFrqHz; // Ignore frequencies above maxFrqHz during processing.
  26. double filtCoeff; // smoothing filter coeff (-.7)
  27. double medFiltWndMs;// median filter window in milliseconds
  28. unsigned filterId; // kSmoothFiltId || kMedianFiltId
  29. double preDelayMs; // move each detection preDelayMs backwards in time
  30. // on the audio output. (compensates for detection delay due to filtering)
  31. } cmOnsetCfg_t;
  32. extern cmOnH_t cmOnsetNullHandle;
  33. cmOnRC_t cmOnsetInitialize( cmCtx_t* c, cmOnH_t* hp );
  34. cmOnRC_t cmOnsetFinalize( cmOnH_t* hp );
  35. bool cmOnsetIsValid( cmOnH_t h );
  36. cmOnRC_t cmOnsetProc(
  37. cmOnH_t h,
  38. const cmOnsetCfg_t* cfg,
  39. const cmChar_t* inAudioFn );
  40. // Return count of detected onsets.
  41. unsigned cmOnsetCount( cmOnH_t h );
  42. // Return location of detected onsets as a sample offset into the file.
  43. unsigned cmOnsetSampleIndex( cmOnH_t h, unsigned idx );
  44. unsigned cmOnsetHopSampleCount( cmOnH_t h );
  45. cmOnRC_t cmOnsetWrite(
  46. cmOnH_t h,
  47. const cmChar_t* outAudioFn,
  48. const cmChar_t* outTextFn);
  49. cmOnRC_t cmOnsetTest( cmCtx_t* c );
  50. //)
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif