コード例 #1
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
Sxmlelement musicxmlfactory::newrest (int duration, const char* type)
{
	Sxmlelement elt = element(k_note);
	if (duration) elt->push(element(k_duration, duration));
	if (type) elt->push(element(k_type, type));
	return elt;
}
コード例 #2
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
Sxmlelement	musicxmlfactory::scorepart (const char* id, const char* name, const char* abbrev)
{
	Sxmlelement part = element(k_score_part);
	part->add (attribute("id", id));
	if (name)			part->push (element(k_part_name, name));
	if (abbrev)			part->push (element(k_part_abbreviation, abbrev));
	return part;
}
コード例 #3
0
ファイル: RandomMusic.cpp プロジェクト: 02191998/libmusicxml
//------------------------------------------------------------------------
// the function that creates and writes the score
//------------------------------------------------------------------------
static Sxmlelement randomMusic(int measuresCount) {
	Sxmlelement score = factory::instance().create(k_score_partwise);
	score->push (newElement(k_movement_title, "Random Music"));
	score->push (makeIdentification());
	score->push (makePartList());
	score->push(makePart(measuresCount));			// adds a part to the score
	return score;
}
コード例 #4
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
Sxmlelement musicxmlfactory::newmeasure (int number, const char* time, const char* clef, int line, int key, int division) const
{
	Sxmlelement m = newmeasure (number);
	Sxmlelement attributes = getAttributes (m);
	if (division) attributes->push (element(k_divisions, division));
	if (time) {
		int beat, beatType;
		int n = sscanf (time, "%d/%d", &beat, &beatType);
		if (n == 2) {
			Sxmlelement t = element (k_time);
			t->push (element(k_beats, beat));
			t->push (element(k_beat_type, beatType));
			attributes->push (t);
		}
	}
	if (clef) {
		Sxmlelement c = element (k_clef);
		c->push (element (k_sign, clef));
		if (line) c->push (element (k_line, line));
		attributes->push (c);
	}
	if (key) {
		Sxmlelement k = element (k_key);
		k->push (element (k_fifths, key));
		attributes->push (k);
	}
	return m;
}
コード例 #5
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::encoding(const char* software)
{
	Sxmlelement encoding = element (k_encoding);
	if (software) encoding->push (element(k_software, software));

	string lib = "MusicXML Library version ";
	lib += musicxmllibVersionStr();
	encoding->push (element(k_software, lib.c_str()));
	encoding->push (element (k_encoding_date, timestring()));
	fIdentification->push (encoding);
}
コード例 #6
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::header (const char* worknumber, const char* worktitle, const char* movementnumber, const char* movementtitle)
{
	if (worknumber || worktitle) {
		Sxmlelement work = element(k_work);
		if (worknumber) work->push (element(k_work_number, worknumber));
		if (worktitle) work->push (element(k_work_title, worktitle));
		fRoot->push (work);
	}
	if (movementnumber) fRoot->push (element(k_movement_number, movementnumber));
	if (movementtitle) fRoot->push (element(k_movement_title, movementtitle));
}
コード例 #7
0
ファイル: RandomMusic.cpp プロジェクト: 02191998/libmusicxml
//------------------------------------------------------------------------
// creates the identification element
//------------------------------------------------------------------------
static Sxmlelement makeIdentification() {
	Sxmlelement id = factory::instance().create(k_identification);
	Sxmlelement encoding = factory::instance().create(k_encoding);

	Sxmlelement creator = newElement(k_creator, "Georg Chance");
	creator->add(newAttribute("type", "Composer"));
	id->push (creator);
	
	encoding->push (newElement(k_software, "MusicXML Library v2"));
	id->push (encoding);
	return id;
}
コード例 #8
0
ファイル: RandomMusic.cpp プロジェクト: 02191998/libmusicxml
//------------------------------------------------------------------------
// creates the part list element
//------------------------------------------------------------------------
static Sxmlelement makePartList() {
	Sxmlelement partlist = factory::instance().create(k_part_list);
	Sxmlelement scorepart = factory::instance().create(k_score_part);
	scorepart->add (newAttribute("id", kPartID));
	scorepart->push (newElement(k_part_name, "Part name"));
	Sxmlelement scoreinstr = factory::instance().create(k_score_instrument);
	scoreinstr->add (newAttribute("id", "I1"));
	scoreinstr->push (newElement(k_instrument_name, "Any instr."));
	scorepart->push (scoreinstr);
	partlist->push(scorepart);
	return partlist;
}
コード例 #9
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
Sxmlelement musicxmlfactory::newbarline (const char* location, const char* barstyle, const char *repeat)
{
	Sxmlelement barline = element (k_barline);
	if (location)
		barline->add (attribute( "location", location));
	if (barstyle)
		barline->push (element(k_bar_style, barstyle));
	if (repeat) {
		Sxmlelement repeatelt = (element(k_repeat));
		repeatelt->add (attribute( "direction", repeat));
		barline->push (repeatelt);
	}
	return barline;
}
コード例 #10
0
ファイル: RandomMusic.cpp プロジェクト: 02191998/libmusicxml
//------------------------------------------------------------------------
// creates a part containing 'count' measures
//------------------------------------------------------------------------
Sxmlelement makePart(int count) {
	Sxmlelement part = factory::instance().create(k_part);
	part->add (newAttribute("id", kPartID));
	for (int i=1; i<=count; i++)			// and 'count' times
		part->push (makemeasure(i));			// adds a new measure to the part
	return part;
}
コード例 #11
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::tie (Sxmlelement start, Sxmlelement stop)
{
	Sxmlelement tieStart = element (k_tie);
	tieStart->add (attribute ("type", "start"));
	start->push (tieStart);
	Sxmlelement tiedStart = element (k_tied);
	tiedStart->add (attribute ("type", "start"));
	addnotation (start, tiedStart);
	
	Sxmlelement tieStop = element (k_tie);
	tieStop->add (attribute ("type", "stop"));
	stop->push (tieStop);
	Sxmlelement tiedStop = element (k_tied);
	tiedStop->add (attribute ("type", "stop"));
	addnotation (stop, tiedStop);
}
コード例 #12
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
Sxmlelement musicxmlfactory::newdynamics (int type, const char* placement)
{
	Sxmlelement dynamics = element (k_dynamics);
	if (placement)
		dynamics->add (attribute( "placement", placement));
	dynamics->push (element(type));
	return dynamics;
}
コード例 #13
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::maketuplet(int actual, int normal, const std::vector<Sxmlelement>& notes)
{
	if (notes.empty()) return;
	Sxmlelement timemod = element(k_time_modification);
	timemod->push (element (k_actual_notes, actual));
	timemod->push (element (k_normal_notes, normal));
	for (unsigned int i=0; i < notes.size(); i++)
		notes[i]->push(timemod);
	Sxmlelement notations = getNotations (notes[0]);
	Sxmlelement tuplet = element (k_tuplet);
	tuplet->add (attribute ("type", "start"));
	notations->push (tuplet);

	notations = getNotations (notes[notes.size()-1]);
	tuplet = element (k_tuplet);
	tuplet->add (attribute ("type", "stop"));
	notations->push (tuplet);
}
コード例 #14
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::addgroup (int number, const char* name, const char* abbrev, bool groupbarline, vector<Sxmlelement>& parts)
{
	Sxmlelement groupStart = element(k_part_group);
	groupStart->add (attribute ("number", number));
	groupStart->add (attribute ("type", "start"));
	if (name)			groupStart->push (element(k_group_name, name));
	if (abbrev)			groupStart->push (element(k_group_abbreviation, abbrev));
	if (groupbarline)	groupStart->push (element(k_group_barline, "yes"));
	fPartList->push (groupStart);

	for (vector<Sxmlelement>::const_iterator i = parts.begin(); i != parts.end(); i++)
		addpart(*i);

	Sxmlelement groupStop = element(k_part_group);
	groupStop->add (attribute ("number", number));
	groupStop->add (attribute ("type", "stop"));
	fPartList->push (groupStop);	
}
コード例 #15
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
Sxmlelement	musicxmlfactory::getSubElement (Sxmlelement elt, int type) const
{
	vector<Sxmlelement>&  subelts = elt->elements();
	for (unsigned int i=0; i < subelts.size(); i++) {
		if (subelts[i]->getType() == type)
			return subelts[i];
	}
	Sxmlelement sub = element(type);
	elt->push (sub);
	return sub;
}
コード例 #16
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
Sxmlelement musicxmlfactory::newnote (const char* step, float alter, int octave, int duration, const char* type)
{
	Sxmlelement elt = element(k_note);
	Sxmlelement pitch = element(k_pitch);
	pitch->push (element (k_step, step));
	if (alter) pitch->push (element (k_alter, alter));
	pitch->push (element (k_octave, octave));
	elt->push(pitch);
	if (duration) elt->push(element(k_duration, duration));
	if (type) elt->push(element(k_type, type));
	return elt;
}
コード例 #17
0
ファイル: RandomMusic.cpp プロジェクト: 02191998/libmusicxml
//------------------------------------------------------------------------
// creates a measure containing random notes
// the function takes the measure number as an argument
//------------------------------------------------------------------------
static Sxmlelement makemeasure(unsigned long num) {
	Sxmlelement measure = factory::instance().create(k_measure);
	measure->add (newAttributeI("number", num));
	if (num==1) {					//  creates specific elements of the first measure
		measure->push(makeAttributes());		// division, time, clef...
	}
	for (int i = 0; i < 4; i++) {		// next adds 4 quarter notes
		Sxmlelement note = factory::instance().create(k_note);		// creates the note
		Sxmlelement pitch = factory::instance().create(k_pitch);	// creates a pitch
		pitch->push (newElement(k_step, randomNote()));				// sets the pitch to a random value
		pitch->push (newElementI(k_octave, 4 + getrandom(2)));		// sets the octave to a random value
		note->push (pitch);											// adds the pitch to the note
		note->push (newElementI(k_duration, kDivision));				// sets the note duration to a quarter note
		note->push (newElement(k_type, "quarter"));					// creates the graphic elements of the note
		measure->push (note);		// and finally adds the note to the measure
	}
	return measure;
}
コード例 #18
0
ファイル: RandomMusic.cpp プロジェクト: 02191998/libmusicxml
//------------------------------------------------------------------------
static Sxmlelement makeAttributes() {
	Sxmlelement attributes = factory::instance().create(k_attributes);
	attributes->push (newElementI(k_divisions, kDivision));

	Sxmlelement time = factory::instance().create(k_time);
	time->push (newElement(k_beats, "4"));
	time->push (newElement(k_beat_type, "4"));
	attributes->push (time);

	Sxmlelement clef = factory::instance().create(k_clef);
	clef->push (newElement(k_sign, "G"));
	clef->push (newElement(k_line, "2"));
	attributes->push (clef);
	
	return attributes;
}
コード例 #19
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::addnotation (Sxmlelement elt, Sxmlelement notation)
{
	Sxmlelement notations = getNotations (elt);
	notations->push (notation);
}
コード例 #20
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::add (Sxmlelement elt, const std::vector<Sxmlelement>& subelts) const
{
	for (unsigned int i=0; i < subelts.size(); i++) 
		elt->push( subelts[i]);
}
コード例 #21
0
ファイル: musicxmlfactory.cpp プロジェクト: k4rm/AscoGraph
//------------------------------------------------------------------------
void musicxmlfactory::addarticulation (Sxmlelement elt, Sxmlelement articulation)
{
	Sxmlelement articulations = getArticulations (elt);
	articulations->push (articulation);
}