// // Programmer: Craig Stuart Sapp // Creation Date: Tue Dec 18 11:01:22 PST 2001 // Last Modified: Wed Aug 20 22:37:23 PDT 2003 (add field option) // Last Modified: Thu Aug 21 19:20:02 PDT 2003 (added **kotov conversion) // Last Modified: Tue Aug 26 22:54:00 PDT 2003 (added spine manipulators) // Filename: ...sig/examples/all/koto2kern.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/koto2kern.cpp // Syntax: C++; museinfo // // Description: Convert **koto representation to **kern representation // // Note: Not finished // #include "humdrum.h" #include #include #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void convertKoto (HumdrumFile& infile); void processKotoData (HumdrumRecord& line); void processKotoDatum (const char* string, HumdrumRecord& line); void processInterpretation (HumdrumRecord& line); void storeTuning (const char* tunestring); void printRhythm (const char* string, double scaling = 1.0); void printPitch (const char* string, HumdrumRecord& line); void printKernNotes (const char* string, HumdrumRecord& line); // command line options: Options options; // database for command-line arguments int debugQ = 0; // for debugging options --debug int skeletonQ = 0; // convert only basic musical ornaments int appendQ = 0; // for use with the -a option int field = 0; // for use with the -f option Array tuning; // for koto tuning /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // input Humdrum Format file tuning.setSize(13); tuning.allowGrowth(0); // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); for (int i=0; i 1) { cout << "\t"; } cout << infile[i][spine]; } cout << "\n"; break; case E_humrec_interpretation: processInterpretation(infile[i]); break; case E_humrec_data: processKotoData(infile[i]); break; default: cout << "!!" << infile[i] << "\n"; break; } } } ////////////////////////////// // // processInterpretation -- // void processInterpretation(HumdrumRecord& line) { if (appendQ) { cout << line << "\t"; } if (strncmp(line[field], "**", 2) == 0) { cout << "**kern\n"; return; } int spine; int scount = 0; for (spine=0; spine 1) { cout << "\t"; } if (strcmp(line[spine], "*-") == 0) { cout << "*-"; continue; } if (strncmp(line[spine], "*M", 2) == 0) { int top, bottom; int count = sscanf(line[0], "*M%d/%d", &top, &bottom); if (count == 2) { cout << line[spine] << ""; } else { cout << "*"; } continue; } if (strncmp(line[spine], "*tune[", 6) == 0) { storeTuning(line[spine]); if (appendQ) { cout << "*"; } continue; } if (strcmp(line[spine], "*free") == 0) { cout << "*free"; continue; } if (strcmp(line[spine], "*strict") == 0) { cout << "*strict"; continue; } cout << line[spine]; } cout << "\n"; } /////////////////////////////// // // storeTuning -- // void storeTuning(const char* tunestring) { int length = strlen(tunestring); int i; int stringnum = 0; Array info(13); for (i=0; i<13; i++) { info[i] = -1; } for (i=6; i 0) { tuning[i] = info[i]; } } } ////////////////////////////// // // processKotoData -- // void processKotoData(HumdrumRecord& line) { static char buffer[1024] = {0}; if (appendQ) { cout << line << "\t"; } int spine; int i; int tokencount; int scount = 0; for (spine=0; spine 1) { cout << "\t"; } if (strncmp(line[spine], "-", 1) == 0) { cout << "."; continue; } tokencount = line.getTokenCount(spine); for (i=0; i 0) { if (pluscount == 2) { cout << "2."; } else { cout << (int)(4 / scaling) / (pluscount+1); } } else if (pipecount > 0) { cout << (int)(4 / scaling) * pow(2.0, pipecount); } else { cout << "RHYTHM_ERROR"; } for (i=0; i 3) { cout << "PERROR"; } // cout << ">" << sharpcount << "," << sharpcount2 << "<"; cout << Convert::base40ToKern(buffer, pvalue + octave * 40); if (!skeletonQ) { if (strchr(string, 's') != NULL) { // print sha ornament cout << ": "; if (index + 1 < tuning.getSize()) { pvalue = tuning[index + 1]; } printRhythm(string, scaling); cout << Convert::base40ToKern(buffer, pvalue + octave * 40); cout << ":"; } else if (strchr(string, 'o') != NULL) { // oshi tome: increase the current tone by a whole step cout << "H\n"; // beginning of glissando if (appendQ) { for (i=0; i