// // Programmer: Craig Stuart Sapp // Creation Date: Fri Nov 20 17:55:43 PST 2015 // Last Modified: Fri Nov 20 17:55:47 PST 2015 // Filename: ...sig/examples/all/satzfehler.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/satzfehler.cpp // Syntax: C++; museinfo // // Description: Identify Satzfehler: one voices does 1-7-1 harmonic pattern // while another voies sings at some point inbetween a 7. // #include "humdrum.h" #include class NoteNode { public: int base40; int track; int measure; int startline; int endline; int spine; }; // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); int analyzeSatzfehler (HumdrumFile& infile); void getNotes (HumdrumFile& infile, Array >& notes, Array& ktracks, Array& rtracks); void printNotes (Array >& notes); int identifySatzfehler (HumdrumFile& infile, Array >& notes, Array& ktracks, Array& rtracks); int checkForStazfehler (HumdrumFile& infile, int startline, int endline, int xtrack, int tpitch, Array& targetlines, Array& targetspines); void markToken (HumdrumFile& infile, int line, int spine, string& signifier); void extractSatzfehler (HumdrumFile& infile, int line, int spine, Array& targetlines, Array& targetspines); // global variables Options options; // database for command-line arguments int markQ = 1; // mark notes (currently stuck on). int countQ = 0; // used with -c option int fileQ = 0; // used with -f option string Signifier = "Z"; // string to mark satzfehler notes. int extractQ = 0; // used with -x option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFileSet infiles; // process the command-line options checkOptions(options, argc, argv); infiles.read(options); int numinputs = infiles.getCount(); int i; int count; int sum = 0; for (i=0; i 1)) { cout << "!!satzfehler-total: " << sum << endl; } return 0; } /////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // analyzeSatzfehler -- // int analyzeSatzfehler(HumdrumFile& infile) { Array > notes; Array ktracks; Array rtracks; getNotes(infile, notes, ktracks, rtracks); // printNotes(notes); int count = identifySatzfehler(infile, notes, ktracks, rtracks); return count; } ////////////////////////////// // // identifySatzfehler -- // int identifySatzfehler(HumdrumFile& infile, Array >& notes, Array& ktracks, Array& rtracks) { int i, j; int status; Array targetlines(3); Array targetspines(3); int int1, int2; int counter = 0; for (i=0; i& targetlines, Array& targetspines) { int i, j, k; int tpc = tpitch % 40; int upc; int track; int result = 0; for (i=startline; i<=endline; i++) { if (!infile[i].isData()) { continue; } for (j=0; j& targetlines, Array& targetspines) { int track1 = infile[targetlines[0]].getPrimaryTrack(targetspines[0]); int track2 = infile[line].getPrimaryTrack(spine); int track; int minline = targetlines[0]; int maxline = targetlines.last(); int i, j; int scount; cout << "**kern\t**kern\n"; for (i=minline; i<=maxline; i++) { scount = 0; for (j=0; j 1) { cout << "\t"; } if (track == track2) { if ((i == minline) && (strstr(infile[i][j], Signifier.data()) == NULL)) { cout << "rX"; } else { cout << infile[i][j]; } } else { cout << infile[i][j]; } } } cout << endl; } cout << "*-\t*-\n"; } ////////////////////////////// // // printNotes -- for debugging. // void printNotes(Array >& notes) { int i, j; for (i=0; i >& notes, Array& ktracks, Array& rtracks) { notes.setSize(0); infile.getKernTracks(ktracks); if (ktracks.getSize() == 0) { return; } notes.setSize(ktracks.getSize()); rtracks.setSize(infile.getMaxTracks() + 1); rtracks.setAll(-1); int i, j; for (i=0; i 0) { if (notes[col].last().base40 < 0) { continue; } } } notes[col].append(note); } } } ////////////////////////////// // // checkOptions -- validate and process command-line options. // void checkOptions(Options& opts, int argc, char* argv[]) { opts.define("debug=b", "trace input parsing"); opts.define("author=b", "author of the program"); opts.define("version=b", "compilation information"); opts.define("example=b", "example usage"); opts.define("h|help=b", "short description"); opts.define("s|signifier=s:Z", "Satzfehler marker in data"); opts.define("c|count=b", "count Satzfehlers"); opts.define("f|file|filename=b", "display filenames"); opts.define("x|extract=b", "extract Satzfehler voice pairs"); opts.process(argc, argv); // handle basic options: if (opts.getBoolean("author")) { cout << "Written by Craig Stuart Sapp, " << "craig@ccrma.stanford.edu, Nov 2015" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: 20 Nov 2015" << endl; cout << "compiled: " << __DATE__ << endl; cout << MUSEINFO_VERSION << endl; exit(0); } else if (opts.getBoolean("help")) { usage(opts.getCommand().data()); exit(0); } else if (opts.getBoolean("example")) { example(); exit(0); } Signifier = opts.getString("signifier"); countQ = opts.getBoolean("count"); fileQ = opts.getBoolean("filename"); extractQ = opts.getBoolean("extract"); if (extractQ) { markQ = 0; } } ////////////////////////////// // // example -- example usage of the maxent program // void example(void) { cout << " \n" << endl; } ////////////////////////////// // // usage -- gives the usage statement for the quality program // void usage(const char* command) { cout << " \n" << endl; } // md5sum: c95f7e855da6f942b2aab39aaf94b1ce satzfehler.cpp [20151120]