From b5fcaaa09a4f15774fb31a84af35254d6e6bd816 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 3 Aug 2020 12:13:11 -0400 Subject: [PATCH] xscore_gen.md, cmtools.c : Update notes and added 'damper' report flag. --- doc/xscore_gen.md | 29 +++++++++++++++++++++++++++-- src/cmtools/cmtools.c | 29 +++++++++-------------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/doc/xscore_gen.md b/doc/xscore_gen.md index 2032cc1..ae99fa1 100644 --- a/doc/xscore_gen.md +++ b/doc/xscore_gen.md @@ -89,10 +89,17 @@ of measured notes. Note that a decremented color stops all active measures not just the measurement associated with the decremented color. +### Section Numbering + +Rectangles around a number indicate sections numbers. +Sections are used to aggregate measurements and to +indicate where particular transforms will be applied in the electronic score. + + Preparing the Music XML File ---------------------------- -*xscore_gen* is know to work with the MusicXML files produced by +*xscore_gen* is known to work with the MusicXML files produced by the [Dolet 6 Sibelius plug-in] After generating the file it is necessary to do some @@ -100,12 +107,30 @@ minor pre-processing before submitting it to *xscore_gen* iconv -f UTF-16 -t UTF-8 -o score-utf16.xml score-utf8.xml +On the first line of score-utf8.xml change: + +``` + +``` + +to + +``` + +``` + +Note that naively opening `score-utf8.xml` with emacs will +crash emacs because the stated XML file encoding `encoding='UTF-16'` +will not match the actual file encoding (UTF-8). Work around +this problem by editing the first line with `vi`. + + Create the decoration file -------------------------- ``` -cmtools --score_gen -x myscore.xml -d mydec.txt +cmtools --score_gen -x myscore.xml -d mydec.txt {--damper} ``` Here's a snippet of a typical 'decoration' file. diff --git a/src/cmtools/cmtools.c b/src/cmtools/cmtools.c index 19c1420..7a12c8c 100644 --- a/src/cmtools/cmtools.c +++ b/src/cmtools/cmtools.c @@ -103,13 +103,13 @@ bool verify_non_null_filename( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* return kOkCtRC; } -cmRC_t score_gen( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* decFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn, const cmChar_t* svgOutFn, unsigned reportFl, int begMeasNumb, int begTempoBPM, bool svgStandAloneFl, bool svgPanZoomFl ) +cmRC_t score_gen( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* decFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn, const cmChar_t* svgOutFn, unsigned reportFl, int begMeasNumb, int begTempoBPM, bool svgStandAloneFl, bool svgPanZoomFl, bool damperRptFl ) { cmRC_t rc; if((rc = verify_file_exists(ctx,xmlFn,"XML file")) != kOkCtRC ) return rc; - if( cmXScoreTest( ctx, xmlFn, decFn, csvOutFn, midiOutFn, svgOutFn, reportFl, begMeasNumb, begTempoBPM, svgStandAloneFl, svgPanZoomFl ) != kOkXsRC ) + if( cmXScoreTest( ctx, xmlFn, decFn, csvOutFn, midiOutFn, svgOutFn, reportFl, begMeasNumb, begTempoBPM, svgStandAloneFl, svgPanZoomFl, damperRptFl ) != kOkXsRC ) return cmErrMsg(&ctx->err,kScoreGenFailedCtRC,"score_gen failed."); return kOkCtRC; @@ -206,16 +206,6 @@ cmRC_t audio_file_report( cmCtx_t* ctx, const cmChar_t* audioFn, const cmChar_t* return rc; } -cmRC_t midi_trim(cmCtx_t* ctx, const cmChar_t* midiInFn, unsigned begMidiUId, unsigned endMidiUId, const cmChar_t* midiOutFn) -{ - cmRC_t rc; - - if((rc = verify_file_exists(ctx,midiInFn,"MIDI file")) != kOkCtRC ) - return rc; - // kNoteTerminateFl | kPedalTerminateFl - return cmMidiFileTrimFn(ctx, midiInFn, begMidiUId, endMidiUId, 0, midiOutFn ); -} - int main( int argc, char* argv[] ) { @@ -240,6 +230,7 @@ int main( int argc, char* argv[] ) kSvgPanZoomFlPoId, kBegMeasPoId, kBegBpmPoId, + kDamperRptPoId, kBegMidiUidPoId, kEndMidiUidPoId }; @@ -252,8 +243,7 @@ int main( int argc, char* argv[] ) kScoreReportSelId, kMidiReportSelId, kTimelineReportSelId, - kAudioReportSelId, - kMidiTrimSelId + kAudioReportSelId }; @@ -281,6 +271,7 @@ int main( int argc, char* argv[] ) unsigned svgPanZoomFl = 1; int begMeasNumb = 0; int begTempoBPM = 60; + unsigned damperRptFl = 0; unsigned begMidiUId = cmInvalidId; unsigned endMidiUId = cmInvalidId; unsigned actionSelId = kNoSelId; @@ -316,8 +307,6 @@ int main( int argc, char* argv[] ) cmPgmOptInstallEnum( poH, kActionPoId, 'A', "audio_report", 0, kAudioReportSelId, kNoSelId, &actionSelId, 1, "Generate an audio file report.",NULL); - cmPgmOptInstallEnum( poH, kActionPoId, 'T', "midi_trim", 0, kMidiTrimSelId, kNoSelId, &actionSelId, 1, - "Trim a MIDI file to create a shortened version.",NULL); cmPgmOptInstallStr( poH, kXmlFileNamePoId, 'x', "muisic_xml_fn",0, NULL, &xmlFn, 1, "Name of the input MusicXML file."); @@ -361,6 +350,9 @@ int main( int argc, char* argv[] ) cmPgmOptInstallInt( poH, kBegBpmPoId, 'e', "beg_bpm", 0, 0, &begTempoBPM, 1, "Set to 0 to use the tempo from the score otherwise set to use the tempo at begMeasNumb." ); + cmPgmOptInstallFlag( poH, kDamperRptPoId, 'p', "damper", 0, 1, &damperRptFl, 1, + "Print the pedal events during 'score_gen' processing."); + cmPgmOptInstallFlag( poH, kSvgStandAloneFlPoId, 'n', "svg_stand_alone_fl",0, 1, &svgStandAloneFl, 1, "Write the SVG file as a stand alone HTML file. Enabled by default." ); @@ -384,7 +376,7 @@ int main( int argc, char* argv[] ) switch( actionSelId ) { case kScoreGenSelId: - rc = score_gen( &ctx, xmlFn, decFn, csvScoreFn, midiOutFn, svgOutFn, reportFl, begMeasNumb, begTempoBPM, svgStandAloneFl, svgPanZoomFl ); + rc = score_gen( &ctx, xmlFn, decFn, csvScoreFn, midiOutFn, svgOutFn, reportFl, begMeasNumb, begTempoBPM, svgStandAloneFl, svgPanZoomFl, damperRptFl ); break; case kScoreFollowSelId: @@ -411,9 +403,6 @@ int main( int argc, char* argv[] ) rc = audio_file_report(&ctx, audioFn, rptFn ); break; - case kMidiTrimSelId: - rc = midi_trim(&ctx, midiInFn, begMidiUId, endMidiUId, midiOutFn); - break; default: rc = cmErrMsg(&ctx.err, kNoActionIdSelectedCtRC,"No action selector was selected.");