// // Programmer: Craig Stuart Sapp // Creation Date: Mon Apr 26 12:57:44 PDT 2004 // Last Modified: Wed Apr 28 00:32:30 PDT 2004 // Filename: ...sig/examples/all/phrasenum.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/phrasenum.cpp // Syntax: C++; museinfo // // Description: Extracts the phrase locations in a monophonic song // according to which note the phrases start on. // #include "humdrum.h" #include #ifndef OLDCPP #include using namespace std; #else #include #endif // includes needed for file/directory processing: #include #include #include #include // function declarations: void checkOptions (Options& opts, int argc, char** argv); void example (void); void usage (const char* command); void processFile (HumdrumFile& hfile, const char* filename); void printAnalysis (Array& phrase, Array& phrasestart, Array& notes, const char* filename); void processArgument (const char* path); int is_file (const char* path); int is_directory (const char* path); // User interface variables: Options options; ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { // process the command-line options checkOptions(options, argc, argv); int i; int numinputs = options.getArgCount(); HumdrumFile hfile; for (i=0; id_name, ".", 1) == 0) { entry = readdir(dir); continue; } fullname = new char[strlen(path) + 1 + strlen(entry->d_name) + 1]; strcpy(fullname, path); strcat(fullname, "/"); strcat(fullname, entry->d_name); processArgument(fullname); entry = readdir(dir); } } closedir(dir); } ////////////////////////////// // // processFile -- print the analysis // void processFile(HumdrumFile& hfile, const char* filename) { Array notes; Array phrase; Array phrasestart; notes.setSize(1000); notes.setSize(0); phrase.setSize(1000); phrase.setSize(0); phrasestart.setSize(1000); phrasestart.setSize(0); int pitch; int counter = 0; int i; int start; for (i=0; i& phrase, Array& phrasestart, Array& notes, const char* filename) { if ((filename != NULL) && (filename[0] != '\0')) { cout << filename << "\t"; } // cout << "There are " << phrasestart.getSize() << " phrases.\n"; // cout << "Starting on the note numbers (offset from 1):\n"; int i; for (i=0; i