// // Programmer: Craig Stuart Sapp // Creation Date: Tue Jun 5 13:48:27 PDT 2001 // Last Modified: Tue Jun 5 13:48:29 PDT 2001 // Filename: ...sig/examples/all/hum2xml.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/hum2xml.cpp // Syntax: C++; museinfo // // Description: Converts a Humdrum file into MusicXML. // #include "humdrum.h" #include #include #include #ifndef OLDCPP #include #else #include #endif // function declarations: void checkOptions (Options& opts, int argc, char** argv); void example (void); void convertToMusicXML (HumdrumFile& hfile); int makePartList (HumdrumFile& hfile); void makePart (HumdrumFile& hfile, int start, int spine, int count); void generatePartInfo (HumdrumFile& hfile, int start, int spine, int count); void convertDataToMusicXML (HumdrumFile& hfile, int line, int trace); void convertMeasureToXML (HumdrumFile& hfile, int line, int spine); void convertAttributeToXML (HumdrumFile& hfile, int line, int spine); void convertNoteToXML (HumdrumFile& hfile, int line, int spine); void pline (int level, char* string); void usage (const char* command); double convertNoteEntryToXML (HumdrumFile& hfile, int line, int spine, const char* buffer, int chord, int vlevel); void checkMeasure (void); void printDurationType (const char* durstring); void printDots (const char* durstring); void adjustKey (int keyinfo); void checkAccidentals (int diatonic, int alter, int chord); void updateAccidentals (void); void printGlobalComments (HumdrumFile& hfile, int direction); void printGlobalComment (HumdrumFile& hfile, int line); void printBibliography (HumdrumFile& hfile, int line); void checkbackup (void); void processTextUnderlay (HumdrumFile& hfile, int line, int spine); void displayUnknownTextType(HumdrumFile& hfile, int line, int spine, int verse); void displayLyrics (HumdrumFile& hfile, int line, int spine, int verse); void displayHTMLText (const char* buffer); void processBeams (HumdrumFile& hfile, int line, int spine, const char* buffer, int vlevel); // User interface variables: Options options; int debugQ = 0; // used with the --debug option int cautionaryQ = 1; // used with the --nocaution option int reverseQ = 0; // reverse the ordering of the parts int lev = 0; // indentation level in output text int minit = 0; // at start of each part: if measure is active double smallestdur = 1.0; // smallest durational component in the music int divisions = 1; // number of divisions per beat int v1lastmeasure[7] = {0}; // for explicit accidentals ABCDEFG int v1states[7] = {0}; // for explicit accidentals ABCDEFG int v1key[7] = {0}; // for explicit accidentals ABCDEFG int v1chord[7] = {0}; // for explicit accidentals ABCDEFG int v1prechordstates[7] = {0}; // for explicit accidentals ABCDEFG int direction = 0; // for commands int beamlevel[128] = {0}; // for beaming information int musicstart = 0; // for suppressing bars before music starts // int attributes = 0; // for suppressing multiple attributes entries ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { // process the command-line options checkOptions(options, argc, argv); HumdrumFile hfile(options.getArg(1)); hfile.analyzeRhythm(); divisions = hfile.getMinTimeBase(); if (divisions % 4 == 0) { divisions = divisions/4; } else { // don't know what this case may be } convertToMusicXML(hfile); return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // checkOptions -- // void checkOptions(Options& opts, int argc, char* argv[]) { opts.define("debug=b", "print debug information"); opts.define("nocaution=b", "print cautionary accidentals"); opts.define("r|reverse=b", "reverse the order of the parts"); opts.define("author=b", "author of program"); opts.define("version=b", "compilation info"); opts.define("example=b", "example usages"); opts.define("h|help=b", "short description"); opts.process(argc, argv); // handle basic options: if (opts.getBoolean("author")) { cout << "Written by Craig Stuart Sapp, " << "craig@ccrma.stanford.edu, May 1998" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: 3 July 1998" << endl; cout << "compiled: " << __DATE__ << endl; cout << MUSEINFO_VERSION << endl; exit(0); } else if (opts.getBoolean("help")) { usage(opts.getCommand()); exit(0); } else if (opts.getBoolean("example")) { example(); exit(0); } debugQ = opts.getBoolean("debug"); cautionaryQ = !opts.getBoolean("nocaution"); reverseQ = opts.getBoolean("reverse"); } ////////////////////////////// // // example -- // void example(void) { } ////////////////////////////// // // convertToMusicXML -- // void convertToMusicXML(HumdrumFile& hfile) { pline(lev, "\n"); pline(lev, "\n"); pline(lev, "\n"); lev--; printGlobalComments(hfile, 1); pline(lev, "\n"); int count = makePartList(hfile); int start = 0; while (start < hfile.getNumLines() && strncmp(hfile[start][0], "**", 2) != 0) { start++; } int i; int gcount = 0; if (!reverseQ) { for (i=hfile[start].getFieldCount()-1; i>=0; i--) { if (strcmp(hfile[start].getExInterp(i), "**kern") != 0) { continue; } gcount++; makePart(hfile, start, i, gcount); count--; } } else { // doing things in reverse order for (i=0; i\n"); printGlobalComments(hfile, -1); if (count != 0) { cerr << "Error in generating parts: number of parts has changed" << endl; } } ////////////////////////////// // // printGlobalComments // void printGlobalComments(HumdrumFile& hfile, int direction) { int start = 0; int stop = hfile.getNumLines(); int i; if (direction == 1) { start = 0; i = 0; while (i < hfile.getNumLines()) { if (strncmp(hfile[i][0], "**", 2) == 0) { stop = i; break; } i++; } } else { stop = hfile.getNumLines() - 1; i = stop; while (i >= 0) { if (strcmp(hfile[i][0], "*-") == 0) { start = i; break; } i--; } } for (i=start; i<=stop; i++) { switch (hfile[i].getType()) { case E_humrec_global_comment: printGlobalComment(hfile, i); break; case E_humrec_bibliography: printBibliography(hfile, i); break; } } } ////////////////////////////// // // printGlobalComment -- // void printGlobalComment(HumdrumFile& hfile, int line) { pline(lev, "\n"; } ////////////////////////////// // // printBibliography -- // void printBibliography(HumdrumFile& hfile, int line) { char buffer[1024] = {0}; strcpy(buffer, hfile[line][0]); int i = 0; while (buffer[i] != '\0') { if (buffer[i] == ':') { buffer[i] = '\0'; i++; if (buffer[i] == ' ') { buffer[i] = '\0'; i++; } break; } i++; } if (i == 0) return; pline(lev, "\n"; } ////////////////////////////// // // makePart -- // void makePart(HumdrumFile& hfile, int start, int spine, int count) { cout << "\n"; pline(lev, "\n"; lev++; minit = 0; musicstart = 0; checkMeasure(); lev++; pline(lev, "\n"); // attributes = 1; lev++; pline(lev, ""); cout << divisions << "\n"; lev--; pline(lev, "\n"); // att lev--; // att int line = 0; int trace = 0; for (line = start+1; line < hfile.getNumLines(); line++) { trace = 0; if (strncmp(hfile[line][0], "!!", 2) == 0) { continue; } if (hfile[line].getType() == E_humrec_empty) { continue; } while (trace < hfile[line].getFieldCount() && spine+1 != hfile[line].getPrimaryTrack(trace)) { trace++; } if (strcmp(hfile[line].getExInterp(trace), "**kern") != 0) { continue; } if (trace < hfile[line].getFieldCount()) { convertDataToMusicXML(hfile, line, trace); } else { cout << "Error on line " << line+1 << ": Spine error\n"; } } lev--; pline(lev, "\n"); } ////////////////////////////// // // convertDataToMusicXML -- // void convertDataToMusicXML(HumdrumFile& hfile, int line, int trace) { if (debugQ) { cout << "DATA = " << hfile[line][trace] << " \n"; } switch(hfile[line].getType()) { case E_humrec_none: case E_humrec_empty: case E_humrec_global_comment: case E_humrec_bibliography: case E_humrec_data_comment: break; case E_humrec_data_kern_measure: convertMeasureToXML(hfile, line, trace); break; case E_humrec_interpretation: convertAttributeToXML(hfile, line, trace); break; case E_humrec_data: musicstart = 1; convertNoteToXML(hfile, line, trace); break; default: break; } } ////////////////////////////// // // updateAccidentals -- restore accidentals at a measure boundary. // void updateAccidentals(void) { // copy v1states to v1lastmeasure // and fill v1states with v1key int i; for (i=0; i<7; i++) { v1lastmeasure[i] = v1states[i]; v1states[i] = v1key[i]; } } ////////////////////////////// // // convertMeasureToXML -- // void convertMeasureToXML(HumdrumFile& hfile, int line, int spine) { int measureno = -1; if (!musicstart) { return; } updateAccidentals(); const char *ptr; if (strcmp(hfile[line][spine], "==") == 0 || strcmp(hfile[line+1][0], "*-") == 0) { checkbackup(); lev++; pline(lev, "\n"); lev++; pline(lev, "light-heavy\n"); lev--; pline(lev, "\n"); lev--; pline(lev, "\n"); } else if ((ptr = strchr(hfile[line][spine], ':')) != NULL) { if ((ptr+1)[0] == '|' || (ptr+1)[0] == '!') { lev++; pline(lev, "\n"); lev++; if (strstr(hfile[line][spine], ":|!") != NULL) { pline(lev, "light-heavy\n"); } else if (strstr(hfile[line][spine], ":||") != NULL) { pline(lev, "light-light\n"); } else if (strstr(hfile[line][spine], ":!") != NULL) { pline(lev, "heavy\n"); } else if (strstr(hfile[line][spine], ":|") != NULL) { pline(lev, "light\n"); } pline(lev, "\n"); lev--; pline(lev, "\n"); lev--; } } else if (strstr(hfile[line][spine], "||") != NULL) { checkbackup(); lev++; pline(lev, "\n"); lev++; pline(lev, "light-light\n"); lev--; pline(lev, "\n"); lev--; } if (strcmp(hfile[line+1][0], "*-") == 0) { return; } checkbackup(); if (minit != 0) { pline(lev, "\n"); } minit++; if (sscanf(hfile[line][spine], "=%d", &measureno)) { pline(lev, "\n"; } else { pline(lev, "\n"); } if ((ptr = strchr(hfile[line][spine], ':')) != NULL) { if ((ptr-1)[0] == '|' || (ptr-1)[0] == '!') { lev++; pline(lev, "\n"); lev++; if (strstr(hfile[line][spine], ":|!") != NULL) { pline(lev, "light-heavy\n"); } else if (strstr(hfile[line][spine], ":||") != NULL) { pline(lev, "light-light\n"); } else if (strstr(hfile[line][spine], ":!") != NULL) { pline(lev, "heavy\n"); } else if (strstr(hfile[line][spine], ":|") != NULL) { pline(lev, "light\n"); } pline(lev, "\n"); lev--; pline(lev, "\n"); lev--; } } } ////////////////////////////// // // checkMeasure -- // void checkMeasure(void) { if (minit == 0) { minit++; pline(lev, "\n"; } } ////////////////////////////// // // adjustKey -- replace the old key signature with a new one // void adjustKey(int keyinfo) { int i; for (i=0; i<7; i++) { v1key[i] = 0; } if (keyinfo < 0) { v1key['B' - 'A'] = -1; if (keyinfo < -1) v1key['E' - 'A'] = -1; if (keyinfo < -2) v1key['A' - 'A'] = -1; if (keyinfo < -3) v1key['D' - 'A'] = -1; if (keyinfo < -4) v1key['G' - 'A'] = -1; if (keyinfo < -5) v1key['C' - 'A'] = -1; if (keyinfo < -6) v1key['F' - 'A'] = -1; } if (keyinfo > 0) { v1key['F' - 'A'] = 1; if (keyinfo > 1) v1key['C' - 'A'] = 1; if (keyinfo > 2) v1key['G' - 'A'] = 1; if (keyinfo > 3) v1key['D' - 'A'] = 1; if (keyinfo > 4) v1key['A' - 'A'] = 1; if (keyinfo > 5) v1key['E' - 'A'] = 1; if (keyinfo > 6) v1key['B' - 'A'] = 1; } // erase previous measure accidentals: for (i=0; i<7; i++) { v1lastmeasure[i] = v1key[i]; v1states[i] = v1key[i]; } } ////////////////////////////// // // convertAttributeToXML -- // void convertAttributeToXML(HumdrumFile& hfile, int line, int spine) { int length = strlen(hfile[line][spine]); if (strncmp(hfile[line][spine], "*M", 2) == 0 && strchr(hfile[line][spine], '/') != NULL) { // meter marking int top = 0; int bottom = 0; int flag = sscanf(hfile[line][spine], "*M%d/%d", &top, &bottom); if (flag == 2) { checkMeasure(); lev++; // if (!attributes) { pline(lev, "\n"); lev++; // attributes = 1; // } pline(lev, "\n"); lev--; pline(lev, "\n"); // att lev--; // att } } else if (strncmp(hfile[line][spine], "*k[", 3) == 0 && hfile[line][spine][length-1] == ']') { // key signature int pitch = 0; if (length > 4) { pitch = Convert::kernToBase40(&hfile[line][spine][length-3]); pitch = pitch % 40; } else { pitch = E_muse_c; } int keyinfo = 0; switch (pitch) { case E_muse_c: keyinfo = 0; break; case E_muse_fs: keyinfo = 1; break; case E_muse_cs: keyinfo = 2; break; case E_muse_gs: keyinfo = 3; break; case E_muse_ds: keyinfo = 4; break; case E_muse_as: keyinfo = 5; break; case E_muse_es: keyinfo = 6; break; case E_muse_bs: keyinfo = 7; break; case E_muse_bf: keyinfo = -1; break; case E_muse_ef: keyinfo = -2; break; case E_muse_af: keyinfo = -3; break; case E_muse_df: keyinfo = -4; break; case E_muse_cf: keyinfo = -5; break; case E_muse_gf: keyinfo = -6; break; case E_muse_ff: keyinfo = -7; break; } adjustKey(keyinfo); checkMeasure(); lev++; // if (!attributes) { pline(lev, "\n"); lev++; // attributes = 1; // } pline(lev, "\n"); lev++; pline(lev, ""); cout << keyinfo << "\n"; lev--; pline(lev, "\n"); lev--; pline(lev, "\n"); // att lev--; // att } else if (strcmp(hfile[line][spine], "*clefF4") == 0) { checkMeasure(); lev++; // if (!attributes) { pline(lev, "\n"); lev++; // attributes = 1; // } pline(lev, "\n"); lev++; pline(lev, "F\n"); pline(lev, "4\n"); lev--; pline(lev, "\n"); lev--; pline(lev, "\n"); // att lev--; // att } else if (strcmp(hfile[line][spine], "*clefG2") == 0) { checkMeasure(); lev++; // if (!attributes) { pline(lev, "\n"); lev++; // attributes = 1; // } pline(lev, "\n"); lev++; pline(lev, "G\n"); pline(lev, "2\n"); lev--; pline(lev, "\n"); lev--; pline(lev, "\n"); // att lev--; // att } } ////////////////////////////// // // convertNoteToXML -- // void convertNoteToXML(HumdrumFile& hfile, int line, int spine) { static char buffer[128] = {0}; int i; if (strcmp(hfile[line].getExInterp(spine), "**kern") != 0) { return; } musicstart = 1; // copy current accidentals into chord buffer for (i=0; i<7; i++) { v1chord[i] = v1lastmeasure[i]; v1prechordstates[i] = v1states[i]; } lev++; double cdur = 0; int xdur = 0; int tokencount = hfile[line].getTokenCount(spine); for (i=0; i 0) { // backwards pline(lev, "\n"); lev++; pline(lev, ""); cout << direction << "\n"; lev--; pline(lev, "\n"); } else if (direction < 0) { // forwards pline(lev, "\n"); lev++; pline(lev, ""); cout << -direction << "\n"; lev--; pline(lev, "\n"); } direction = 0; } ////////////////////////////// // // convertNoteEntryToXML -- // double convertNoteEntryToXML(HumdrumFile& hfile, int line, int spine, const char* buffer, int chord, int vlevel) { double output = 0; if (strcmp(buffer, ".") == 0) { // nothing to do return 0.0; } int explicitz = 0; int altered = 0; double duration = Convert::kernToDuration(buffer); int pitch = Convert::kernToBase40(buffer); char buff2[64] = {0}; if (pitch > 0) { Convert::base40ToKern(buff2, pitch); } else { strcpy(buff2, "r"); } if (strstr(buff2, "--") != NULL) { } else if (strstr(buff2, "--") != NULL) { altered = -2; } else if (strstr(buff2, "##") != NULL) { altered = 2; } else if (strstr(buff2, "-") != NULL) { altered = -1; } else if (strstr(buff2, "#") != NULL) { altered = 1; } else if (strstr(buffer, "n") != NULL) { altered = 0; explicitz = 1; } else { altered = 0; explicitz = 0; } char diapitch = toupper(buff2[0]); int octave = 0; if (pitch > 0) { octave = pitch / 40; } if (debugQ) { cout << "+++ processing note token: " << buffer << endl; } // if (attributes) { // lev--; // pline(lev, "\n"); // lev--; // att // attributes = 0; // } checkbackup(); pline(lev, "\n"); lev++; int grace = 0; if (strchr(buffer, 'q') != NULL || strchr(buffer, 'Q') != NULL) { grace = 1; } if (grace) { pline(lev, "\n"); } if (chord) { pline(lev, "\n"); } if (toupper(diapitch) != 'R') { pline(lev, "\n"); lev++; pline(lev, ""); cout << diapitch << "\n"; if (altered != 0) { pline(lev, ""); cout << altered << "\n"; } pline(lev, ""); cout << octave << "\n"; lev--; pline(lev, "\n"); } else { pline(lev, "\n"); } if (!grace) { pline(lev, ""); cout << duration*divisions << "\n"; output = duration; } else { output = 0.0; } int tietype = 0; if (strchr(buffer, '[') != NULL) { tietype = 1; } else if (strchr(buffer, '_') != NULL) { tietype = 2; } else if (strchr(buffer, ']') != NULL) { tietype = 3; } switch (tietype) { case 1: pline(lev, "\n"); break; case 2: pline(lev, "\n"); pline(lev, "\n"); break; case 3: pline(lev, "\n"); break; } int vcase = 0; if (strchr(hfile[line].getSpineInfo(spine), '(') == NULL) { vcase = 0; pline(lev, "1\n"); pline(lev, ""); } else if (strchr(hfile[line].getSpineInfo(spine), 'a') != NULL) { vcase = 1; pline(lev, "1\n"); pline(lev, ""); } else if (strchr(hfile[line].getSpineInfo(spine), 'b') != NULL) { vcase = 2; pline(lev, "2\n"); pline(lev, ""); } else { vcase = 3; pline(lev, "1\n"); pline(lev, ""); } char durstring[32] = {0}; Convert::durationToKernRhythm(durstring, duration); printDurationType(durstring); cout << "\n"; printDots(durstring); /// WRITTEN ACCIDENTALS //////////////////////////////////////////// if (toupper(buff2[0]) != 'R') { if (strchr(buffer, 'n') != NULL) { pline(lev, "natural\n"); v1states[toupper(buff2[0]) - 'A'] = 0; v1lastmeasure[toupper(buff2[0]) - 'A'] = 0; } else { checkAccidentals(toupper(buff2[0]), altered, chord); } } if (strchr(buffer, '/') != NULL) { pline(lev, "up\n"); } else if (strchr(buffer, '\\') != NULL) { pline(lev, "down\n"); } else if (vcase == 1) { pline(lev, "down\n"); } else if (vcase == 2) { if (strchr(buffer, '/') == NULL && strchr(buffer, '\\') == NULL) { pline(lev, "up\n"); } } if (duration >= 1.0) { // kill rogue beam marks. beamlevel[vlevel] = 0; } if (!chord) { processBeams(hfile, line, spine, buffer, vlevel); } /// WRITTEN TIES /////////////////////////////////////////////////// if (tietype) { pline(lev, "\n"); lev++; switch (tietype) { case 1: pline(lev, "\n"); break; case 2: pline(lev, "\n"); pline(lev, "\n"); break; case 3: pline(lev, "\n"); break; } lev--; pline(lev, "\n"); } /// FERMATAS /////////////////////////////////////////////////////// if (strchr(buffer, ';') != NULL) { pline(lev, "\n"); lev++; pline(lev, "\n"); lev--; pline(lev, "\n"); } /// ARTICULATIONS //////////////////////////////////////////// if (strchr(buffer, '\'') != NULL) { pline(lev, "\n"); lev++; pline(lev, "\n"); lev++; pline(lev, "\n"); lev--; pline(lev, "\n"); lev--; pline(lev, "\n"); } if (strchr(buffer, '~') != NULL) { pline(lev, "\n"); lev++; pline(lev, "\n"); lev++; pline(lev, "\n"); lev--; pline(lev, "\n"); lev--; pline(lev, "\n"); } if (strchr(buffer, '^') != NULL) { pline(lev, "\n"); lev++; pline(lev, "\n"); lev++; pline(lev, "\n"); lev--; pline(lev, "\n"); lev--; pline(lev, "\n"); } /// LYRICS ///////////////////////////////////////////////////////// if (!chord) { processTextUnderlay(hfile, line, spine); } lev--; pline(lev, "\n"); return output; } ////////////////////////////// // // processBeams -- // void processBeams(HumdrumFile& hfile, int line, int spine, const char* buffer, int vlevel) { int backhook = 0; int forehook = 0; int openbeam = 0; int closebeam = 0; int i=0; int sum = 0; int length = strlen(buffer); for (i=0; icontinue\n"; } return; } // int totalcount = beamlevel[vlevel] + openbeam - closebeam + // backhook + forehook; int rcount = 0; if (openbeam != 0) { // add any new beams which are starting // continue any old beams for (i=0; icontinue\n"; rcount++; } // add new beams for (i=0; ibegin\n"; rcount++; } beamlevel[vlevel] += openbeam; // add any opening beam hook for (i=0; iforward hook\n"; rcount++; } } if (closebeam != 0) { // close any old beams which are ending // continue any old beams for (i=0; icontinue\n"; rcount++; } // close old beams for (i=0; iend\n"; rcount++; } beamlevel[vlevel] -= closebeam; // add any ending beam hook for (i=0; ibackward hook\n"; rcount++; } } if (beamlevel[vlevel] < 0) { beamlevel[vlevel] = 0; } } ////////////////////////////// // // processTextUnderlay -- // void processTextUnderlay(HumdrumFile& hfile, int line, int spine) { int fields = hfile[line].getFieldCount(); if (spine >= fields-1) { return; } int tspine = spine+1; int verse = 1; while (tspine < fields && strcmp(hfile[line].getExInterp(tspine), "**kern") != 0) { if (strcmp(hfile[line][tspine], ".") == 0) { // ignore null tokens } else if (strcmp(hfile[line].getExInterp(tspine), "**text") == 0) { displayLyrics(hfile, line, tspine, verse); } else { displayUnknownTextType(hfile, line, tspine, verse); } tspine++; verse++; } } ////////////////////////////// // // displayLyrics -- // void displayLyrics(HumdrumFile& hfile, int line, int spine, int verse) { displayUnknownTextType(hfile, line, spine, verse); } ////////////////////////////// // // displayUnknownTextType -- // void displayUnknownTextType(HumdrumFile& hfile, int line, int spine, int verse) { pline(lev, "\n"; lev++; pline(lev, "single\n"); pline(lev, ""); displayHTMLText(hfile[line][spine]); cout << "\n"; lev--; pline(lev, "\n"); } ////////////////////////////// // // displayHTMLText -- // void displayHTMLText(const char* buffer) { int length = strlen(buffer); for (int i=0; i"); switch (alter) { case 2: cout << "double-sharp"; break; case 1: cout << "sharp"; break; case 0: cout << "natural"; break; case -1: cout << "flat"; break; case -2: cout << "double-flat"; break; } cout << "\n"; v1states[diatonic - 'A'] = alter; v1lastmeasure[diatonic - 'A'] = alter; } else if (cautionaryQ && v1lastmeasure[diatonic - 'A'] != alter) { // if a cautionary accidental accross measure, then adjust here pline(lev, ""); switch (alter) { case 2: cout << "double-sharp"; break; case 1: cout << "sharp"; break; case 0: cout << "natural"; break; case -1: cout << "flat"; break; case -2: cout << "double-flat"; break; } cout << "\n"; v1states[diatonic - 'A'] = alter; v1lastmeasure[diatonic - 'A'] = alter; } } else { // note in a chord diatonic = toupper(diatonic); if (v1prechordstates[diatonic - 'A'] != alter) { pline(lev, ""); switch (alter) { case 2: cout << "double-sharp"; break; case 1: cout << "sharp"; break; case 0: cout << "natural"; break; case -1: cout << "flat"; break; case -2: cout << "double-flat"; break; } cout << "\n"; v1states[diatonic - 'A'] = alter; v1lastmeasure[diatonic - 'A'] = alter; } else if (cautionaryQ && v1chord[diatonic - 'A'] != alter) { // if a cautionary accidental accross measure, then adjust here pline(lev, ""); switch (alter) { case 2: cout << "double-sharp"; break; case 1: cout << "sharp"; break; case 0: cout << "natural"; break; case -1: cout << "flat"; break; case -2: cout << "double-flat"; break; } cout << "\n"; v1states[diatonic - 'A'] = alter; v1lastmeasure[diatonic - 'A'] = alter; } } } ////////////////////////////// // // printDots -- // void printDots(const char* durstring) { int length = strlen(durstring); int i; for (i=0; i\n"); } } } ////////////////////////////// // // printDurationType -- // void printDurationType(const char* durstring) { char buffer[32] = {0}; int length = strlen(durstring); strcpy(buffer, durstring); for (int i=0; i\n"); lev++; // find the start of the spine data and output a part for each // spine int i = 0; int count = 0; // the number of **kern spines int j = 0; while (i=0; j--) { if (strcmp(hfile[i].getExInterp(j), "**kern") != 0) { continue; } count++; generatePartInfo(hfile, i, j, count); } } lev--; pline(lev, "\n"); return count; } ////////////////////////////// // // generatePart -- // void generatePartInfo(HumdrumFile& hfile, int start, int spine, int count) { int i = start + 1; int j = 0; pline(lev, "\n"; lev++; int done = 0; while (!done && i < hfile.getNumLines()) { if (hfile[i].getType() == E_humrec_interpretation) { for (j=0; j"); cout << &(hfile[i][j][2]) << "\n"; } else { pline(lev, "XPart "); cout << spine << "\n"; } lev--; pline(lev, "\n"); } ////////////////////////////// // // pline -- print a line of data // void pline(int level, char* string) { for (int i=0; i