libcm is a C development framework with an emphasis on audio signal processing applications.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cmTakeSeqBldr.h 4.6KB

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