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.

cmScore.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef cmScore_h
  2. #define cmScore_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkScRC = cmOkRC,
  9. kCsvFailScRC,
  10. kSyntaxErrScRC,
  11. kInvalidIdxScRC,
  12. kTimeLineFailScRC
  13. };
  14. enum
  15. {
  16. kInvalidEvtScId = 0,
  17. kTimeSigEvtScId,
  18. kKeySigEvtScId,
  19. kTempoEvtScId,
  20. kTrackEvtScId,
  21. kTextEvtScId,
  22. kEOTrackEvtScId,
  23. kCopyEvtScId,
  24. kBlankEvtScId,
  25. kBarEvtScId,
  26. kPgmEvtScId,
  27. kCtlEvtScId,
  28. kNonEvtScId
  29. };
  30. enum
  31. {
  32. kEvenScFl = 0x01, // This note is marked for evenness measurement
  33. kDynScFl = 0x02, // This note is marked for dynamics measurement
  34. kTempoScFl = 0x03, // This note is marked for tempo measurement
  35. kSkipScFl = 0x04, // This isn't a real event (e.g. tied note) skip over it
  36. kInvalidScFl = 0x08 // This note has a calculated time
  37. };
  38. typedef struct
  39. {
  40. unsigned type; // Event type
  41. double secs; // Time location in seconds
  42. double durSecs; // Duration in seconds
  43. unsigned index; // index of this event
  44. cmMidiByte_t pitch; // MIDI pitch of this note
  45. unsigned flags; // Attribute flags for this event
  46. unsigned dynVal; // Dynamcis value pppp to ffff (1 to 11) for this note.
  47. unsigned barNumb; // bar number of this event
  48. unsigned barNoteIdx; // index of this note in this bar
  49. } cmScoreEvt_t;
  50. typedef struct
  51. {
  52. double secs; // Time of this location
  53. unsigned evtCnt; // Count of events in evtArray[].
  54. cmScoreEvt_t** evtArray; // Events which occur at this time.
  55. unsigned evtIdx; // Index into the master event array
  56. // (p->array[]) of the first event in this loc.
  57. unsigned barNumb; // Bar number this event is contained by.
  58. } cmScoreLoc_t;
  59. typedef void (*cmScCb_t)( void* arg, const void* data, unsigned byteCnt );
  60. typedef cmRC_t cmScRC_t;
  61. typedef cmHandle_t cmScH_t;
  62. typedef void (*cmScCb_t)( void* arg, const void* data, unsigned byteCnt );
  63. extern cmScH_t cmScNullHandle;
  64. const cmChar_t* cmScEvtTypeIdToLabel( unsigned id );
  65. const cmChar_t* cmScDynIdToLabel( unsigned id );
  66. // Initialize a score object from a CSV File generated from a score spreadsheet.
  67. cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, cmScCb_t cbFunc, void* cbArg );
  68. cmScRC_t cmScoreFinalize( cmScH_t* hp );
  69. // Filename of last successfuly loaded score file.
  70. const cmChar_t* cmScoreFileName( cmScH_t h );
  71. bool cmScoreIsValid( cmScH_t h );
  72. // Access the score data.
  73. unsigned cmScoreEvtCount( cmScH_t h );
  74. cmScoreEvt_t* cmScoreEvt( cmScH_t h, unsigned idx );
  75. // Access the score location data
  76. unsigned cmScoreLocCount( cmScH_t h );
  77. cmScoreLoc_t* cmScoreLoc( cmScH_t h, unsigned idx );
  78. cmScRC_t cmScoreSeqNotify( cmScH_t h );
  79. typedef enum
  80. {
  81. kInvalidMsgScId,
  82. kBeginMsgScId,
  83. kEventMsgScId,
  84. kEndMsgScId
  85. } cmScMsgTypeId_t;
  86. typedef struct
  87. {
  88. cmScMsgTypeId_t typeId;
  89. cmScoreEvt_t evt; // only used when typeId == kEventMsgScId
  90. } cmScMsg_t;
  91. cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* );
  92. void cmScorePrint( cmScH_t h, cmRpt_t* rpt );
  93. cmScRC_t cmScoreSyncTimeLine( cmScH_t scH, cmTlH_t tlH, unsigned editDistWndCnt, cmReal_t maxNoteOffsetSecs );
  94. cmScRC_t cmScoreSyncTimeLineTest( cmCtx_t* ctx, const cmChar_t* timeLineJsFn, const cmChar_t* scoreCsvFn );
  95. void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
  96. void cmScoreFix( cmCtx_t* ctx );
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. #endif