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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #ifndef cmSdb_h
  2. #define cmSdb_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*
  7. The data for this object is stored in a CSV file with the following column syntax.
  8. Column Name Type Description
  9. ------ -------- ----- -----------------------------------------------------
  10. 1 uuid uint Unique integer identifier for this event
  11. 2 baseUuid uint uuid of channel 0 for this event
  12. 3 chIdx uint Channel index (stereo: 1=left 2=right)
  13. 4 obi uint Outer onset sample index into 'afn'.
  14. 5 ibi uint Inner onset sample index into 'afn'.
  15. 6 iei uint Inner offset sample index into 'afn'.
  16. 7 oei uint Outer offset sample index into 'afn'.
  17. 8 src text Source label for this event (e.g. mcgill, ui )
  18. 9 midi uint MIDI pitch number or -1 if the sample is not pitched
  19. 10 instr text Instrument label.
  20. 11 srate uint Sample rate of audio file reference by 'afn'.
  21. 10 chCnt uint Count of channels for this event.
  22. * notes text 0 or more free form double quoted text notes.
  23. * afn text File name of the audio file this event occurs in.
  24. Notes:
  25. #. Each event represents a mono audio signal. If the event is drawn
  26. from a multi-channel audio file then the 'chCnt' field will be
  27. greater than one. If 'chCnt' is greater than one then the associated
  28. samples can be found by collecting all events that share the
  29. same 'baseUuid'.
  30. #. There may be zero or more columns of 'notes'. If there are no
  31. notes then the 'afn' field is in column 11.
  32. #. The index values (chIdx,obi,ibi,iei,oei) as stored in the CSV file
  33. are 1 based. These values are decreased by 1 by the cmSdb CSV reader
  34. so that their cmSdb value is zero based. See cmSdbLoad().
  35. */
  36. enum
  37. {
  38. kOkSdbRC,
  39. kLHeapFailSdbRC,
  40. kCsvFailSdbRC,
  41. kSyntaxErrSdbRC,
  42. kInvalidRspIdxSdbRC,
  43. kChPairNotFoundSdbRC
  44. };
  45. typedef cmHandle_t cmSdbH_t;
  46. typedef cmHandle_t cmSdbResponseH_t;
  47. typedef cmRC_t cmSdbRC_t;
  48. extern cmSdbH_t cmSdbNullHandle_t;
  49. extern cmSdbResponseH_t cmSdbResponseNullHandle_t;
  50. typedef struct
  51. {
  52. unsigned uuid; // unique id of this sample
  53. unsigned baseUuid; // uuid of channel 0
  54. unsigned chIdx; // channel index (0=left,1=right)
  55. unsigned obi; // outer onset
  56. unsigned ibi; // inner onset
  57. unsigned iei; // inner offset
  58. unsigned oei; // outer offset
  59. unsigned midi; // MIDI pitch or -1 for unpitched instruments
  60. unsigned srate; // sample rate
  61. unsigned chCnt; // source channel count
  62. const cmChar_t* src; // sample source (e.g. mcgill, ui )
  63. const cmChar_t* instr; // instrument label
  64. const cmChar_t* afn; // audio file name
  65. const cmChar_t** notesV; // NULL terminated list of terms describing the event.
  66. } cmSdbEvent_t;
  67. cmSdbRC_t cmSdbCreate( cmCtx_t* ctx, cmSdbH_t* hp, const cmChar_t* audioDir, const cmChar_t* csvFn );
  68. cmSdbRC_t cmSdbDestroy( cmSdbH_t* hp );
  69. bool cmSdbIsValid( cmSdbH_t h );
  70. cmSdbRC_t cmSdbLoad( cmSdbH_t h, const cmChar_t* csvFn );
  71. // Select a set of events from the sample database.
  72. //
  73. // The possible selection criteria are:
  74. // sample rate
  75. // instrument label
  76. // source label
  77. // notes labels
  78. // event duration
  79. //
  80. // In order to match an event all active criteria
  81. // must match. In other words the match implies a
  82. // logical AND operation on each match criteria.
  83. // Each of the criteria can be made inactive by
  84. // specifying particular key values.
  85. // sample rate = 0
  86. // instrument label = NULL
  87. // source label = NULL
  88. // notes labels = NULL
  89. // event duration = minDurSec=0 maxDurSec=0
  90. //
  91. // For the text array arguments (instrV,srcV,notesV)
  92. // each element of the array is a key which is attempts to
  93. // match the associated field in each event record.
  94. // By default a match is triggered if the key text is identical to the
  95. // event field text. The match algorithm can be modified by
  96. // specifying a '*' as the first character in the key field.
  97. // In this case a the key need only be a substring of the
  98. // event field to trigger a match. For example "*viol"
  99. // will return events that match both "violin" and "viola".
  100. //
  101. // To specify a mismatch as a successful match
  102. // (i.e. to return events which do not match the key text)
  103. // prefix the key with a '!' character.
  104. //
  105. // Note that it is legal to specify both '!' and '*'. In
  106. // which case a match will be triggered by fields where
  107. // the key text is not a substring of the field text.
  108. //
  109. // All query response handles returned from this function
  110. // should eventualy be released by the application via a call to
  111. // cmSdbResponseFree().
  112. cmSdbRC_t cmSdbSelect(
  113. cmSdbH_t h,
  114. double srate, // event sample rate or 0 to ignore
  115. const cmChar_t** instrV, // array of instrument labels to match
  116. const cmChar_t** srcV, // array of 'src' labels to match
  117. const cmChar_t** notesV, // array of text 'notes' to match
  118. double minDurSec, // min event duration
  119. double maxDurSec, // max event duration or 0 to ignore
  120. unsigned minChCnt, // min ch cnt or 0 to ignore
  121. cmSdbResponseH_t* rhp );
  122. // Given the event 'ep' locate the channel pairs associated with that event.
  123. // The response handle returned from this function must be released
  124. // by a call to cmSdbResponseFree().
  125. cmSdbRC_t cmSdbSelectChPairs( cmSdbH_t h, const cmSdbEvent_t* ep, cmSdbResponseH_t* rhp );
  126. // Return the count of events in a query response.
  127. unsigned cmSdbResponseCount( cmSdbResponseH_t rh );
  128. // Return the event at 'index' in from a query response.
  129. // Legal 'index' range: 0<=index<=cmSdbResponseCount().
  130. const cmSdbEvent_t* cmSdbResponseEvent( cmSdbResponseH_t rh, unsigned index );
  131. // Return true if the 'rh' is a non-NULL query response handle.
  132. bool cmSdbResponseIsValid( cmSdbResponseH_t rh );
  133. // Release the resource held by a query response.
  134. cmSdbRC_t cmSdbResponseFree( cmSdbResponseH_t* rhp );
  135. void cmSdbResponsePrint( cmSdbResponseH_t rh, cmRpt_t* rpt );
  136. // Time align all channel pairs by setting the onset times to
  137. // the minimum time among all the pairs and the offset times to
  138. // the maximum among all the pairs.
  139. cmSdbRC_t cmSdbSyncChPairs( cmSdbH_t h );
  140. cmSdbRC_t cmSdbTest( cmCtx_t* ctx );
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif