From b2938c4f9b2b991834a0f933cdb8086e4189b4de Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Thu, 4 Feb 2021 21:31:12 +0100 Subject: [PATCH] Implement fermata/@form Fixes #136 --- src/ExportConverters.mss | 27 +++++++++++++++++++++++++++ src/ExportGenerators.mss | 13 ++++++------- src/Utilities.mss | 21 +++++++++++++++++++++ 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/ExportConverters.mss b/src/ExportConverters.mss index 1c0b5f9..3bb934f 100644 --- a/src/ExportConverters.mss +++ b/src/ExportConverters.mss @@ -1059,3 +1059,30 @@ function ConvertTimeStamp (time) { isodate = utils.Format('%s:%s:%s', hours, mins, secs); return isodate; } //$end + +function ConvertFermataForm (bobj) { + //$module(ExportConverters.mss) + + // Tries to find out @shape for 'keypad fermatas' of NoteRests and BarRests. + // At this point we expect that the calling function has already determined + // that the noteRest has a 'keypad fermata'. + + if (bobj.Type = 'BarRest') + { + stemweight = 0; + } + else + { + stemweight = bobj.Stemweight; + } + + if ((stemweight < 0) or (bobj.VoiceNumber % 2 = 1) or HasSingleVoice(bobj.ParentBar)) + { + return 'norm'; + } + else + { + return 'inv'; + } + +} //$end diff --git a/src/ExportGenerators.mss b/src/ExportGenerators.mss index 38fee64..13bc0ce 100644 --- a/src/ExportGenerators.mss +++ b/src/ExportGenerators.mss @@ -148,7 +148,6 @@ function GenerateMEIMusic () { Self._property:LyricWords = CreateDictionary(); Self._property:SpecialBarlines = CreateDictionary(); Self._property:SystemText = CreateDictionary(); - Self._property:LayerObjectPositions = null; Self._property:ObjectPositions = CreateDictionary(); Self._property:VoltaBars = CreateDictionary(); @@ -847,17 +846,17 @@ function GenerateNoteRest (bobj, layer) { if (bobj.GetArticulation(PauseArtic)) { - GenerateFermata(bobj, 'curved', 'norm'); + GenerateFermata(bobj, 'curved', ConvertFermataForm(bobj)); } if (bobj.GetArticulation(SquarePauseArtic)) { - GenerateFermata(bobj, 'square', 'norm'); + GenerateFermata(bobj, 'square', ConvertFermataForm(bobj)); } if (bobj.GetArticulation(TriPauseArtic)) { - GenerateFermata(bobj, 'angular', 'norm'); + GenerateFermata(bobj, 'angular', ConvertFermataForm(bobj)); } if (bobj.GetArticulation(StaccatoArtic)) @@ -1228,15 +1227,15 @@ function GenerateBarRest (bobj) { // TODO: Check for flipped fermatas case(PauseTypeRound) { - GenerateFermata(bobj, 'curved', 'norm'); + GenerateFermata(bobj, 'curved', ConvertFermataForm(bobj)); } case(PauseTypeTriangular) { - GenerateFermata(bobj, 'angular', 'norm'); + GenerateFermata(bobj, 'angular', ConvertFermataForm(bobj)); } case(PauseTypeSquare) { - GenerateFermata(bobj, 'square', 'norm'); + GenerateFermata(bobj, 'square', ConvertFermataForm(bobj)); } } diff --git a/src/Utilities.mss b/src/Utilities.mss index 5f3b3bf..5a1a6de 100644 --- a/src/Utilities.mss +++ b/src/Utilities.mss @@ -602,6 +602,27 @@ function PrevNormalOrGrace (noteRest, grace) { return prev_obj; } //$end +function HasSingleVoice (bar) { + //$module(Utilities.mss) + + // Returns true if the bar has at most one single voice + + voiceNum = -1; + for each bobj in bar + { + if (voiceNum != bobj.VoiceNumber and (bobj.Type = 'NoteRest' or bobj.Type = 'BarRest')) + { + if (voiceNum > 0) + { + return false; + } + voiceNum = bobj.VoiceNumber; + } + } + + return true; +} //$end + function GetNongraceParentBeam (noteRest, layer) { //$module(Utilities.mss) /*