libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmXScore.h 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef cmXScore_h
  2. #define cmXScore_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"Process a Music XML score in a variety of ways." kw[score] }
  7. //$
  8. // cmScoreTest() performs a the following functions:
  9. // - Parses Music XML files into a text (edit) file.
  10. // - The 'edit' file can then be manually edited to modify and add information to the score.
  11. // - The modified 'edit' file can then be used to generate a CSV file
  12. // suitable for use with cmScore(), a MIDI file which can render the modified score,
  13. // and a SVG file which will display the score as a piano roll.
  14. //
  15. enum
  16. {
  17. kOkXsRC = cmOkRC,
  18. kXmlFailXsRC,
  19. kLHeapFailXsRC,
  20. kSyntaxErrorXsRC,
  21. kCsvFailXsRC,
  22. kUnterminatedTieXsRC,
  23. kUnterminatedSlurXsRC,
  24. kUnterminatedOctaveShiftXsrRC,
  25. kPedalStateErrorXsRc,
  26. kMidiFailXsRC,
  27. kFileFailXsRC,
  28. kSvgFailXsRC,
  29. kOverlapWarnXsRC,
  30. kZeroLengthEventXsRC
  31. };
  32. typedef cmRC_t cmXsRC_t;
  33. typedef cmHandle_t cmXsH_t;
  34. extern cmXsH_t cmXsNullHandle;
  35. // Prepare the MusicXML file:
  36. //
  37. // 1) Convert XML to UTF-8:
  38. // a. Change: encoding = 'UTF-16' to encoding='UTF-8'
  39. // b. Emacs C-x <RET> f utf-8 <RET>
  40. // c. Change: <?xml ... encoding = 'UTF-16' to encoding='UTF-8' ...?>
  41. //
  42. // 2) Replace "DoletSibelius Unknown Symbol Index " with "DoletSibelius unknownSymIdx="
  43. //
  44. // Steps 1) and 2) can be automated by in emacs by:
  45. //
  46. // M-x load-file ~/src/emacs/proc_music_xml.el
  47. //
  48. // Initialize an cmXScore object from a Sibelius generated MusicXML file.
  49. // 'editFn' is used to add additional information to the score.
  50. // See cmXScoreGenEditFile()
  51. cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn, const cmChar_t* editFn, bool damperRptFl );
  52. cmXsRC_t cmXScoreFinalize( cmXsH_t* hp );
  53. bool cmXScoreIsValid( cmXsH_t h );
  54. cmXsRC_t cmXScoreWriteCsv( cmXsH_t h, int beginMeasNumb, const cmChar_t* csvFn );
  55. void cmXScoreReport( cmXsH_t h, cmRpt_t* rpt, bool sortFl );
  56. // Generate a template 'edit file'. This file can be edited by hand to included additional
  57. // information in the score. See the 'editFn' argument to cmXScoreInitialize() for where
  58. // this file is used.
  59. cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn, bool damperRptFl );
  60. // Generate the CSV file suitable for use by cmScore.
  61. //
  62. // If the file referenced by 'reorderFn' exists then it is used to attach additional
  63. // score information. If it does not then a new edit file is created via an
  64. // internal call to cmXScoreGenEditFile(). This file can then be edited
  65. // to include the additional score file information and passed back by a later
  66. // call to this same function.
  67. // Set reportFl to true to print a report of the score following processing.
  68. // Set begMeasNumb to the first measure the to be written to the output csv, MIDI and SVG files.
  69. // Set begBPM to 0 to use the tempo from the score otherwise set it to the tempo at begMeasNumb.
  70. cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn, const cmChar_t* svgOutFn, bool reportFl, int begMeasNumb, int begBPM, bool svgStandAloneFl, bool svgPanZoomFl, bool damperRptFl );
  71. //)
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif