libcm is a C development framework with an emphasis on audio signal processing applications.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cmPickup.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef cmPickup_h
  2. #define cmPickup_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkPuRC = cmOkRC,
  9. kProcFailPuRC,
  10. kJsonFailPuRC
  11. };
  12. typedef cmRC_t cmPuRC_t;
  13. typedef cmHandle_t cmPuH_t;
  14. // This record holds information which is maintained on a per-pickup basis
  15. typedef struct
  16. {
  17. unsigned begSmpIdx; // during auto-gain cfg set to the first sample in the audio example file where the group of notes from this pickup begin.
  18. unsigned endSmpIdx; // ... end of the example notes for this pickup
  19. unsigned midiPitch; // midi pitch associated with this pickup
  20. unsigned onCnt; // during auto-gain cfg set to the count of onsets detected for this pickup
  21. unsigned offCnt; // ... offset detected
  22. cmReal_t gateMaxAvg; // avg of the the max gate RMS values for all detected notes
  23. cmReal_t gain; // auto-gain coeff for this pickup
  24. } cmPuCh_t;
  25. extern cmPuH_t cmPuNullHandle;
  26. cmPuRC_t cmPuAlloc( cmCtx_t* ctx, cmPuH_t* hp );
  27. cmPuRC_t cmPuFree( cmPuH_t* hp );
  28. bool cmPuIsValid( cmPuH_t h );
  29. // Given a recorded audio file containing a set of notes recorded from each pickup,
  30. // an Audacity label file which marks the beginning of teach set of notes,
  31. // and a set of gate detector parameters attempt to calculate a set of gain
  32. // coefficients to equalize the relative gain of all the pickup channels.
  33. // This algorithm works in two passes: In the first pass the gain coefficient
  34. // is established by finding an average RMS value among the examples and
  35. // then increasing and decreasing the pickups to move the examples closer
  36. // to the average. The gain is then adjusted and a second pass is made to
  37. // examine how well the gate detectors work with the new gain setttings.
  38. cmPuRC_t cmPuAutoGainCfg(
  39. cmPuH_t h,
  40. const cmChar_t* audioFn, // audio file containing a set of examples for each note
  41. const cmChar_t* labelFn, // audicity label file with one marker preceding each set of notes
  42. const cmChar_t* outMtx0Fn, // octave binary matrix file containing the intermediate and final results of the gate detector analysis after the first pass
  43. const cmChar_t* outMtx1Fn, // octave binary matrix file containing the intermediate and final results of the gate detector analysis after the second pass
  44. const cmChar_t* outAudFn, // audioFn rewritten with auto-gain applied
  45. unsigned procSmpCnt, // analysis DSP frame size in samples
  46. cmReal_t hopMs, // analysis window hop size in milliseconds
  47. const cmGateDetectParams* gd0Args, // first pass gate detector args
  48. const cmGateDetectParams* gd1Args ); // second pass gate detector args
  49. // Calls cmPuReadJson() and then prepends the fileDir to each of the
  50. // file names. All the files are then read and written to this directory.
  51. // and calls cmPuAutoGainCfg().
  52. cmPuRC_t cmPuAutoGainCfgFromJson(
  53. cmPuH_t h,
  54. const cmChar_t* fileDir,
  55. cmJsonH_t jsH,
  56. cmJsonNode_t* onp,
  57. unsigned procSmpCnt );
  58. cmPuRC_t cmPuAutoGainExec( cmPuH_t h, const cmChar_t* fileDir, unsigned procSmpCnt );
  59. // Load the 'parmsCfg', 'gdArgs' and 'gain' array from the JSON
  60. // 'autoTune' object contained in the JSON object 'onp'.
  61. cmPuRC_t cmPuReadJson( cmPuH_t h, cmJsonH_t jsH, cmJsonNode_t* onp );
  62. unsigned cmPuChannelCount( cmPuH_t h );
  63. const cmPuCh_t* cmPuChannel( cmPuH_t h, unsigned chIdx );
  64. // Update the 'autoTune' JSON object contained the JSON object 'onp'.
  65. cmPuRC_t cmPuWriteJson( cmPuH_t h, cmJsonH_t jsH, cmJsonNode_t* onp );
  66. // Update the 'autoTune' JSON object in the JSON file 'jsonFn'.
  67. // (Same as cmPuWriteJson() except the JSON tree to update is contained in a file.)
  68. cmPuRC_t cmPuWriteJsonFile( cmPuH_t h, const cmChar_t* jsonFn );
  69. void cmPuReport( cmPuH_t h, cmRpt_t* rpt );
  70. void cmPuTest(cmCtx_t* ctx);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif