// // Programmer: Craig Stuart Sapp // Creation Date: Mon Nov 20 17:56:26 PST 2000 // Last Modified: Mon Nov 20 17:56:29 PST 2000 // Filename: ...sig/examples/all/terdis.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/terdis.cpp // Syntax: C++; museinfo // // Description: measurements of tertian dissonances through rules given // by John Maxwell in: // // Reference: "An Expert System for Harmonizing Analysis of Tonal // Music." pp 335-353 in: "Understanding Music with AI: // Perspectives on Music Cognition." Ed. by Mira Balaban, // Kemal Ebcioglu, and Otto Laske. MIT Press; 1992. // [ISBN 0-262-52170-9] // // Table 1: Levels of Tertian Dissonance, page 338 // // Dissonance Level Chord Quality // ============================================== // 1 consonant intervals // major triads // minor triads // 2 tritone // diminished triad // minor-minor seventh // major-minor seventh // 3 augmented fifth // augmented triad // 4 half-diminished seventh // fully-diminished sevenths // augmented-sixth sonorities // 5 verticals with major sevenths // anything else // // #include "humdrum.h" #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void generateAnalysis (HumdrumFile& infile, Array& terdis); double measureTertianDissonance (HumdrumFile& infile, int line); void printAnalysis (HumdrumFile& infile, Array& terdis); void rotateNotes (Array& notes); void usage (const char* command); // global variables Options options; // database for command-line arguments int debugQ = 0; // used with the --debug option int appendQ = 0; // used with the -a option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; Array terdis; // 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& terdis) { terdis.setSize(infile.getNumLines()); for (int i=0; i notes; if (infile[line].getType() != E_humrec_data) { return TERTIAN_UNKNOWN; } infile.getNoteList(notes, line, NL_PC | NL_FILL | NL_SORT | NL_UNIQ | NL_NORESTS); if (notes.getSize() == 0) { return TERTIAN_0; } if (notes.getSize() == 1) { return TERTIAN_0; } int i, j; int foundTertianQ = 0; int interval; for (i=0; i& notes) { if (notes.getSize() < 2) { return; } int note = notes[0]; int i; for (i=0; i& terdis) { int i; if (appendQ) { for (i=0; i