// // Programmer: Craig Stuart Sapp // Creation Date: Thu Jun 22 17:16:28 PDT 2000 // Last Modified: Thu Jun 29 21:21:31 PDT 2000 // Last Modified: Sun Mar 13 23:07:45 PDT 2016 Switched to STL // Filename: ...sig/exmaples/all/vofun.cpp // Web Page: http://sig.sapp.org/examples/museinfo/humdrum/vofun.cpp // Syntax: C++; museinfo // Reference: http://dactyl.som.ohio-state.edu/Humdrum/representations/embel.rep.html // // Description: Analyzes **kern data for voice function analyses. // // #include "humdrum.h" #include #include #include #include #include using namespace std; // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void determineChordQuality (ChordQuality& cq, const HumdrumRecord& aRecord); void example (void); void prepareOutput (void); void processRecords (HumdrumFile& infile); void usage (const char* command); void doAnalysis (void); // global variables Options options; // database for command-line arguments char unknown[256] = {0}; // space for unknown chord simplification int chordinit; // for initializing chord detection function EnumerationEmbellish embellish; int spinecount = 0; // the number of **kern spines in the input vector Line; // the translation between elements and // file line numbers. typedef vector arrayint; vector Notes; // the input notes to be analyzed vector Functions; // the output functions vector Inversion; // the inversion value for the harmony vector Root; // the root value for the harmony in Base 40 vector Quality; // the quality for the harmony HumdrumFile infile, outfile; /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { // initialize harmony tracking arrays Inversion.reserve(10000); Root.reserve(10000); Quality.reserve(10000); Line.reserve(10000); Notes.reserve(100); Functions.reserve(100); int k; for (k=0; k<100; k++) { Notes[k].reserve(10000); Functions[k].reserve(10000); } Inversion.resize(0); Root.resize(0); Quality.resize(0); Line.resize(0); Notes.resize(0); Functions.resize(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 lastnotes; // for keeping track of null record notes int i; if (chordinit) { chordinit = 0; lastnotes.resize(aRecord.getFieldCount()); for (i=0; i currentNotes(lastnotes.size()); int count = 0; for (i=0; i"; cout << "\ti=" << Inversion[i] << "\tr=" << Root[i] << "\tq=" << Quality[i] << "\n"; } char buffer[1024] = {0}; int k; j = 0; for (int i=0; i= 0) { strcat(buffer, embellish.getName(Functions[k][j])); } else { strcat(buffer, "?"); } if (k < spinecount - 1) { strcat(buffer, "\t"); } } outfile.appendLine(buffer); j++; break; default: outfile.appendLine(infile[i]); } } } ////////////////////////////// // // processRecords -- looks at humdrum records and determines chord // quality // void processRecords(HumdrumFile& infile) { ChordQuality quality; HumdrumRecord currRecord; int i, j; for (i=0; i