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.

cmTakeSeqBldr.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #ifndef cmTakeSeqBldr_h
  2. #define cmTakeSeqBldr_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"Concatenate multiple overlapping MIDI performances into a single virtual performance by associating score information with the MIDI events." kw:[seq] }
  7. enum
  8. {
  9. kOkTsbRC = cmOkRC,
  10. kJsonFailTsbRC,
  11. kParseFailTsbRC,
  12. kTimeLineFailTsbRC,
  13. kScoreFailTsbRC,
  14. kInvalidArgTsbRC,
  15. kMidiFileFailTsbRC,
  16. kMissingScTrkTsbRC,
  17. kRenderSeqEmptyTsbRC,
  18. };
  19. typedef cmRC_t cmTsbRC_t;
  20. typedef cmHandle_t cmTakeSeqBldrH_t;
  21. extern cmTakeSeqBldrH_t cmTakeSeqBldrNullHandle;
  22. // Allocate a Sequence Builder.
  23. cmTsbRC_t cmTakeSeqBldrAlloc( cmCtx_t* ctx, cmTakeSeqBldrH_t* hp );
  24. // Allocate and initalize a sequence builder.
  25. cmTsbRC_t cmTakeSeqBldrAllocFn( cmCtx_t* ctx, cmTakeSeqBldrH_t* hp, const cmChar_t* scoreTrkFn );
  26. // Free a previously allocated sequence builder.
  27. cmTsbRC_t cmTakeSeqBldrFree( cmTakeSeqBldrH_t* hp );
  28. // Validate a sequence builder handle.
  29. bool cmTakeSeqBldrIsValid( cmTakeSeqBldrH_t h );
  30. // Load a score tracking file create by app/cmScoreProc.c:_cmScoreProcGenAssocMain().
  31. // Note that calling this function loads a time-line object and score object
  32. // along with the information contained in the score tracking file.
  33. cmTsbRC_t cmTakeSeqBldrInitialize( cmTakeSeqBldrH_t h, const cmChar_t* scoreTrkFn );
  34. // Load a group of notes delinated by a time-line marker into the sequence.
  35. // If notes overlap with existing notes according to their 'scEvtIdx' attribute:
  36. // a. If 'overWriteFl' is set then the incoming overlapped notes are enabled
  37. // and the existing overlapped notes are disabled, otherwise the incoming
  38. // overlapped notes are disabled and the existing notes remain enabled.
  39. // b. The incoming section is time aligned with the first or last existing
  40. // note depending on whether the new section aligns best with the beginning
  41. // or ending of the existing notes.
  42. //
  43. // If no overlapping notes exist then the incoming section is aligned by estimating
  44. // the alignment with existing notes using the score alone.
  45. cmTsbRC_t cmTakeSeqBldrLoadTake( cmTakeSeqBldrH_t h, unsigned tlMarkUid, bool overwriteFL );
  46. cmTsbRC_t cmTakeSeqBldrUnloadTake( cmTakeSeqBldrH_t h, unsigned tlMarkUid );
  47. double cmTakeSeqBldrSampleRate( cmTakeSeqBldrH_t h );
  48. // Return a handle to the score used by this cmTakeSeqBldr.
  49. cmScH_t cmTakeSeqBldrScoreHandle( cmTakeSeqBldrH_t h );
  50. // Return the count of score-track takes.
  51. unsigned cmTakeSeqBldrScTrkTakeCount( cmTakeSeqBldrH_t h );
  52. typedef struct
  53. {
  54. unsigned minScEvtIdx; // first score event index this 'take' contains
  55. unsigned maxScEvtIdx; // last score event index this 'take' contains
  56. unsigned tlMarkerUid; // the marker Uid associated with this take
  57. } cmTksbScTrkTake_t;
  58. // Given an index [0 - cmTakeSeqBldrScTrkTakeCount()) return a cmTksbScTrkTake_t record
  59. cmTsbRC_t cmTakeSeqBldrScTrkTake( cmTakeSeqBldrH_t h, unsigned idx, cmTksbScTrkTake_t* ref );
  60. // Return the text associated with the specified 'take' marker.
  61. const cmChar_t* cmTakeSeqBldrScTrkTakeText( cmTakeSeqBldrH_t h, unsigned tlMarkerUId );
  62. // Set score location index to cmInvalidIdx to rewind the player to the beginning of the sequence.
  63. cmTsbRC_t cmTakeSeqBldrPlaySeekLoc( cmTakeSeqBldrH_t h, unsigned scLocIdx );
  64. typedef struct
  65. {
  66. unsigned smpIdx; // NOTE: changes in this structure should be
  67. unsigned status; // might break;
  68. unsigned d0; // void _cmDspTakeSeqRendPedalsUp( cmDspCtx_t* ctx, cmDspInst_t* inst )
  69. unsigned d1; // because it loads a static array
  70. } cmTksbEvent_t;
  71. typedef void (*cmTakeSeqBldrPlayFunc_t)( void* arg, const cmTksbEvent_t* evt );
  72. cmTsbRC_t cmTakeSeqBldrPlayExec( cmTakeSeqBldrH_t h, unsigned deltaSmp, cmTakeSeqBldrPlayFunc_t cbFunc, void* cbArg );
  73. typedef struct
  74. {
  75. unsigned srcId;
  76. unsigned scEvtIdx;
  77. unsigned rid;
  78. unsigned flags;
  79. unsigned offsetSmp;
  80. unsigned durSmp;
  81. cmTksbEvent_t evt;
  82. } cmTksbRend_t;
  83. void cmTakeSeqBldrRendReset( cmTakeSeqBldrH_t h );
  84. bool cmTakeSeqBldrRendNext(cmTakeSeqBldrH_t h, cmTksbRend_t* rendRef );
  85. cmTsbRC_t cmTakeSeqBldrRendInfo( cmTakeSeqBldrH_t h, unsigned rid, cmTksbRend_t* r );
  86. cmTsbRC_t cmTakeSeqBldrRendDelete( cmTakeSeqBldrH_t h, unsigned rid );
  87. cmTsbRC_t cmTakeSeqBldrRendInsert(
  88. cmTakeSeqBldrH_t h,
  89. const cmTksbEvent_t* e,
  90. unsigned durSmp,
  91. unsigned* ridRef );
  92. cmTsbRC_t cmTakeSeqBldrWrite( cmTakeSeqBldrH_t h, const cmChar_t* fn );
  93. cmTsbRC_t cmTakeSeqBldrRead( cmTakeSeqBldrH_t h, const cmChar_t* fn );
  94. cmTsbRC_t cmTakeSeqBldrTest( cmCtx_t* ctx );
  95. //)
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif