//
// Programmer:    Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Tue Mar  5 21:32:27 PST 2002
// Last Modified: Thu Sep 25 17:47:16 PDT 2003 (minor bug fixes)
// Filename:      ...sig/examples/all/kern2esac.cpp
// Web Address:   http://sig.sapp.org/examples/museinfo/humdrum/kern2esac.cpp
// Syntax:        C++; museinfo
//
// Description:   Converts an EsAC file into Humdrum.
//

//
// ZUCCAL
// CUT[title]
// REG[region]
// KEY[code smallest_rhythm key meter]
// MEL[encoding //] >>
// FKT[social function]
// FCT[social function]
//

#include "humdrum.h"

#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <math.h>

#ifndef OLDCPP
   #include <iostream>
   #include <fstream>
   using namespace std;
#else
   #include <iostream.h>
   #include <fstream.h>
#endif

// function declarations:
void      checkOptions(Options& opts, int argc, char** argv);
void      example(void);
void      usage(const char* command);
void      convertKernToEsac(const char* filename);


// User interface variables:
Options   options;


//////////////////////////////////////////////////////////////////////////

int main(int argc, char** argv) {

   // process the command-line options
   checkOptions(options, argc, argv);
   int i;
   for (i=1; i<=options.getArgCount(); i++) {
      convertKernToEsac(options.getArg(i));
      if (i <=options.getArgCount()-1) {
         cout << endl;
      }
   }
   return 0;
}

//////////////////////////////////////////////////////////////////////////


//////////////////////////////
//
// convertKernToEsac --
//

void convertKernToEsac(const char* filename) {
   #ifndef OLDCPP
      ifstream infile(filename);
   #else
      ifstream infile(filename, ios::nocreate);
   #endif

   if (!infile.is_open()) {
      cerr << "Error: cannot open file: " << filename << endl;
      exit(1);
   }

   // int minrhy = infile.getMinTimeBase();
   int minrhy = 0;
   cout << "MINRHY = " << minrhy << endl;


}



//////////////////////////////
//
// checkOptions -- 
//

void checkOptions(Options& opts, int argc, char* argv[]) {
   opts.define("debug=b",      "print debug information"); 

   opts.define("author=b",  "author of program"); 
   opts.define("version=b", "compilation info");
   opts.define("example=b", "example usages");   
   opts.define("help=b",  "short description");
   opts.process(argc, argv);
   
   // handle basic options:
   if (opts.getBoolean("author")) {
      cout << "Written by Craig Stuart Sapp, "
           << "craig@ccrma.stanford.edu, January 2010" << endl;
      exit(0);
   } else if (opts.getBoolean("version")) {
      cout << argv[0] << ", version: 14 January 2010" << endl;
      cout << "compiled: " << __DATE__ << endl;
      cout << MUSEINFO_VERSION << endl;
      exit(0);
   } else if (opts.getBoolean("help")) {
      usage(opts.getCommand());
      exit(0);
   } else if (opts.getBoolean("example")) {
      example();
      exit(0);
   }
   
   int debugQ      = opts.getBoolean("debug");

}



//////////////////////////////
//
// example --
//

void example(void) {


}



//////////////////////////////
//
// usage --
//

void usage(const char* command) {

}



// md5sum: 98d1ce55d2ddc5ee999b64f0dba39a05 kern2esac.cpp [20100602]