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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef cmProc4_h
  2. #define cmProc4_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. typedef struct
  7. {
  8. unsigned smpIdx; // time tag sample index for val
  9. cmMidiByte_t val; //
  10. bool validFl; //
  11. } cmScFolBufEle_t;
  12. typedef struct
  13. {
  14. unsigned pitchCnt; //
  15. unsigned* pitchV; // pitchV[pitchCnt]
  16. unsigned scIdx; // index of the score event (into cmScoreEvt[]) at this location
  17. int barNumb; // bar number of this location
  18. } cmScFolLoc_t;
  19. typedef struct
  20. {
  21. cmObj obj;
  22. cmReal_t srate; //
  23. cmScH_t scH; // score handle
  24. unsigned bufN; // event buffer count
  25. cmScFolBufEle_t* bufV; // event buffer bufV[bufN] - bufV[bufN-1] newest event, bufV[boi] oldest event
  26. int locN; // count of score locations
  27. cmScFolLoc_t* loc; // score loc[locN]
  28. unsigned sbi; // oldest score window index
  29. unsigned sei; // newest score window index
  30. unsigned msln; // minimum score look ahead count
  31. unsigned mswn; // maximum score window length
  32. unsigned forwardCnt; // count of score loc's to look ahead for a match to the current pitch when the optimal edit-dist alignment does not produce a match for the current pitch
  33. unsigned maxDist; // max. dist allowed to still consider matching
  34. unsigned minVel; // notes < minVel are ignored
  35. bool printFl; // true if pitch tracker reporting should be included
  36. bool noBackFl; // prevent the tracker from going backwards in time
  37. unsigned* edWndMtx;
  38. unsigned missCnt; // current consecutive unmatched notes
  39. unsigned matchCnt; // current consecutive matched notes
  40. unsigned eventIdx; // events since reset
  41. unsigned skipCnt; // notes skipped due to velocity
  42. unsigned ret_idx; // last tracked location
  43. } cmScFol;
  44. cmScFol* cmScFolAlloc( cmCtx* ctx, cmScFol* p, cmReal_t srate, cmScH_t scH, unsigned bufN, unsigned minWndLookAhead, unsigned maxWndCnt, unsigned minVel );
  45. cmRC_t cmScFolFree( cmScFol** pp );
  46. cmRC_t cmScFolInit( cmScFol* p, cmReal_t srate, cmScH_t scH, unsigned bufN, unsigned minWndLookAhead, unsigned maxWndCnt, unsigned minVel );
  47. cmRC_t cmScFolFinal( cmScFol* p );
  48. // Jump to a score location and reset the internal state of the follower.
  49. cmRC_t cmScFolReset( cmScFol* p, unsigned scoreIndex );
  50. // Give the follower a MIDI performance event. Only MIDI note-on events are acted upon;
  51. // all others are ignored.
  52. unsigned cmScFolExec( cmScFol* p, unsigned smpIdx, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1 );
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif