From b43ce26f731888ea5b4f98676d0c7246ad841c05 Mon Sep 17 00:00:00 2001 From: zolaemil Date: Tue, 24 Jun 2014 18:20:48 +0100 Subject: [PATCH 1/5] enabled all test cases --- tests/tests.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/tests.html b/tests/tests.html index 86c52e8..0b88e6c 100644 --- a/tests/tests.html +++ b/tests/tests.html @@ -178,16 +178,16 @@ test_cases.push({ title: "Clef - Alto clef (with stem directions)", mei_xml: 'TC.VexClef.07.xml'}); test_cases.push({ title: "Clef - Transposed treble clef (with stem directions)", mei_xml: 'TC.VexClef.06.xml'}); test_cases.push({ title: "Plain Staff", mei_xml: 'TC.PlainStaff.xml'}); - // test_cases.push({ title: "Bar lines", mei_xml: 'TC.BarLines.xml'}); - // test_cases.push({ - // title: "Page Layout, measure widths in the MEI code", - // mei_xml: 'TC.PageLayout.xml', - // canvas_width: 1600, - // canvas_height:2700, - // options: { - // labelMode: 'full' - // } - // }); + test_cases.push({ title: "Bar lines", mei_xml: 'TC.BarLines.xml'}); + test_cases.push({ + title: "Page Layout, measure widths in the MEI code", + mei_xml: 'TC.PageLayout.xml', + canvas_width: 1600, + canvas_height:2700, + options: { + labelMode: 'full' + } + }); test_cases.push({ title: "Page Layout, automatic measure width calculation", mei_xml: 'TC.PageLayoutAutoWidths.xml', From 4d911ece9ab264272964b051ceaaf94fe7727591 Mon Sep 17 00:00:00 2001 From: zolaemil Date: Tue, 24 Jun 2014 18:30:58 +0100 Subject: [PATCH 2/5] ending test --- tests/TC.BarLines.xml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/TC.BarLines.xml b/tests/TC.BarLines.xml index 4deba6e..7ac4407 100644 --- a/tests/TC.BarLines.xml +++ b/tests/TC.BarLines.xml @@ -38,25 +38,35 @@ - + + + + + + + + + + + + + + + + + - + - - - - - - - + From 880bd7db2744a19dff9d569ae9e0710a83743b1e Mon Sep 17 00:00:00 2001 From: zolaemil Date: Wed, 25 Jun 2014 17:00:38 +0100 Subject: [PATCH 3/5] tidy up comments in tests.html; reindented .html files with soft tabs --- tests/test-raphael.html | 70 +++--- tests/test_meilib.html | 38 ++-- tests/tests.html | 475 +++++++++++++++++++++------------------- tests/unitTest.html | 31 ++- 4 files changed, 313 insertions(+), 301 deletions(-) diff --git a/tests/test-raphael.html b/tests/test-raphael.html index 4a2b5c2..102407e 100644 --- a/tests/test-raphael.html +++ b/tests/test-raphael.html @@ -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"> - - MEI-to-VexFlow Test Page - - - - - - - - + + + + + + - - -
-

Title of Test Comes Here

-
-

Title of Test Comes Here

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

Title of Test Comes Here

+
+

Title of Test Comes Here

+
+
+ diff --git a/tests/test_meilib.html b/tests/test_meilib.html index 40fc36f..0c31152 100644 --- a/tests/test_meilib.html +++ b/tests/test_meilib.html @@ -1,23 +1,23 @@ - - MeiLib Test - - - - - - - - - -

MeiLib Test Page

-
- + + MeiLib Test + + + + + + + + + +

MeiLib Test Page

+
+ diff --git a/tests/tests.html b/tests/tests.html index 0b88e6c..48475bb 100644 --- a/tests/tests.html +++ b/tests/tests.html @@ -9,237 +9,250 @@ 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"> - - MEI-to-VexFlow Test Page - - - - - - - + + MEI-to-VexFlow Test Page + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - var canvas_elements = new Array(); - var title_elements = new Array(); - //create as many canvases and title elements as test cases... - $(test_cases).each( function(index) { - $('div.test-page').append(testItem_html); - - //...and load them into canvas_elements and title_elements arrays - canvas_elements[index] = $("div.a canvas")[index] - title_elements[index] = $("span.test-title")[index]; - }) - - //render test cases - var i; - for (i=0;i - - -
-
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + diff --git a/tests/unitTest.html b/tests/unitTest.html index cb81c25..9f90235 100644 --- a/tests/unitTest.html +++ b/tests/unitTest.html @@ -1,10 +1,10 @@ - - MEI-to-VexFlow UNIT TESTS - - + + MEI-to-VexFlow UNIT TESTS + + @@ -14,12 +14,11 @@ - - - - - + + - - - MEI2VexFlow Unit Tests. See console.log messages! + + + + MEI2VexFlow Unit Tests. See console.log messages! - + From 7ed2a49bca0a1df5433e3b3cb0309e9b33019424 Mon Sep 17 00:00:00 2001 From: zolaemil Date: Mon, 30 Jun 2014 15:53:53 +0100 Subject: [PATCH 4/5] adjust modifiers position after positioning the staff; use setX() VexFlow if available --- src/Measure.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Measure.js b/src/Measure.js index 8e7609b..e107eed 100644 --- a/src/Measure.js +++ b/src/Measure.js @@ -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]; @@ -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()); From 9693a7a3ac12e4ee832422448a9b22f5c663a6f4 Mon Sep 17 00:00:00 2001 From: zolaemil Date: Mon, 30 Jun 2014 15:57:48 +0100 Subject: [PATCH 5/5] removed END volta type; [fix needed in VexFlow] --- src/Converter.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Converter.js b/src/Converter.js index 51d645d..d8b65a3 100644 --- a/src/Converter.js +++ b/src/Converter.js @@ -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); - } }); }, @@ -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
'); } @@ -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); + } }, /**