// // Programmer: Craig Stuart Sapp // Creation Date: Thu Nov 15 08:55:35 PST 2001 // Last Modified: Thu Nov 15 08:55:40 PST 2001 // Filename: ...sig/examples/all/spinemv.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/spinemv.cpp // Syntax: C++; museinfo // // Description: For reorganizing spines in a humdrum file. // #include "humdrum.h" #include // function declarations: void checkOptions (Options& opts, int argc, char** argv); void example (void); void usage (const char* command); void getTransformation (HumdrumFile& hfile, Array& transform); void printTransformation (HumdrumFile& hfile, Array& transform); void printLine (HumdrumFile& hfile,Array& transform,int line); double getAveragePitch (HumdrumFile& hfile, int primaryTrack); // User interface variables: Options options; int reverseQ = 0; int determineQ = 0; int normalQ = 0; const char* primaryspine = "**kern"; ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { HumdrumFile hfile; checkOptions(options, argc, argv); // process the command-line options // figure out the number of input files to process int numinputs = options.getArgCount(); for (int i=0; i transform; getTransformation(hfile, transform); if (!determineQ) { printTransformation(hfile, transform); } } return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // printTransformation -- // void printTransformation(HumdrumFile& hfile, Array& transform) { int i; for (i=0; i& transform, int line) { int i, j; int target = 0; int count = 0; for (j=0; j& transform) { transform.setSize(1000); transform.setSize(0); transform.allowGrowth(1); int maxspine = hfile.getMaxTracks(); int i, j; if (reverseQ) { transform.setSize(maxspine); for (i=0; i lavg) { if (determineQ) { cout << "Score is in reverse order.\tpitch avgs:" << favg << "\tcompared to " << lavg << endl; return; } // reverse data by kern (or primary spine type) blocks for (i=maxspine; i>0; i--) { if (hfile.getTrackExInterp(i) == "**kern") { transform.append(i); j = i+1; while ((j <= maxspine) && (hfile.getTrackExInterp(j) != "**kern")) { transform.append(j); j++; } } } transform.allowGrowth(0); return; } else { // score is already in normal form if (determineQ) { cout << "Score is in normal order.\tpictch avgs.:" << favg << " compared to " << lavg << endl; return; } for (i=1; i<=maxspine; i++) { transform.append(i); } transform.allowGrowth(0); return; } } // reverse data by kern (or primary spine type) blocks char buffer[1024] = {0}; if (strncmp(primaryspine, "**", 2) != 0) { strcpy(buffer, "**"); strcat(buffer, primaryspine); } else { strcat(buffer, primaryspine); } for (i=maxspine; i>0; i--) { if (hfile.getTrackExInterp(i) == buffer) { transform.append(i); j = i+1; while ((j <= maxspine) && (hfile.getTrackExInterp(j) != buffer)) { transform.append(j); j++; } } } } ////////////////////////////// // // getAveragePitch -- get the base-12 pitch average. // double getAveragePitch(HumdrumFile& hfile, int primaryTrack) { int i, j, k; char buffer[1024] = {0}; double sum = 0.0; int count = 0; int tokencount = 0; int pitch = 0; for (i=0; i 0) { sum += pitch; count++; } } } } } return sum/count; } ////////////////////////////// // // usage -- // void usage(const char* command) { } // md5sum: 24272570a59c6e3ea0af102c34df1971 mvspine.cpp [20170605]