// // Programmer: Craig Stuart Sapp // Creation Date: Sat May 23 21:08:48 PDT 1998 // Last Modified: Fri Jul 3 14:18:04 PDT 1998 // Filename: ...sig/examples/all/base40.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/base40.cpp // Syntax: C++; museinfo // Reference: http://www.ccarh.org/publications/reprints/base40 // // Description: Converts **kern pitches into/from base 40 system. // #include "humdrum.h" #include #include #include // function declarations void checkOptions(Options& opts, int argc, char* argv[]); void processDataRecord(HumdrumRecord& line); void processExclusiveInterp(HumdrumRecord& line); void processTandemRecord(HumdrumRecord& line); void splitstring(const char* line, char* front, char* basestring, char* back, string& markstart, string& markend); void kernsplit(const char* line, char* front, char* back, string& markstart, string& markend); // global variables Options options; // database for command-line arguments int octaveQ = 1; // boolean for keeping or removing octave info int transpose = 0; // transposition value from command-line int preserveQ = 0; // boolean for keeping extra kern info int kernQ = 1; // boolean for converting **base40 to **kern int cvalue = 2; // default pitch class for C int noptionQ = 0; // for -n option: convert to specific key int mode = 0; // for -n option string newkey; // for -n option string markstart; // start of base40 number marker string markend; // end of base40 number marker /////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { // process the command-line options checkOptions(options, argc, argv); int numinputs = options.getArgCount(); HumdrumFile input; for (int j=0; j 0) && isupper(newkey[0])) { mode = 0; // Major } else { mode = 1; // Minor } int i = 0; for (i=0; i<(int)newkey.size(); i++) { if (newkey[i] == 's') { newkey[i] = '#'; } } } } ////////////////////////////// // // example -- example usage of the base40 program // void example(void) { cout << " \n" "no examples yet \n" " \n" << endl; } ////////////////////////////// // // kernsplit -- split up the kern into stuff before and stuff // after a pitch value. // void kernsplit(const char* line, char* front, char* back, string& markstart, string& markend) { int length = strlen(line); char *templine; templine = new char[length+1]; strcpy(templine, line); char* pointer; pointer = strtok(templine, "abcdefgABCDEFG#-n"); if (pointer != NULL) { strcpy(front, pointer); } else { front[0] = '\0'; } pointer = strtok(NULL, "abcdefgABCDEFG#-n"); if (pointer != NULL) { strcpy(back, pointer); } else { back[0] = '\0'; } delete [] templine; } ////////////////////////////// // // processDataRecord -- example usage of the base40 program // void processDataRecord(HumdrumRecord& line) { int k; int base40value; static char buffer[1024] = {0}; static char pitchbuffer[128] = {0}; static char front[128] = {0}; static char back[128] = {0}; static char basestring[128] = {0}; if (kernQ) { // converting from **base40 to **kern for (k=0; k**kern spines and converts them \n" "to a base-40 representation which preserves interval qualities between \n" "pitches. \n" " \n" "Usage: " << command << " [-r][-p] input \n" " \n" "Options: \n" " -r = keep **kern rhythms and other kern information. \n" " -p = convert to base40 pitch class, not asolute pitch. \n" " -k = convert from **base40 to **kern \n" " --options = list of all options, aliases and default values \n" " \n" << endl; } // md5sum: 0daf9147aea9e7df1309d27fe20671e8 base40.cpp [20160320]