Exemple #1
0
//_______________________________________________________________________________
int main(int argc, char *argv[]) {
#if debug
	char *path = "rm.xml";
	argc = 2;
#else
	char *path = argv[1];
#endif
	if (argc > 1) {
		xmlreader r;
		SXMLFile file = r.read(path);
		if (file) {
			Sxmlelement st = file->elements();
			if (st) {
				test1(st);
				count(st, k_measure);
				count(st, k_note);

				test2(st);
				count(st, k_measure);
				count(st, k_note);

				test3(st);
				count(st, k_measure);
				count(st, k_note);

				file->print (cout);
				cout << endl;		
			}
		}
	}
	return 0;
}
Exemple #2
0
int main (int argc, char * argv[]) {
	// if present, reads the measures count from the command line
	int count = (argc == 2) ? atoi(argv[1]) : 20;
	// sets the random numbers seed
#ifdef WIN32
	srand((unsigned)time(0));
#else
	srandom((unsigned)time(0));
#endif
	SXMLFile f = TXMLFile::create();
	f->set( new TXMLDecl("1.0", "", TXMLDecl::kNo));
	f->set( new TDocType("score-partwise"));
	f->set( randomMusic(count) );
	f->print(cout);
	cout << endl;
    return 0;
}
//_______________________________________________________________________________
int main(int argc, char *argv[]) {
  char *file = argv[1];
  xmlreader r;
  SXMLFile xmlfile;
  if ((argc > 1) && strcmp(file, "-"))
    xmlfile = r.read(file);
  else
    xmlfile = r.read(stdin);
  if (xmlfile) {
    Sxmlelement st = xmlfile->elements();
    if (st) {
      mychuckwriter writer;
      midicontextvisitor v(480, &writer);
      unrolled_xml_tree_browser browser(&v);
      browser.browse(*st);
    }
  }
  return 0;
}
Exemple #4
0
int CsoundFile::importFile(std::string filename)
{
  struct stat statbuffer;
  int returnValue = stat(filename.c_str(), &statbuffer);
  if(returnValue)
    {
      return false;
    }
  std::ifstream stream(filename.c_str(), std::ios::binary);
  if((filename.find(".orc")    != filename.npos) ||
     (filename.find(".ORC")    != filename.npos))
    {
      returnValue += importOrchestra(stream);
    }
  else if((filename.find(".sco") != filename.npos) ||
          (filename.find(".SCO") != filename.npos))
    {
      returnValue += importScore(stream);
    }
  else if((filename.find(".mid") != filename.npos) ||
          (filename.find(".MID") != filename.npos))
    {
      returnValue += importMidifile(stream);
    }
#if defined(HAVE_MUSICXML2)
  else if((filename.find(".xml") != filename.npos) ||
          (filename.find(".XML") != filename.npos))
    {
      score.erase();
      xmlreader xmlReader;
      Sxmlelement sxmlElement;
      // Try to read an SXMLFile out of the MusicXML file.
      SXMLFile sxmlFile = xmlReader.read(filename.c_str());
      if (sxmlFile) {
        // Get the document tree of XML elements from the SXMLFile.
        sxmlElement = sxmlFile->elements();
      }
      if (sxmlElement) {
        // Create a CsoundFileMidiWriter that is attached to this Score.
        CsoundFileMidiWriter csoundFileMidiWriter(this);
        // Create a midicontextvisitor, which calls into an abstract
        // midiwriter interface, which is attached to our
        // CsoundFileMidiWriter, which implements that midiwriter
        // interface.
        midicontextvisitor midicontextvisitor_(csoundFileMidiWriter.tpq,
                                               &csoundFileMidiWriter);
        // Create an xml_tree_browser that is attached to our midicontextvisitor.
        xml_tree_browser xmlTreeBrowser(&midicontextvisitor_);
        // The xml_tree_browser will carry the midicontextvisitor to
        // all the elements of the document tree, in the proper order,
        // calling newNote as appropriate.
        xmlTreeBrowser.browse(*sxmlElement);
      }
    }
#endif
  else
    {
      returnValue += importFile(stream);
    }
  stream.close();
  return returnValue;
}