Example #1
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;
}
Example #2
0
void printLocation(HumdrumFile& infile, int line, int measure) {
   RationalNumber rat;
   int startQ = 0;
   if (fileQ) {
      if (startQ && spaceQ) { cout << ' '; } startQ++;
      if (quotesQ) {
         if (labelQ) { cout << '"'; }
      }
      cout << infile.getFilename();
      if (quotesQ) {
         if (labelQ) { cout << '"'; }
      }
   }
   if (lineQ) {
      if (startQ && spaceQ) { cout << ' '; } startQ++;
      if (labelQ) { cout << 'L'; }
      cout << line  + 1;
      if (labelQ && doubleQ) { cout << 'L'; }
   }
   if (measureQ) {
      if (startQ && spaceQ) { cout << ' '; } startQ++;
      if (labelQ) { cout << 'M'; }
      cout << measure;
      if (labelQ && doubleQ) { cout << 'M'; }
   }

   if (beatQ) {
      if (startQ && spaceQ) { cout << ' '; } startQ++;
      if (labelQ) { cout << 'B'; }
      if (rationalQ) {
         rat = infile[line].getBeatR(); 
         rat *= absFactor;
         rat.printTwoPart(cout);
      } else {
         cout << infile[line].getBeat();
      }
      if (labelQ && doubleQ) { cout << 'B'; }
   }

   if (absQ) {
      if (startQ && spaceQ) { cout << ' '; } startQ++;
      if (labelQ) { cout << absChar; }
      if (rationalQ) {
         rat = infile[line].getAbsBeatR(); 
         rat *= absFactor;
         rat.printTwoPart(cout);
      } else {
         cout << infile[line].getAbsBeat() * absFactor.getFloat();
      }
      if (labelQ && doubleQ) { cout << absChar; }
   }

}
Example #3
0
void printJsonHeader(HumdrumFile& infile, int indent, Array<int>& ktracks,
      Array<int>& partmin, Array<int>& partmax) {
   pi(cout, indent);
   cout << "{\n";

   pi(cout, indent);
   cout << "\t\"dataformat\"\t:\t\"pianoroll\",\n";

   pi(cout, indent);
   cout << "\t\"version\"\t:\t\"2.0\",\n";

   pi(cout, indent);
   cout << "\t\"creationdate\"\t:\t\"";

   int minpitch = partmin[0];
   int maxpitch = partmax[0];
   int i;
   for (i=1; i<partmin.getSize(); i++) {
      if (minpitch > partmin[i]) {
         minpitch = partmin[i];
      }
      if (maxpitch < partmax[i]) {
         maxpitch = partmax[i];
      }
   }

   struct tm *current;
   time_t now;
   time(&now);
   current = localtime(&now);
   int year = current->tm_year + 1900;
   int month = current->tm_mon + 1;
   int day = current->tm_mday;
   cout << year;
   if (month < 10) {
      cout << "0";
   } 
   cout << month;
   if (day < 10) {
      cout << "0";
   } 
   cout << day;
   cout << "\",\n";

   pi(cout, indent);
   cout << "\t\"filename\"\t:\t\"" << infile.getFilename() << "\",\n";

   pi(cout, indent);
   cout << "\t\"scorelength\"\t:\t";
   RationalNumber value = infile[infile.getNumLines()-1].getAbsBeatR();
   printRationalNumber(cout, value);
   cout << ",\n";

   pi(cout, indent);
   cout << "\t\"partcount\"\t:\t";
   cout << ktracks.getSize();
   cout << ",\n";

   pi(cout, indent);
   cout << "\t\"partnames\"\t:\t";
   printPartNames(infile);
   cout << ",\n";

   pi(cout, indent);
   cout << "\t\"minpitch\"\t:\t";
   printPitch(cout, minpitch, "");
   cout << ",\n";

   pi(cout, indent);
   cout << "\t\"maxpitch\"\t:\t";
   printPitch(cout, maxpitch, "");
   cout << ",\n";
   

   pi(cout, indent);
   cout << "\t\"rangemin\"\t:\t";
   cout << "[";
   for (i=partmin.getSize()-1; i>=0; i--) {
      if (abs(partmin[i]) >= 1000) {
         cout << "null";
      } else {
         printPitch(cout, partmin[i], "");
      }
      if (i > 0) {
         cout << ", ";
      }
   }
   cout << "],\n";

   pi(cout, indent);
   cout << "\t\"rangemax\"\t:\t";
   cout << "[";
   for (i=partmax.getSize()-1; i>=0; i--) {
      if (abs(partmax[i]) >= 1000) {
         cout << "null";
      } else {
         printPitch(cout, partmax[i], "");
      }
      if (i > 0) {
         cout << ", ";
      }
   }
   cout << "],\n";

   printBarlines(cout, infile, indent);

   pi(cout, indent);
   cout << "\t\"partdata\"\t:\n";
}