Ejemplo n.º 1
0
//------------------------------------------------------------------------
// 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;
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------
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;
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------
// 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;
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------
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);
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------
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;
}
Ejemplo n.º 6
0
//------------------------------------------------------------------------
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;
}
Ejemplo n.º 7
0
//------------------------------------------------------------------------
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);	
}
Ejemplo n.º 8
0
//------------------------------------------------------------------------
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);
}
Ejemplo n.º 9
0
//------------------------------------------------------------------------
// 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;
}
Ejemplo n.º 10
0
//------------------------------------------------------------------------
// 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;
}
Ejemplo n.º 11
0
//------------------------------------------------------------------------
void musicxmlfactory::rights (const char* c, const char* type)
{
	Sxmlelement rights = element(k_rights, c);
	if (type) rights->add (attribute("type", type));
	fIdentification->push (rights);
}
Ejemplo n.º 12
0
//------------------------------------------------------------------------
void musicxmlfactory::creator (const char* c, const char* type)
{
	Sxmlelement creator = element(k_creator, c);
	if (type) creator->add (attribute("type", type));
	fIdentification->push (creator);
}
Ejemplo n.º 13
0
//------------------------------------------------------------------------
Sxmlelement	musicxmlfactory::part (const char* id)
{
	Sxmlelement part = element(k_part);
	part->add (attribute("id", id));
	return part;
}
Ejemplo n.º 14
0
//------------------------------------------------------------------------
Sxmlelement musicxmlfactory::newmeasure(int number) const
{
	Sxmlelement measure = element (k_measure);
	measure->add (attribute ("number", number));
	return measure;
}