// // Programmer: Craig Stuart Sapp // Creation Date: Sat May 23 21:08:48 PDT 1998 // Last Modified: Fri Jul 3 14:18:04 PDT 1998 // Last Modified: Sat Oct 14 20:26:15 PDT 2000 (revised for museinfo 1.0) // Last Modified: Wed Nov 29 12:14:41 PST 2000 (use internal analysis) // Last Modified: Tue Apr 21 00:41:11 PDT 2009 (fixed spine manip printing) // Last Modified: Thu May 14 20:25:17 PDT 2009 (-U option added) // Last Modified: Mon Apr 26 06:21:58 PDT 2010 (-n, -s options added) // Filename: ...sig/examples/all/sonority2.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/sonority2.cpp // Syntax: C++; museinfo // // Description: Analyzes **kern data for timeslice chord qualities // #include "humdrum.h" #include #include #ifndef OLDCPP #include #else #include #endif // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void processRecords (HumdrumFile& infile); void usage (const char* command); void fillStringWithNotes (char* string, ChordQuality& quality, HumdrumFile& infile, int line); int identifyBassNote (SigCollection& notes, HumdrumFile& infile, int line, Array& sounding); int transitionalSonority(ChordQuality& quality, HumdrumFile& infile, int line); // 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 int explicitQ = 0; // used with -U option int notesQ = 0; // used with -n option int suppressQ = 0; // used with -s option int parenQ = 1; // used with -P option int appendQ = 0; // used with -a option int octaveVal = -100; // used with -o option const char* notesep = " "; // used with -N option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile, outfile; // 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 cq; infile.analyzeSonorityQuality(cq); ChordQuality quality; int foundstart = 0; char aString[512] = {0}; for (int i=0; i= 0) { Convert::base40ToKern(buffer, (notes[i]%40) + octaveVal * 40); } else { Convert::base40ToKern(buffer, notes[i] + ((octave[i]+4) * 40)); } if (parenQ && (sounding[i] == 0)) { strcat(string, "("); } strcat(string, buffer); if (parenQ && (sounding[i] == 0)) { strcat(string, ")"); } if (i < notes.getSize() - 1) { strcat(string, notesep); } } } ////////////////////////////// // // identifyBassnote -- // int identifyBassNote(SigCollection& notes, HumdrumFile& infile, int line, Array& sounding) { int j, k; int output = -1; int minval = 1000000; int value; int tcount; char buffer[128] = {0}; Array soundQ(40); soundQ.setAll(0); sounding.setSize(notes.getSize()); sounding.setAll(0); int pline; int pspine; int dotQ = 0; if (notes.getSize() == 0) { return -1; } for (j=0; j 100000) { return -1; } minval = minval % 12; int i; int tval; for (i=0; i= 0) { if (soundQ[notes[i]%40]) { sounding[i] = 1; } } tval = Convert::base40ToMidiNoteNumber(notes[i]); if (tval < 0) { continue; } tval = tval % 12; if (tval == minval) { output = i; // break; need to supress this because of sounding tests } } return output; } ////////////////////////////// // // usage -- gives the usage statement for the sonority program // void usage(const char* command) { cout << " \n" "Analyzes **kern data and generates a **qual spine which gives the chord \n" "quality of the **kern spines. Currently, input spines cannot split or \n" "join. \n" " \n" "Usage: " << command << " [-a][-i|-r|-t] [input1 [input2 ...]] \n" " \n" "Options: \n" " -a = assemble the **qual analysis spine with input data \n" " -i = displays the **qual chord inversion only \n" " -r = displays the **qual chord root only \n" " -t = displays the **qual chord type only \n" " --options = list of all options, aliases and default values \n" " \n" << endl; } // md5sum: e1a3157578ca9ef3030d1d10adb8fadc sonority.cpp [20100430]