Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Fix endings processing; cleanup of whitespaces and comments in tests #52

Merged
merged 6 commits into from
Jul 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/Converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,8 @@ var MEI2VF = ( function(m2v, MeiLib, VF, $, undefined) {
*/
processSections : function(xmlDoc) {
var me = this;
$(xmlDoc).find('section, ending').each(function() {
if (this.localName === 'ending') {
me.processEnding(this);
} else {
$(xmlDoc).find('section').each(function() {
me.processSection(this);
}
});
},

Expand Down Expand Up @@ -554,6 +550,9 @@ var MEI2VF = ( function(m2v, MeiLib, VF, $, undefined) {
case 'sb' :
me.setPendingSystemBreak(element);
break;
case 'ending' :
me.processEnding(element);
break;
default :
throw new m2v.RUNTIME_ERROR('MEI2VF.RERR.NotSupported', 'Element <' + element.localName + '> is not supported in <section>');
}
Expand Down Expand Up @@ -828,12 +827,15 @@ var MEI2VF = ( function(m2v, MeiLib, VF, $, undefined) {
*/
addStaffVolta : function(staff) {
var volta = this.currentVoltaType;
if (volta.start)
staff.setVoltaType(Vex.Flow.Volta.type.BEGIN, volta.start + '.', 30, 0);
if (volta.end)
staff.setVoltaType(Vex.Flow.Volta.type.END, "", 30, 0);
if (!volta.start && !volta.end)
staff.setVoltaType(Vex.Flow.Volta.type.MID, "", 30, 0);
if (volta.start) {
staff.setVoltaType(Vex.Flow.Volta.type.BEGIN, volta.start + '.', 30);
} else if (volta.end) {
//TODO: fix type.BEGIN and type.END interference in vexflow, then remove else!
//[think through in which cases we actually need type.END]
staff.setVoltaType(Vex.Flow.Volta.type.END, "", 30);
} else if (!volta.start && !volta.end) {
staff.setVoltaType(Vex.Flow.Volta.type.MID, "", 30);
}
},

/**
Expand Down
22 changes: 15 additions & 7 deletions src/Measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ var MEI2VF = ( function(m2v, MeiLib, VF, $, undefined) {
* @param {String[]} labels The labels of all staves
*/
format : function(x, labels) {
var me = this, width = me.w, i = me.staffs.length, staff;
var me = this, width = me.w, i = me.staffs.length, staff, k;
while (i--) {
if (me.staffs[i]) {
staff = me.staffs[i];
Expand All @@ -245,14 +245,22 @@ var MEI2VF = ( function(m2v, MeiLib, VF, $, undefined) {
shift_y : -3
});
}
staff.x += x;
staff.glyph_start_x += x;

if (typeof staff.setX == "function") {
staff.setX(x);
} else {
/* Fallback if VexFlow doesn't have setter */
//TODO: remove when setX() is merged to standard VexFlow
staff.x = x;
staff.glyph_start_x = x + 5;
staff.bounds.x = x;
for (k = 0; k < staff.modifiers.length; k++) {
staff.modifiers[k].x = x;
}
}

staff.start_x = staff.x + me.maxNoteStartX;
staff.bounds.x += x;
staff.setWidth(width);
staff.modifiers[0].x += x;
// staff.end_x += x + offsetW;
// staff.glyph_end_x += x + offsetW;
}
}
me.voices.format(me.getFirstDefinedStaff());
Expand Down
28 changes: 19 additions & 9 deletions tests/TC.BarLines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,35 @@
</layer>
</staff>
</measure>
<measure n="3" right="rptboth">
<ending n="1">
<measure n="3" right="rptboth">
<staff n="1">
<layer>
</layer>
</staff>
</measure>
</ending>
<ending n="2">
<measure n="4">
<staff n="1">
<layer>
</layer>
</staff>
</measure>
</ending>
<measure n="5" right="rptend">
<staff n="1">
<layer>
</layer>
</staff>
</measure>
<measure n="4" right="rptend">
<measure n="6" right="end">
<staff n="1">
<layer>
</layer>
</staff>
</measure>
<measure n="5" right="end">
<staff n="1">
<layer>
</layer>
</staff>
</measure>
<measure n="6" right="invis">
<measure n="7" right="invis">
<staff n="1">
<layer></layer>
</staff>
Expand Down
70 changes: 35 additions & 35 deletions tests/test-raphael.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@
xmlns:mo-i="http://purl.org/ontology/mo-imaginary/"
xmlns:event="http://purl.org/NET/c4dm/event.owl"
version="HTML+RDFa 1.0" xml:lang="en">
<head>
<title>MEI-to-VexFlow Test Page</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/JavaScript" src="../bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/JavaScript" src="../bower_components/raphael/raphael-min.js"></script>
<script type="text/JavaScript" src="../bower_components/vexflow/build/vexflow/vexflow-min.js"></script>
<script type="text/JavaScript" src="../dist/meitovexflow.js"></script>
<script type="text/JavaScript" src="loadXMLDoc.js"></script>
<script type="text/JavaScript" src="runtest.js"></script>
<script type="text/JavaScript">
MEI2VF.setLogging(true);
$(document).ready(function(){
var test_cases = new Array();
<head>
<title>MEI-to-VexFlow Test Page</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/JavaScript" src="../bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/JavaScript" src="../bower_components/raphael/raphael-min.js"></script>
<script type="text/JavaScript" src="../bower_components/vexflow/build/vexflow/vexflow-min.js"></script>
<script type="text/JavaScript" src="../dist/meitovexflow.js"></script>
<script type="text/JavaScript" src="loadXMLDoc.js"></script>
<script type="text/JavaScript" src="runtest.js"></script>
<script type="text/JavaScript">
MEI2VF.setLogging(true);
$(document).ready(function(){
var test_cases = new Array();

MEI2VF.RunTest(
{ title: 'Prokofiev Op. 36', mei_xml: 'TC.Prokofiev.xml', canvas_height:400},
document.getElementById('svg'), $('#test-title'),
Vex.Flow.Renderer.Backends.RAPHAEL
);

MEI2VF.RunTest(
{ title: 'Prokofiev Op. 36', mei_xml: 'TC.Dynamics.xml'},
document.getElementById('svg1'), $('#test-title'),
Vex.Flow.Renderer.Backends.RAPHAEL
);
MEI2VF.RunTest(
{ title: 'Prokofiev Op. 36', mei_xml: 'TC.Prokofiev.xml', canvas_height:400},
document.getElementById('svg'), $('#test-title'),
Vex.Flow.Renderer.Backends.RAPHAEL
);

});
</script>
</head>
<body>
<div class="test-page">
<h2><span class='test-title' property='dc:title'>Title of Test Comes Here</span></h2>
<div class='a'><svg id='svg'/></div>
<h2><span class='test-title' property='dc:title'>Title of Test Comes Here</span></h2>
<div class='a'><svg id='svg1'/></div>
</div>
</body>
MEI2VF.RunTest(
{ title: 'Prokofiev Op. 36', mei_xml: 'TC.Dynamics.xml'},
document.getElementById('svg1'), $('#test-title'),
Vex.Flow.Renderer.Backends.RAPHAEL
);

});
</script>
</head>
<body>
<div class="test-page">
<h2><span class='test-title' property='dc:title'>Title of Test Comes Here</span></h2>
<div class='a'><svg id='svg'/></div>
<h2><span class='test-title' property='dc:title'>Title of Test Comes Here</span></h2>
<div class='a'><svg id='svg1'/></div>
</div>
</body>
</html>
38 changes: 19 additions & 19 deletions tests/test_meilib.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<!DOCTYPE html>
<html
version="HTML+RDFa 1.0" xml:lang="en">
<head>
<title>MeiLib Test</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/JavaScript" src="../bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/JavaScript" src="../bower_components/vexflow/build/vexflow/vexflow-min.js"></script>
<script type="text/JavaScript" src="../dist/meitovexflow.js"></script>
<script type="text/JavaScript" src="loadXMLDoc.js"></script>
<script type="text/JavaScript" src="runtest_meilib.js"></script>
<script type="text/JavaScript">
$(document).ready( function(){
MeiLibTest();
});
</script>
</head>
<body>
<h2>MeiLib Test Page</h2>
<div id="results"/>
</body>
<head>
<title>MeiLib Test</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/JavaScript" src="../bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/JavaScript" src="../bower_components/vexflow/build/vexflow/vexflow-min.js"></script>
<script type="text/JavaScript" src="../dist/meitovexflow.js"></script>
<script type="text/JavaScript" src="loadXMLDoc.js"></script>
<script type="text/JavaScript" src="runtest_meilib.js"></script>
<script type="text/JavaScript">

$(document).ready( function(){
MeiLibTest();
});
</script>
</head>
<body>
<h2>MeiLib Test Page</h2>
<div id="results"/>
</body>
</html>
Loading