// // Programmer: Craig Stuart Sapp // Creation Date: Mon Nov 20 09:00:52 PST 2000 // Last Modified: Mon Nov 20 09:00:55 PST 2000 // Filename: ...sig/examples/all/vertdis.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/vertdis.cpp // Syntax: C++ // // Description: Implementation of rules for tertian dissonance 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] // #include "humdrum.h" #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void generateAnalysis1 (HumdrumFile& infile, Array& soncondis); int measureVerticalConsonance (HumdrumFile& infile, int line); void printAnalysis (HumdrumFile& infile, Array& soncondis); 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 soncondis; // 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& soncondis) { soncondis.setSize(infile.getNumLines()); for (int i=0; i notes; if (infile[line].getType() != E_humrec_data) { return UNDEFINED_VERTICAL; } infile.getNoteList(notes, line, NL_FILL | NL_SORT | NL_UNIQ | NL_NORESTS); // IF a sonority consists of only one note, THEN it is a consonant vertical. if (notes.getSize() <= 1) { return CONSONANT_VERTICAL; } // IF a sonority consists of two notes that form a consonant interval // other than a perfect fourth, THEN it is a consonant vertical. if (notes.getSize() == 2) { int interval = notes[1] - notes[0]; if (interval < 0) { cout << "Error on line " << line+1 << " of file: " << "problem determing interval" << endl; exit(1); } interval = interval % 40; if (interval == E_base40_per4) { return DISSONANT_VERTICAL; } else if (interval == E_base40_per1 || interval == E_base40_maj3 || interval == E_base40_min3 || interval == E_base40_min6 || interval == E_base40_maj6 || interval == E_base40_per5) { return CONSONANT_VERTICAL; } else { return DISSONANT_VERTICAL; } } // IF a sonority consists of three or more notes forming only // consonant intervals, THEN it is a consonant vertical. int i, j; int interval; for (i=0; i& soncondis) { int i; if (appendQ) { for (i=0; i