// // Programmer: Craig Stuart Sapp // Creation Date: Fri Jul 3 22:16:30 PDT 1998 // Last Modified: Sat Jul 4 11:59:48 PDT 1998 // Last Modified: Wed Oct 18 16:13:43 PDT 2000 (upgraded to musedata 1.1) // Filename: ...sig/examples/all/composite.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/composite.cpp // Syntax: C++; museinfo // // Description: Generates composite rhythm data spine from **kern input // #include "humdrum.h" #include #include #include #ifndef OLDCPP #include #include #define SSTREAM stringstream #define CSTRING str().c_str() using namespace std; #else #include #ifdef VISUAL #include /* for Windows 95 */ #else #include #endif #define SSTREAM strstream #define CSTRING str() #endif // function declarations void checkOptions(Options& opts, int argc, char* argv[]); double determineDuration(const HumdrumRecord& aRecord); int determineRest(const HumdrumRecord& aRecord); int determineTie(HumdrumRecord& aRecord); void example(void); void generateMupOutput(HumdrumFile& aFile); void modifyRecordTie(HumdrumRecord& aRecord, int state); void numberToString(double number, char* string); void processRecords(HumdrumFile& infile, HumdrumFile& outfile); void usage(const char* command); // global variables Options options; // database for command-line arguments double meterposition = 1; // position of current event in meter double scalevalue = 1; // for changing duration size (not used yet) int durinit; // for initializing duration function int restinit; // for initializing rests function int tieinit; // for initializing composite tie detector int lastTie = 0; // for determining tie start/stop string title = ""; // for MUP title /////////////////////////////////////////////////////////////////////////// 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 lastdurations; // for keeping track of durations static SigCollection runningstatus; // for keeping track current dur int i; // initialization: if (durinit) { durinit = 0; lastdurations.setSize(aRecord.getFieldCount()); runningstatus.setSize(aRecord.getFieldCount()); for (i=0; i lastnotes; // for keeping track of null record notes int output = 1; int i; if (restinit) { restinit = 0; lastnotes.setSize(aRecord.getFieldCount()); for (i=0; i currentNotes(lastnotes.getSize()); int count = 0; for (i=0; i ties; // for keeping track of notes states static SigCollection sustains; // for keeping track of note sustains static SigCollection rests; // for keeping track of notes states int i; if (tieinit) { tieinit = 0; ties.setSize(aRecord.getFieldCount()); sustains.setSize(aRecord.getFieldCount()); rests.setSize(aRecord.getFieldCount()); for (i=0; i currentTies(ties.getSize()); SigCollection currentSustains(sustains.getSize()); SigCollection currentRests(rests.getSize()); int count = 0; for (i=0; i results(ties.getSize()); int tiechange; for (i=0; i turn on a tie // state = 0 --> turn off a tie // void modifyRecordTie(HumdrumRecord& aRecord, int state) { char temp[128]; if (state) { // starting a tie strcpy(temp, "["); strcat(temp, aRecord[aRecord.getFieldCount() - 1]); } else { strcpy(temp, aRecord[aRecord.getFieldCount() - 1]); strcat(temp, "]"); } aRecord.changeField(aRecord.getFieldCount()-1, temp); } ////////////////////////////// // // processRecords -- looks at humdrum records and determines chord // quality // void processRecords(HumdrumFile& infile, HumdrumFile& outfile) { char aString[256] = {0}; double duration; int rest; int tie; int lastDataRecord = 0; HumdrumRecord currRecord; for (int i=0; i