From d6ffc8e5c58b78beaf5393ac43baefdd32fbbcca Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 29 Sep 2016 20:38:23 +0100 Subject: [PATCH 01/12] Updates to the libmei.plg Removed the (buggy) AddChildAtPosition --- lib/libmei.plg | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/libmei.plg b/lib/libmei.plg index 66f2a05..c802360 100644 --- a/lib/libmei.plg +++ b/lib/libmei.plg @@ -1289,21 +1289,6 @@ GetChildren "(element) { SetChildren "(element, childarr) { element.children = childarr; }" -AddChildAtPosition "(element, child, position) { - c = element.children; - r = CreateSparseArray(); - // copy the children to the new array. Add two - // beyond the length since we'll be adding a new element. - for i = c.Length + 2 { - if (i = position) { - r[i] = child; - i = i + 1; - } else { - r[i] = c[i]; - } - } - element.children = r; -}" AddChild "(element, child) { cid = child._id; child._parent = element._id; From 4a377341241abb672c54b394f5948db24bed9eb6 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 29 Sep 2016 20:38:57 +0100 Subject: [PATCH 02/12] Fixed: Remove unused parameter --- src/ExportGenerators.mss | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index a90a89e..e77fba6 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -1088,8 +1088,6 @@ function GenerateBarRest (bobj) { function GenerateScoreDef (score) { //$module(ExportGenerators.mss) scoredef = libmei.ScoreDef(); - Self._property:_GlobalScoreDef = libmei.GetId(scoredef); - docSettings = score.DocumentSetup; // this will ensure that the units specified by the user is the one that is From b242f3aa386c3ab2d6fdaacc2ce5ca12abe4f8be Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 29 Sep 2016 20:39:57 +0100 Subject: [PATCH 03/12] Fixed: Renamed MeasureLines Now named MeasureObjects to reflect the fact that it's more than just lines being stored. --- src/ExportGenerators.mss | 20 ++++++++++---------- src/ExportProcessors.mss | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index e77fba6..dc3ee9a 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -230,7 +230,7 @@ function GenerateMeasure (num) { score = Self._property:ActiveScore; // measureties Self._property:MeasureTies = CreateSparseArray(); - Self._property:MeasureLines = CreateSparseArray(); + Self._property:MeasureObjects = CreateSparseArray(); m = libmei.Measure(); libmei.AddAttribute(m, 'n', num); @@ -275,7 +275,7 @@ function GenerateMeasure (num) { m.children.Push(tie); } - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; for each line in mlines { @@ -549,18 +549,18 @@ function GenerateLayers (staffnum, measurenum) { if (line != null) { - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(line._id); - Self._property:MeasureLines = mlines; + Self._property:MeasureObjects = mlines; } - // add chord symbols to the measure lines + // add chord symbols to the measure objects // so that they get added to the measure later in the processing cycle. if (chordsym != null) { - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(chordsym._id); - Self._property:MeasureLines = mlines; + Self._property:MeasureObjects = mlines; } } @@ -705,7 +705,7 @@ function GenerateNoteRest (bobj, layer) { libmei.AddAttribute(fermata, 'layer', bobj.VoiceNumber); libmei.AddAttribute(fermata, 'staff', bobj.ParentBar.ParentStaff.StaffNum); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(fermata._id); } @@ -718,7 +718,7 @@ function GenerateNoteRest (bobj, layer) { libmei.AddAttribute(fermata, 'layer', bobj.VoiceNumber); libmei.AddAttribute(fermata, 'staff', bobj.ParentBar.ParentStaff.StaffNum); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(fermata._id); } @@ -731,7 +731,7 @@ function GenerateNoteRest (bobj, layer) { libmei.AddAttribute(fermata, 'layer', bobj.VoiceNumber); libmei.AddAttribute(fermata, 'staff', bobj.ParentBar.ParentStaff.StaffNum); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(fermata._id); } diff --git a/src/ExportProcessors.mss b/src/ExportProcessors.mss index eda7f68..326231d 100644 --- a/src/ExportProcessors.mss +++ b/src/ExportProcessors.mss @@ -502,7 +502,7 @@ function ProcessSymbol (sobj) { turn = libmei.Turn(); libmei.AddAttribute(turn, 'form', 'norm'); turn = AddBarObjectInfoToElement(sobj, turn); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(turn._id); } @@ -512,7 +512,7 @@ function ProcessSymbol (sobj) { turn = libmei.Turn(); libmei.AddAttribute(turn, 'form', 'inv'); turn = AddBarObjectInfoToElement(sobj, turn); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(turn._id); } From 19538f50752ec1471d80ff0b8d412e1a099046c4 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 29 Sep 2016 20:41:09 +0100 Subject: [PATCH 04/12] New: Key and Time Signature Changes Changes to key and time signatures are now reflected in the MEI output. --- src/ExportGenerators.mss | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index dc3ee9a..9e9d8d3 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -187,6 +187,10 @@ function GenerateMEIMusic () { section = libmei.Section(); libmei.AddChild(sco, section); + systf = score.SystemStaff; + + currentScoreDef = null; + for j = 1 to numbars + 1 { // this value may get changed by the volta processor @@ -210,6 +214,61 @@ function GenerateMEIMusic () { Self._property:PageBreak = null; } + currTimeS = systf.CurrentTimeSignature(j); + currKeyS = systf.CurrentKeySignature(j); + + // Do not try to get the signatures for bar 0 -- will not work + if (j > 1) + { + prevTimeS = systf.CurrentTimeSignature(j - 1); + prevKeyS = systf.CurrentKeySignature(j - 1); + } + else + { + prevTimeS = systf.CurrentTimeSignature(j); + prevKeyS = systf.CurrentKeySignature(j); + } + + /* + This will check for a change in the current time signature and create a new + scoredef element if it's changed. The key signature will always be processed later, + so by then we will either have a new scoredef with a timesig change, or we'll need + to create one just for the keysig change. + */ + if ((currTimeS.Numerator != prevTimeS.Numerator) or (currTimeS.Denominator != prevTimeS.Denominator)) + { + currentScoreDef = libmei.ScoreDef(); + // Log('Time Signature Change in Bar ' & j); + libmei.AddAttribute(currentScoreDef, 'meter.count', currTimeS.Numerator); + libmei.AddAttribute(currentScoreDef, 'meter.unit', currTimeS.Denominator); + libmei.AddAttribute(currentScoreDef, 'meter.sym', ConvertNamedTimeSignature(currTimeS.Text)); + } + + if (currKeyS.Sharps != prevKeyS.Sharps) + { + if (currentScoreDef = null) + { + currentScoreDef = libmei.ScoreDef(); + } + + libmei.AddAttribute(currentScoreDef, 'key.sig', ConvertKeySignature(currKeyS.Sharps)); + } + + if (currentScoreDef != null) + { + // The sig changes must be added just before we add the measure to keep + // the proper order. + if (ending != null) + { + libmei.AddChild(ending, currentScoreDef); + } + else + { + libmei.AddChild(section, currentScoreDef); + } + currentScoreDef = null; + } + if (ending != null) { libmei.AddChild(section, ending); From 4cef3ad5c5e391322780f2b67274d28159bbf087 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Sun, 2 Oct 2016 18:14:54 +0100 Subject: [PATCH 05/12] Fixed: Reference to nonexistent object The MeasureLines array was changed to MeasureObjects, but these lines were not updated to reflect this. --- src/ExportProcessors.mss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ExportProcessors.mss b/src/ExportProcessors.mss index 326231d..65fd611 100644 --- a/src/ExportProcessors.mss +++ b/src/ExportProcessors.mss @@ -474,7 +474,7 @@ function ProcessSymbol (sobj) { { // trill trill = GenerateTrill(sobj); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(trill._id); } @@ -483,7 +483,7 @@ function ProcessSymbol (sobj) { // inverted mordent mordent = libmei.Mordent(); libmei.AddAttribute(mordent, 'form', 'inv'); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(mordent._id); } @@ -492,7 +492,7 @@ function ProcessSymbol (sobj) { // mordent mordent = libmei.Mordent(); libmei.AddAttribute(mordent, 'form', 'norm'); - mlines = Self._property:MeasureLines; + mlines = Self._property:MeasureObjects; mlines.Push(mordent._id); } From 8f8992b98fdfa496f5a00f9b8d3c76f2c2945790 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Sun, 2 Oct 2016 18:15:12 +0100 Subject: [PATCH 06/12] New: Update identifier for 2.0.3 --- src/GLOBALS.mss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GLOBALS.mss b/src/GLOBALS.mss index 0937a9d..2702347 100644 --- a/src/GLOBALS.mss +++ b/src/GLOBALS.mss @@ -1,4 +1,4 @@ -Version "2.0.2" +Version "2.0.3" PluginName "Sibelius to MEI Exporter" Author "Andrew Hankinson" From 3984b95a8b7b2d05fc1432e1cb81f7ec2125842d Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 20 Oct 2016 10:05:56 -0400 Subject: [PATCH 07/12] Fixed: Typo with Diminuendo Lines --- src/ExportGenerators.mss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index 9e9d8d3..5c7c149 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -1316,7 +1316,7 @@ function GenerateLine (bobj) { line = libmei.Hairpin(); libmei.AddAttribute(line, 'form', 'cres'); } - case ('DimuendoLine') + case ('DiminuendoLine') { line = libmei.Hairpin(); libmei.AddAttribute(line, 'form', 'dim'); From c28c4b7d6386cdc06464dbb50d757777c1404324 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 20 Oct 2016 10:08:40 -0400 Subject: [PATCH 08/12] Fixed: Rename variable for measure objects They're more than just lines, so variable name should reflect this. --- src/ExportGenerators.mss | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index 5c7c149..52e0fed 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -454,7 +454,7 @@ function GenerateLayers (staffnum, measurenum) { } obj = null; - line = null; + mobj = null; chordsym = null; parent = null; beam = null; @@ -578,23 +578,23 @@ function GenerateLayers (staffnum, measurenum) { } case('Slur') { - line = GenerateLine(bobj); + mobj = GenerateLine(bobj); } case('CrescendoLine') { - line = GenerateLine(bobj); + mobj = GenerateLine(bobj); } case('DimuendoLine') { - line = GenerateLine(bobj); + mobj = GenerateLine(bobj); } case('OctavaLine') { - line = GenerateLine(bobj); + mobj = GenerateLine(bobj); } case('Trill') { - line = GenerateLine(bobj); + mobj = GenerateLine(bobj); } case('RepeatTimeLine') { @@ -602,15 +602,15 @@ function GenerateLayers (staffnum, measurenum) { } case('Line') { - line = GenerateLine(bobj); + mobj = GenerateLine(bobj); } } - if (line != null) + if (mobj != null) { - mlines = Self._property:MeasureObjects; - mlines.Push(line._id); - Self._property:MeasureObjects = mlines; + mobjs = Self._property:MeasureObjects; + mobjs.Push(mobj._id); + Self._property:MeasureObjects = mobjs; } // add chord symbols to the measure objects From 356058ae5c827a724223b3384867146513c4fa44 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 20 Oct 2016 10:10:52 -0400 Subject: [PATCH 09/12] New: Text converter The case for text is now handled in the output generator. --- src/ExportGenerators.mss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index 52e0fed..454aa8e 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -604,6 +604,10 @@ function GenerateLayers (staffnum, measurenum) { { mobj = GenerateLine(bobj); } + case('Text') + { + mobj = ConvertText(bobj); + } } if (mobj != null) From 4fe1276c8d83ca7c1184214791685b893e4a7bd8 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 20 Oct 2016 10:12:07 -0400 Subject: [PATCH 10/12] New: Method for creating tstamp2 values The ConvertPositionWithDurationToTimestamp method is used to convert an object with a multi-measure duration to the appropriate MEI value, e.g., 4m+1.5. --- src/ExportConverters.mss | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ExportConverters.mss b/src/ExportConverters.mss index 416eb7b..31cb1ec 100644 --- a/src/ExportConverters.mss +++ b/src/ExportConverters.mss @@ -793,6 +793,26 @@ function ConvertPositionToTimestamp (position, bar) { return ret; } //$end +function ConvertPositionWithDurationToTimestamp (bobj) { + //$module(ExportConverters.mss) + + /* + Like ConvertPositionToTimestamp, but suitable to filling out the tstamp2 parameter + with an object of a specific duration (such as a slur or hairpin), e.g., 1m+2 + + NB: Can only be used on objects with EndBarNumber and EndPosition attributes, like Lines. + */ + startBar = bobj.ParentBar; + startBarNum = startBar.BarNumber; + endBarNum = bobj.EndBarNumber; + endBar = startBar.ParentStaff.NthBar(endBarNum); + endPosition = bobj.EndPosition; + measureDuration = endBarNum - startBarNum; + position = ConvertPositionToTimestamp(endPosition, endBar); + + return measureDuration & 'm+' & position; +} //$end + function ConvertTupletStyle (tupletStyle) { //$module(ExportConverters.mss) switch (tupletStyle) From f324427cf4e54b631ede6a1a2025820e625df125 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 20 Oct 2016 10:13:01 -0400 Subject: [PATCH 11/12] Fixed: Slurs now carry the tstamp2 parameter Previously slurs did not have their duration encoded in the tstamp2 attribute. This is now fixed. --- src/Utilities.mss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Utilities.mss b/src/Utilities.mss index 3e99a89..4baba4b 100644 --- a/src/Utilities.mss +++ b/src/Utilities.mss @@ -162,11 +162,11 @@ function AddBarObjectInfoToElement (bobj, element) { } } - libmei.AddAttribute(element, 'tstamp', ConvertPositionToTimestamp(bobj.Position, bobj.ParentBar)); + libmei.AddAttribute(element, 'tstamp', ConvertPositionToTimestamp(bobj.Position, bar)); - if (bobj.Type = 'Line' or bobj.Type = 'Slur') + if (bobj.Type = 'Line' or bobj.Type = 'Slur' or bobj.Type = 'DiminuendoLine' or bobj.Type = 'CrescendoLine') { - libmei.AddAttribute(element, 'tstamp2', ConvertPositionToTimestamp(bobj.EndPosition, bar)); + libmei.AddAttribute(element, 'tstamp2', ConvertPositionWithDurationToTimestamp(bobj)); } libmei.AddAttribute(element, 'staff', bar.ParentStaff.StaffNum); From b784f1c938c2b12015da990bd3c8f6f40b8a9e7f Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 20 Oct 2016 10:14:48 -0400 Subject: [PATCH 12/12] Fixed: Another typo Someday I will learn to spell 'Diminuendo' correctly... --- src/ExportGenerators.mss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index 454aa8e..0e9ced3 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -584,7 +584,7 @@ function GenerateLayers (staffnum, measurenum) { { mobj = GenerateLine(bobj); } - case('DimuendoLine') + case('DiminuendoLine') { mobj = GenerateLine(bobj); }