Beispiel #1
0
int main(int argc, char** argv) {
   HumdrumFile hfile;

   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   numinputs = options.getArgCount();
 
   const char* filename = "";

   for (int i=0; i<numinputs || i==0; i++) {
      hfile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         filename = "";
         hfile.read(cin);
      } else {
         filename = options.getArg(i+1).data();
         hfile.read(filename);
      }
     
      hfile.analyzeRhythm();
      displayResults(hfile, numinputs, filename);
   }

   return 0;
}
Beispiel #2
0
int main(int argc, char** argv) {
	HumdrumFile infile;

	// initial processing of the command-line options
	checkOptions(options, argc, argv);

	if (options.getArgCount() < 1) {
		infile.read(cin);
	} else {
		infile.read(options.getArg(1));
	}

	if (removeQ || overwriteQ) {
		stringstream tempstream;
		removeStems(tempstream, infile);
		infile.clear();
		infile.read(tempstream);
		if (removeQ) {
			cout << infile;
			exit(0);
		}
	} 

	autostem(infile);
	cout << infile;

	return 0;
}
Beispiel #3
0
int main(int argc, char* argv[]) {
   HumdrumFile infile;

   // 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<numinputs || i==0; i++) {
      infile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }

      infile.analyzeSpines();
      printSpineAnalysis(infile);
   }

   return 0;
}
Beispiel #4
0
int main(int argc, char** argv) {
   HumdrumFile hfile;

   checkOptions(options, argc, argv);  // process the command-line options

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   for (int i=0; i<numinputs || i==0; i++) {
      hfile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         hfile.read(cin);
      } else {
         hfile.read(options.getArg(i+1));
      }
      // hfile.analyzeRhythm();

      Array<int> transform;
      getTransformation(hfile, transform);
      if (!determineQ) {
         printTransformation(hfile, transform);
      }

   }

   return 0;
}
Beispiel #5
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   HumdrumFile hfile;
   for (int i=0; i<numinputs || i==0; i++) {
      hfile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         hfile.read(cin);
      } else {
         hfile.read(options.getArg(i+1));
      }

      hfile.analyzeRhythm();
      divisions = hfile.getMinTimeBase();
      if (divisions % 4 == 0) {
         divisions = divisions/4;
      } else {
         // don't know what this case may be
      }
      convertToMusicXML(hfile);

   }

   return 0;
}
Beispiel #6
0
int main(int argc, char** argv) {
   if (argc > 2) {
      cout << "Usage: " << argv[0] << " input-file" << endl;
      exit(1);
   }

   HumdrumFile hfile;
   if (argc == 2) {
      hfile.read(argv[1]);
   } else if (argc == 1) {
      hfile.read(cin);
   }
   
   hfile.analyzeRhythm("4", DEBUG);

   int measure = 0;

   cout << "absbeat\tdur\tbeat\tmeasure\t::\tdata\n";
   cout << ":::::::::::::::::::::::::::::::::::::::::::::::::::::\n";
   for (int i=0; i<hfile.getNumLines(); i++) {
      if (hfile[i].isMeasure()) {
         sscanf(hfile[i][0], "=%d", &measure);
      }
      cout << hfile.getAbsBeat(i) << '\t'
           << hfile.getDuration(i) << '\t'
           << measure << '\t'
           << hfile.getBeat(i) << "\t::\t"
           << hfile.getLine(i) << endl;
   }

   return 0;
}
Beispiel #7
0
int main(int argc, char* argv[]) {
   HumdrumFile infile;

   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   Array<double> values;
   values.setSize(0);

   Array<double> midibins;
   midibins.setSize(128);
   midibins.setAll(0);
   midibins.allowGrowth(0);

   for (int i=0; i<numinputs || i==0; i++) {
      infile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }

      generateAnalysis(infile, midibins);
   }

   printAnalysis(midibins);

   return 0;
}
Beispiel #8
0
int main(int argc, char* argv[]) {
   HumdrumFile    infile;
   Array<double>  timings;
   Array<double>  tempo;

   // 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<numinputs || i==0; i++) {
      infile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }

      analyzeTiming(infile, timings, tempo);
      generateSwing(infile, timings, percentage);
      printAnalysis(infile, timings, tempo);
   }

   return 0;
}
Beispiel #9
0
int main(int argc, char* argv[]) {
    HumdrumFile infile;

    // process the command-line options
    checkOptions(options, argc, argv);

    // figure out the number of input files to process
    int numinputs = options.getArgCount();

    Array<double> absbeat;
    Array<int> pitch;
    Array<int> testset;
    Array<double> duration;
    Array<double> level;
    Array<double> coef;

    for (int i=0; i<numinputs || i==0; i++) {
        infile.clear();

        // if no command-line arguments read data file from standard input
        if (numinputs < 1) {
            infile.read(cin);
        } else {
            infile.read(options.getArg(i+1));
        }
        infile.analyzeRhythm();
        cout << "(cmn\n";
        convertToCMN(infile);
        cout << ")\n";
    }

    return 0;
}
Beispiel #10
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);
   HumdrumFile infile;
   int i;

   Array<Array<char> > idtags;
   int idtagQ = 0;
   firstinput.read(options.getArg(1));

   for (i=1; i<=options.getArgCount(); i++) {
      infile.clear();
      infile.read(options.getArg(i));
      if (i ==1) {
         idtagQ = getIdTags(idtags, infile);
      }

      if (idtagQ && i > 1) {
         printFileID(infile, i-1, options.getArgCount(), idtags);
      } else {
         printFile(infile, i-1, options.getArgCount());
      }
   }

   return 0;
}
Beispiel #11
0
int main(int argc, char* argv[]) {
   checkOptions(options, argc, argv);

   Array<PixelRow> picturedata;
   Array<PixelRow> background;
   HumdrumFile infile;

   int numinputs = options.getArgCount();
   if (numinputs > 0) {
      const char* filenameIn  = options.getArg(1).data();
      infile.read(filenameIn);
   } else {
      infile.read(cin);
   }

   if (infile.getFilename().size() == 0) {
      infile.setFilename(optionfilename);
   }

   if (jsonQ) {
      createJsonProll(infile);
   } else {
      int rfactor = generatePicture(infile, picturedata, style);
      generateBackground(infile, rfactor, picturedata, background);
      printPicture(picturedata, background, rfactor, cfactor, 
            gminpitch, gmaxpitch, infile);
   }

   return 0;
}
Beispiel #12
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);
   HumdrumFile infile;
   Array<Array<char> > templatedata;
   Array<Array<char> > sourcedata;
   Array<int> datalines;

   if ((options.getArgCount() < 1) || (options.getArgCount() > 2)) {
      usage(options.getCommand().data());
      exit(1);
   }

   int sourcearg   = 1;
   int templatearg = 2;
   if (reverseQ) {
      sourcearg   = 2;
      templatearg = 1;
   }
   
   if (options.getArgCount() == 2) {
      infile.read(options.getArg(sourcearg));
      readTemplateContents(templatedata, options.getArg(templatearg).data());

   } else {
      // read second file from standard input
      if (sourcearg == 1) {
         infile.read(options.getArg(1));
	 readTemplateContents(templatedata, cin);
      } else {
         infile.read(cin);
	 readTemplateContents(templatedata, options.getArg(1).data());
      }
   }

   int spine = chooseSpine(interp, infile);

   fillSourceData(sourcedata, datalines, infile, spine, nullQ);

   if (debugQ) {
      cout << "SOURCE DATA: " << endl;
      printTemplate(sourcedata);
      cout << "TEMPLATE DATA: " << endl;
      printTemplate(templatedata);
   }
        

   doDamerauLevenshteinAnalysis(sourcedata, templatedata);

   if (pweightQ) {
      printWeights();
   }

   return 0;
}
Beispiel #13
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);

   HumdrumFile infile;
   infile.read(options.getArg(1));
   if (distQ) {
      infile.analyzeRhythm();
   }
   Array<NoteUnit> notes;
   getNotes(notes, infile);
   scrambleNotes(notes);
   if (transQ) {
      printNotes(notes);
   } else {
      replaceNotes(infile, notes);
      cout << infile;
   }

   if (displaySeedQ) {
      cout << "!!!seed: " << seed << endl;
   }

   return 0;
}
Beispiel #14
0
int main(int argc, char* argv[]) {
   #ifndef VISUAL
      srand48(time(NULL)*12345);   // seed rand num generator with current time
   #else
      srand(time(NULL)*12345);
   #endif

   HumdrumFile infile;

   // process the command-line options
   checkOptions(options, argc, argv);

   string filename;
   // if no command-line arguments read data file from standard input
   int numinputs = options.getArgCount();
   if (numinputs < 1) {
      cout << "Error: you must supply at least one input fileme" << endl;
      exit(1);
   } else {
      filename = options.getArg(1);
      infile.read(options.getArg(1));
   }
   processFile(filename, infile);

}
Beispiel #15
0
void fillIstnDatabase(Array<ISTN>& istndatabase, const char* istnfile) {
   HumdrumFile infile;
   infile.read(istnfile);
   int i, j;
   ISTN entry;
   istndatabase.setSize(infile.getNumLines());
   istndatabase.setSize(0);
   for (i=0; i<infile.getNumLines(); i++) {
      if (infile[i].getType() != E_humrec_data) {
         continue;
      }
      entry.clear();
      for (j=0; j<infile[i].getFieldCount(); j++) {
         if (strcmp(infile[i].getExInterp(j), "**theme") == 0) {
            entry.setFilename(infile[i][j]);
         } else if (strcmp(infile[i].getExInterp(j), "**istn") == 0) {
            entry.setIstn(infile[i][j]);
         }
      }
      if (entry.is_valid()) {
         istndatabase.append(entry);
      }
   }

   istndatabase.allowGrowth(0);
}
Beispiel #16
0
void readWeights(const char* filename) {

   int i;
   int j;
   int key;
   double value;

   HumdrumFile wfile;
   wfile.read(filename);
   for (i=0; i<wfile.getNumLines(); i++) {
      if (wfile[i].getType() != E_humrec_data) {
         continue;
      }
      key = -1;
      value = -1000000.0;
      for (j=0; j<wfile[i].getFieldCount(); j++) {
         if (strcmp(wfile[i].getExInterp(j), "**kern") == 0) {
            key = Convert::kernToMidiNoteNumber(wfile[i][j]) % 12;
            if (std::islower(wfile[i][j][0])) {
               key += 12;
            }
         } else if (strcmp(wfile[i].getExInterp(j), "**weight") == 0) {
            sscanf(wfile[i][j], "%lf", &value);
         }
      }
      if ((key >= 0) && (key < 24) && (value != -1000000.0)) {
         if (key < 12) {
            majorKeyUser[key] = value;
         } else {
            minorKeyUser[key-12] = value;
         }
      }
   }
}
Beispiel #17
0
int main(int argc, char** argv) {
   HumdrumFile infile;

   // initial processing of the command-line options
   checkOptions(options, argc, argv);

   if (options.getArgCount() < 1) {
      infile.read(cin);
   } else {
      infile.read(options.getArg(1));
   }

   convertHumdrumToEnp(cout, infile);

   return 0;
}
Beispiel #18
0
int main(int argc, char** argv) {
   if (argc != 2) {
      return 1;
   }
   HumdrumFile infile;
   if (!infile.read(argv[1])) {
      return 1;
   }
   int tpq = infile.tpq();
   cout << "TPQ: " << tpq << endl;
   cout << "PITCH\tTRACK\tSTART\tDURATION" << endl;

   for (int i=0; i<infile.getLineCount(); i++) {
      if (!infile[i].isData()) {
         continue;
      }
      for (int j=0; j<infile[i].getTokenCount(); j++) {
         if (infile.token(i, j).isNull()) {
            continue;
         }
         if (infile.token(i, j).isDataType("kern")) {
            printNoteInformation(infile, i, j, tpq);
         }
      }
   }
   return 0;
}
Beispiel #19
0
void printExclusiveInterpLine(int linenum, HumdrumFile& infile) {
	int dataline = -1;
	int i;
	for (i=0; i<data.getNumLines(); i++) {
		if (infile[i].hasSpines()) {
			dataline = i;
			break;
		}
	}
	if (dataline < 0) {
		return;
	}

	stringstream tempstream;
	for (i=0; i<infile[dataline].getFieldCount(); i++) {
		tempstream << infile[dataline].getExInterp(i);
		if (i < infile[dataline].getFieldCount()-1) {
			tempstream << "\t";
		}
	}
	tempstream << "\n";
	for (i=0; i<infile[dataline].getFieldCount(); i++) {
		tempstream << "*-";
		if (i < infile[dataline].getFieldCount()-1) {
			tempstream << "\t";
		}
	}
	tempstream << ends;

	HumdrumFile dummyfile;
	dummyfile.read(tempstream);
	printInputLine(dummyfile, 0);
}
int main(int argc, char** argv) {
   if (argc != 2) {
      return 1;
   }
   HumdrumFile infile;
   if (!infile.read(argv[1])) {
      return 1;
   }
   // print line parameters:
   cout << "Global parameters in file:" << endl;
   for (int i=0; i<infile.getLineCount(); i++) {
      if (infile[i].hasParameters()) {
         cout << (HumHash)infile[i];
      }
   }

   cout << "Local parameters in file:" << endl;
   for (int i=0; i<infile.getLineCount(); i++) {
      for (int j=0; j<infile[i].getTokenCount(); j++) {
         if (infile[i].token(j).hasParameters()) {
            cout << (HumHash)infile[i].token(j);
         }
      }
   }

   return 0;
}
int main(int argc, char** argv) {
    HumdrumFile hfile;
    if (argc > 1) {
        hfile.read(argv[1]);
    }
    else {
        hfile.read(cin);
    }
    for (int i=0; i<hfile.getNumLines(); i++) {
        std::cout << "\t" << hfile[i][0];
        for (int j=1; j<hfile[i].getFieldCount(); j++) {
            cout << "\t" << hfile[i][j] << endl;
        }
        std::cout << std::endl;
    }
    return 0;
}
Beispiel #22
0
int main(int argc, char* argv[]) {
   HumdrumFile infile;

   // process the command-line options
   checkOptions(options, argc, argv);

   const char* filename;
   infile.clear();
   // if no command-line arguments read data file from standard input
   int numinputs = options.getArgCount();
   if (numinputs < 1) {
      infile.read(cin);
   } else {
      filename = options.getArg(1).data();
      infile.read(filename);
   }
   processFile(infile);

}
Beispiel #23
0
int main(int argc, char* argv[]) {
   HumdrumFile    infile;
   Array<double>  timings;
   Array<double>  tempo;

   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   double totaldur = 0.0;

   for (int i=0; i<numinputs || i==0; i++) {
      infile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }

      if (interpQ) {
         doLinearInterpolation(infile);
      } else {
         analyzeTiming(infile, timings, tempo);
         if (totalQ) {
            totaldur += timings[timings.getSize()-1];
            if (numinputs > 1) {
               printtime(options.getArg(i+1), timings[timings.getSize()-1]);
            }
         } else {
            printAnalysis(infile, timings, tempo);
         }
      }
   }
   if (totalQ) {
      printtime("", totaldur);
   }

   return 0;
}
Beispiel #24
0
int main(int argc, char** argv) {
   if (argc != 2) {
      return 1;
   }
   HumdrumFile infile;
   if (!infile.read(argv[1])) {
      return 1;
   }
   infile.printCsv();
   return 0;
}
Beispiel #25
0
int main(int argc, char* argv[]) {
	HumdrumFile infile;

	// process the command-line options
	checkOptions(options, argc, argv);

	infile.clear();
	// if no command-line arguments read data file from standard input
	int numinputs = options.getArgCount();
	if (numinputs < 1) {
		infile.read(cin);
	} else {
		filename = options.getArg(1);
		infile.read(options.getArg(1));
	}
	int i;
	for (i=0; i<infile.getMaxTracks(); i++) {
		processFile(infile, i);
	}

	cout << infile;
}
Beispiel #26
0
void processArgument(const char* path) {
   HumdrumFile hfile;
   DIR* dir = NULL;
   char* fullname;
   struct dirent* entry;
   int namelen = 0;
   int valid = 0;

   if (is_file(path)) {
      namelen = strlen(path);
      valid = 0;
      if (strcmp(&(path[namelen-4]), ".thm") == 0) {
         valid = 1;
      } else if (strcmp(&(path[namelen-4]), ".krn") == 0) {
         valid = 1;
      } else if (strcmp(&(path[namelen-4]), ".THM") == 0) {
         valid = 1;
      } else if (strcmp(&(path[namelen-4]), ".KRN") == 0) {
         valid = 1;
      }
      if (!valid) {
         return;
      }
      hfile.read(path);
      createIndex(hfile, path);
   } else if (is_directory(path)) {
      dir = opendir(path);
      if (dir == NULL) {
         return;
      }
      entry = readdir(dir);
      while (entry != NULL) {
         if (strncmp(entry->d_name, ".", 1) == 0) {
            entry = readdir(dir);
            continue;
         }

         fullname = new char[strlen(path) + 1 + strlen(entry->d_name) + 1];
         strcpy(fullname, path);
         strcat(fullname, "/");
         strcat(fullname, entry->d_name);
         processArgument(fullname);
         entry = readdir(dir);
      }
   }

   if (dir != NULL) {
      closedir(dir);
   }
}
Beispiel #27
0
int main(int argc, char** argv) {
   if (argc != 2) {
      return 1;
   }
   HumdrumFile infile;
   if (!infile.read(argv[1])) {
      return 1;
   }
   infile.analyzeKernSlurs();

   infile.printXml();
   return 0;
   
}
Beispiel #28
0
int main(int argc, char* argv[]) {
   checkOptions(options, argc, argv);
   HumdrumFile infile;
   infile.read(options.getArg(1));
   MidiFile midifile;
   createMidiFile(midifile, infile);

   if (strcmp(filename, "") == 0) {
      cout << midifile;
   } else {
      midifile.write(filename);
   }

   return 0;
}
Beispiel #29
0
void processFile(HumdrumFile& infile, int index) {
	vector<int> lines;
	vector<int> pitches;
	vector<int> tiestates;
	vector<int> tiecorrections;
	vector<int> localindex;

	for (int i=0; i<infile.getNumLines(); i++) {
		if (infile[i].getType() == E_humrec_interpretation) {
			if (strcmp(infile[i].getExInterp(index), "**kern") != 0) {
				// spine is not **kern data, so no tie fixing necessary
				return;
			} else {
				// primary spine is **kern data
				break;
			}
		}
	}

// cout << "Spine is not kern data: " << infile[i].getExInterp(index) << endl;
// cout << "LINE IS: " << infile[i] << endl;
// cout << "INDEX = " << index << endl;
// cout << "LINE = " << i << endl;
// cout << "SPINE INFO = " << infile[i].getSpineInfo(index) << endl;

	getPitchesAndTies(infile, lines, pitches, tiestates, index, localindex);
	int corr = getTieCorrections(tiecorrections, pitches, tiestates);

	if (testQ) {
		if (corr) {
			cout << filename << ": " << corr << " incorrect ties\n";
			exit(0);
		} else {
			exit(0);
		}
	}

	if (corr) {
		stringstream datastream;
		printFileWithCorrections(datastream, infile, lines,
				tiecorrections, localindex);
		datastream << ends;
		infile.clear();
		infile.read(datastream);
	} else {
		// no corrections needed: do not alter infile
	}
}
Beispiel #30
0
int main(int argc, char** argv) {
   if (argc != 2) {
      return 1;
   }
   HumdrumFile infile;
   if (!infile.read(argv[1])) {
      return 1;
   }
   for (int i=0; i<infile.size(); i++) {
      cout << infile[i].getDurationFromBarline() << "\t";
      cout << infile[i].getDurationToBarline() << "\t";
      cout << infile[i].getBeat() << "\t";
      cout << infile[i].getBeat().getFloat() << "\t";
      cout << infile[i] << endl;
   }
   return 0;
}