You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
ifkarp edited this page May 14, 2015
·
2 revisions
Some code examples to illustrate how to use the Libmei in C++:
Reading in an MEI XML file
#include<mei/xmlimport.h>
mei::XMLImportResult res = mei::documentFromFile("beethoven.mei", mei::MEI_STRICT_IMPORT);
mei::MeiDocument *doc = res.getMeiDocument();
Writing out an XML file
#include<mei/mei.h>
#include<mei/shared.h>
#include<mei/cmn.h>
#include<mei/xmlexport.h>//create a very basic document structure
mei::MeiDocument *doc = new mei::MeiDocument();
mei::MeiElement *m1 = new mei::MeiElement("mei");
doc->setRootElement(m1);
//create a new note with an attribute
mei::MeiAttribute *att = new mei::MeiAttribute("accid", "s");
mei::Note *n = new mei::Note();
n->addAttribute(att);
m1->addChild(n);
//This will return True if it was successfulint status = mei::documentToFile(doc, "outputfile.mei")
You can also look at the C++ unit tests code for more examples.