Skip to content

Commit

Permalink
Fixed problem with multiple morae (issue frmatthew#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Bloomfield committed Jun 1, 2016
1 parent 896731d commit 7b18766
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/Exsurge.Chant.Markings.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export class Mora extends GlyphVisualizer {
super(ctxt, GlyphCode.Mora);
this.note = note;
this.positionHint = MarkingPositionHint.Default;
this.horizontalOffset = 0;
}

performLayout(ctxt) {
Expand All @@ -243,7 +244,7 @@ export class Mora extends GlyphVisualizer {
verticalOffset -= ctxt.staffInterval * .75;
}

this.bounds.x += this.note.bounds.right() + ctxt.staffInterval / 4.0;
this.bounds.x += this.horizontalOffset + this.note.bounds.right() + ctxt.staffInterval / 4.0;
this.bounds.y += verticalOffset;
}
}
Expand Down
39 changes: 16 additions & 23 deletions src/Exsurge.Chant.Neumes.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,20 +565,13 @@ export class Clivis extends Neume {
// 1. morae need to be lined up if both notes have morae
// 2. like the podatus, mora on lower note needs to below
// under certain circumstances
for (i = 0; i < this.notes[1].morae.length; i++) {
mark = this.notes[1].morae[i];

if (this.notes[0].staffPosition - this.notes[1].staffPosition === 1 &&
Math.abs(this.notes[1].staffPosition % 2) === 1)
mark.positionHint = MarkingPositionHint.Below;
}

for (i = 0; i < this.notes[0].morae.length; i++) {

if (hasLowerMora) {
mark = this.notes[0].morae[i];
mark.positionHint = MarkingPositionHint.Above;
mark.horizontalOffset += this.notes[1].bounds.right() - this.notes[0].bounds.right();
if (this.notes[1].morae.length &&
this.notes[0].staffPosition - this.notes[1].staffPosition === 1 &&
Math.abs(this.notes[1].staffPosition % 2) === 1) {
var morae = this.notes[1].morae;
morae.slice(-1)[0].positionHint = MarkingPositionHint.Below;
if(morae.length > 1) {
morae[0].horizontalOffset += this.notes[1].bounds.right() - this.notes[0].bounds.right();
}
}

Expand Down Expand Up @@ -793,16 +786,16 @@ export class Podatus extends Neume {
if (this.notes[0].epismata[i].positionHint === MarkingPositionHint.Default)
this.notes[0].epismata[i].positionHint = MarkingPositionHint.Below;

// if this note has two or more (!?) morae then we just leave them be
// since they have already been assigned position hints.
if (this.notes[0].morae.length < 2) {
for (i = 0; i < this.notes[0].morae.length; i++) {
marking = this.notes[0].morae[i];

if ((this.notes[1].staffPosition - this.notes[0].staffPosition) === 1 &&
Math.abs(this.notes[0].staffPosition % 2) === 1)
marking.positionHint = MarkingPositionHint.Below;
// The mora on the first (lower) note needs to be below it, if the second note
// is only one pitch above, and the first note is on a line.
if (this.notes[1].staffPosition - this.notes[0].staffPosition === 1 &&
Math.abs(this.notes[0].staffPosition % 2) === 1) {
if (this.notes[0].morae.length == 1) {
marking = this.notes[0].morae[0];
} else if (this.notes[1].morae.length > 1) {
marking = this.notes[1].morae[0];
}
if(marking) marking.positionHint = MarkingPositionHint.Below;
}

for (i = 0; i < this.notes[1].epismata.length; i++)
Expand Down
12 changes: 4 additions & 8 deletions src/Exsurge.Gabc.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,14 +969,10 @@ export class Gabc {
// position hint. if a user decides to try to put position indicators
// on the double morae (such as 1 or 2), then really the behavior is
// not defined by gabc, so it's on the user to figure it out.
if (note.morae.length > 0) {
// if we already have one mora, then create another but force a
// an alternative positionHint
haveLookahead = true;
if (Math.abs(note.staffPosition) % 2 === 0)
lookahead = '1';
else
lookahead = '0';
if (note.morae.length > 0 && notes.length) {
var previousNote = notes.slice(-1)[0];
var previousMora = note.morae.slice(-1)[0];
previousMora.note = previousNote;
}

mark = new Markings.Mora(ctxt, note);
Expand Down

0 comments on commit 7b18766

Please sign in to comment.