libcm is a C development framework with an emphasis on audio signal processing applications.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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