Skip to content

Commit

Permalink
Implement fermata/@Form
Browse files Browse the repository at this point in the history
Fixes #136
  • Loading branch information
th-we committed Feb 4, 2021
1 parent be0e888 commit b2938c4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
27 changes: 27 additions & 0 deletions src/ExportConverters.mss
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 6 additions & 7 deletions src/ExportGenerators.mss
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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));
}
}

Expand Down
21 changes: 21 additions & 0 deletions src/Utilities.mss
Original file line number Diff line number Diff line change
Expand Up @@ -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)
/*
Expand Down

0 comments on commit b2938c4

Please sign in to comment.