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.

cmAudioFileMgr.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef cmAudioFileMgr_h
  4. #define cmAudioFileMgr_h
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //( { file_desc:"Manages a collection of audio files and maintains downsampled copies of their signals." kw:[audio file] }
  9. enum
  10. {
  11. kOkAfmRC = cmOkRC,
  12. kAudioFileFailAfmRC
  13. };
  14. typedef cmHandle_t cmAfmH_t;
  15. typedef cmHandle_t cmAfmFileH_t;
  16. typedef cmRC_t cmAfmRC_t;
  17. extern cmAfmH_t cmAfmNullHandle;
  18. extern cmAfmFileH_t cmAfmFileNullHandle;
  19. //----------------------------------------------------------------------------
  20. // Audio Files
  21. //----------------------------------------------------------------------------
  22. cmAfmRC_t cmAfmFileOpen( cmAfmH_t h, cmAfmFileH_t* fhp, const cmChar_t* audioFn, unsigned fileId, cmAudioFileInfo_t* afInfo );
  23. cmAfmRC_t cmAfmFileClose( cmAfmFileH_t* fhp );
  24. bool cmAfmFileIsValid( cmAfmFileH_t fh );
  25. // Return the application supplied file id associated with this file.
  26. // This value was set by the 'fileId' argument to cmAfmFileOpen().
  27. unsigned cmAfmFileId( cmAfmFileH_t fh );
  28. // Return the file handle associated with this file.
  29. cmAudioFileH_t cmAfmFileHandle( cmAfmFileH_t fh );
  30. // Return a pointer to the information record associated with this file.
  31. const cmAudioFileInfo_t* cmAfmFileInfo( cmAfmFileH_t fh );
  32. // Summarize min and max values of the downSampled audio file.
  33. // The summary is kept in an internal cache which is used to
  34. // optimize the time required to complete later calls to cmAfmFileGetSummary().
  35. // 'downSampleFactor' is the count of samples per summary point.
  36. cmAfmRC_t cmAfmFileSummarize( cmAfmFileH_t fh, unsigned downSampleFactor );
  37. // Return a summary of the samples in the range audio file range
  38. // begSmpIdx:begSmpIdx+smpCnt-1 reduced or expanded to 'outCnt' values
  39. // in minV[outCnt] and maxV[outCnt].
  40. // If 'outCnt' is equal to 'smpCnt' then the actual sample values are returned.
  41. cmAfmRC_t cmAfmFileGetSummary( cmAfmFileH_t fh, unsigned chIdx, unsigned begSmpIdx, unsigned smpCnt, cmSample_t* minV, cmSample_t* maxV, unsigned outCnt );
  42. //----------------------------------------------------------------------------
  43. // Audio File Manager
  44. //----------------------------------------------------------------------------
  45. cmAfmRC_t cmAfmCreate( cmCtx_t* ctx, cmAfmH_t* hp );
  46. cmAfmRC_t cmAfmDestroy( cmAfmH_t* hp );
  47. bool cmAfmIsValid( cmAfmH_t h );
  48. cmAfmFileH_t cmAfmIdToHandle( cmAfmH_t h, unsigned fileId );
  49. //)
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. #endif