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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 = 0x04, // This note is marked for tempo measurement
  35. kSkipScFl = 0x08, // This isn't a real event (e.g. tied note) skip over it
  36. kInvalidScFl = 0x10 // This note has a calculated time
  37. };
  38. struct cmScoreLoc_str;
  39. // The score can be divided into arbitrary non-overlapping sections.
  40. typedef struct
  41. {
  42. const cmChar_t* label; // section label
  43. struct cmScoreLoc_str* locPtr; // location where this section starts
  44. unsigned begIndex; // score element index where this section starts
  45. double evenCoeff; //
  46. double dynCoeff; //
  47. double tempoCeoff; //
  48. } cmScoreSection_t;
  49. typedef struct
  50. {
  51. unsigned type; // Event type
  52. double secs; // Time location in seconds
  53. double durSecs; // Duration in seconds
  54. unsigned index; // Index of this event in the event array.
  55. cmMidiByte_t pitch; // MIDI pitch of this note
  56. unsigned flags; // Attribute flags for this event
  57. unsigned dynVal; // Dynamcis value pppp to ffff (1 to 11) for this note.
  58. unsigned barNumb; // Bar id of the measure containing this event.
  59. unsigned barNoteIdx; // Index of this note in this bar
  60. unsigned csvRowNumb; // File row number (not index) from which this record originated
  61. unsigned perfSmpIdx; // Time this event was performed or cmInvalidIdx if the event was not performed.
  62. unsigned perfVel; // Velocity of the performed note or 0 if the note was not performed.
  63. } cmScoreEvt_t;
  64. typedef struct cmScoreSet_str
  65. {
  66. unsigned typeFl; // See kXXXScFl flags above
  67. cmScoreEvt_t** eleArray; // Events that make up this set in time order
  68. unsigned eleCnt; //
  69. cmScoreSection_t** sectArray; // Array of pointers to sections to apply this set to
  70. unsigned sectCnt; //
  71. struct cmScoreSet_str* link; // cmScoreLoc_t setList link
  72. } cmScoreSet_t;
  73. // All events which are simultaneous are collected into a single
  74. // cmScoreLoc_t record.
  75. typedef struct cmScoreLoc_str
  76. {
  77. double secs; // Time of this location
  78. unsigned evtCnt; // Count of events in evtArray[].
  79. cmScoreEvt_t** evtArray; // Events which occur at this time.
  80. unsigned barNumb; // Bar number this event is contained by.
  81. cmScoreSet_t* setList; // Set's which end on this time location
  82. cmScoreSection_t* begSectPtr; // NULL if this location does not start a section
  83. } cmScoreLoc_t;
  84. typedef void (*cmScCb_t)( void* arg, const void* data, unsigned byteCnt );
  85. typedef cmRC_t cmScRC_t;
  86. typedef cmHandle_t cmScH_t;
  87. typedef void (*cmScCb_t)( void* arg, const void* data, unsigned byteCnt );
  88. extern cmScH_t cmScNullHandle;
  89. const cmChar_t* cmScEvtTypeIdToLabel( unsigned id );
  90. const cmChar_t* cmScDynIdToLabel( unsigned id );
  91. // Initialize a score object from a CSV File generated from a score spreadsheet.
  92. cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, cmScCb_t cbFunc, void* cbArg );
  93. cmScRC_t cmScoreFinalize( cmScH_t* hp );
  94. // Filename of last successfuly loaded score file.
  95. const cmChar_t* cmScoreFileName( cmScH_t h );
  96. // Validate the score handle
  97. bool cmScoreIsValid( cmScH_t h );
  98. // Access the score data.
  99. unsigned cmScoreEvtCount( cmScH_t h );
  100. cmScoreEvt_t* cmScoreEvt( cmScH_t h, unsigned idx );
  101. // Access the score location data
  102. unsigned cmScoreLocCount( cmScH_t h );
  103. cmScoreLoc_t* cmScoreLoc( cmScH_t h, unsigned idx );
  104. void cmScorePrintLoc( cmScH_t h );
  105. // Make callbacks for all events in the score. The callbacks
  106. // contain cmScMsg_t records serialized as a byte stream.
  107. // Use cmScoreDecode() to convert the byte string to a
  108. // cmScMsg_t record.
  109. cmScRC_t cmScoreSeqNotify( cmScH_t h );
  110. void cmScoreClearPerfInfo( cmScH_t h );
  111. void cmScoreSetPerfEvent( cmScH_t h, unsigned locIdx, unsigned smpIdx, unsigned pitch, unsigned vel );
  112. typedef enum
  113. {
  114. kInvalidMsgScId,
  115. kBeginMsgScId,
  116. kEventMsgScId,
  117. kEndMsgScId
  118. } cmScMsgTypeId_t;
  119. typedef struct
  120. {
  121. cmScMsgTypeId_t typeId;
  122. cmScoreEvt_t evt; // only used when typeId == kEventMsgScId
  123. } cmScMsg_t;
  124. // Decode a serialized cmScMsg_t from a byte stream as passed to the
  125. // cmScCb_t function.
  126. cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* );
  127. void cmScorePrint( cmScH_t h, cmRpt_t* rpt );
  128. void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif