Skip to content

Commit

Permalink
Fixes #45 #48 #58. Fixes bug in Porrectus layout
Browse files Browse the repository at this point in the history
  • Loading branch information
frmatthew committed Mar 28, 2016
1 parent 4c825c0 commit 36bac6b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
15 changes: 8 additions & 7 deletions src/Exsurge.Chant.Neumes.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ export class Apostropha extends Neume {
// determine the glyph to use
var note = this.notes[0];

if (note.liquescent !== LiquescentType.None)
note.setGlyph(ctxt, GlyphCode.StrophaLiquescent);
else
note.setGlyph(ctxt, GlyphCode.Stropha);

note.setGlyph(ctxt, Apostropha.determineNoteGlyphCode(note));
this.addVisualizer(note);

this.origin.x = note.origin.x;
Expand All @@ -200,6 +196,9 @@ export class Apostropha extends Neume {
if (note.shape === NoteShape.Stropha)
return GlyphCode.Stropha;

if (note.liquescent !== LiquescentType.None)
note.setGlyph(ctxt, GlyphCode.StrophaLiquescent);

if (note.shapeModifiers & NoteShapeModifiers.Cavum)
return GlyphCode.PunctumCavum;

Expand Down Expand Up @@ -625,9 +624,11 @@ export class Porrectus extends Neume {
// add the connecting line
if (thirdStaffPosition - secondStaffPosition > 1) {
line = new NeumeLineVisualizer(ctxt, second, third, false);
x -= line.bounds.width;
line.bounds.x = x;
line.bounds.x = x - line.bounds.width;
this.addVisualizer(line);

if (third.liquescent & LiquescentType.Descending)
x -= line.bounds.width;
}

if (third.liquescent & LiquescentType.Small) {
Expand Down
38 changes: 29 additions & 9 deletions src/Exsurge.Gabc.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,6 @@ export var Gabc = {

var neumes = [];
var intraNeumeSpacing = ctxt.intraNeumeSpacing;

var prevNote = null, currNote = null;
var firstNoteIndex = 0;
var currNoteIndex = 0;

Expand All @@ -428,17 +426,31 @@ export var Gabc = {
// determine what to do...either transition to a different neume/state, or
// continue building the neume of that state. handle() returns the next state

var createNeume = function (neume, includeCurrNote) {
var createNeume = function (neume, includeCurrNote, includePrevNote = true) {

// add the notes to the neume
var lastNoteIndex = includeCurrNote ? currNoteIndex : currNoteIndex - 1;
var lastNoteIndex;
if (includeCurrNote)
lastNoteIndex = currNoteIndex;
else if (includePrevNote)
lastNoteIndex = currNoteIndex - 1;
else
lastNoteIndex = currNoteIndex - 2;

if (lastNoteIndex < 0)
return;

while (firstNoteIndex <= lastNoteIndex)
neume.notes.push(notes[firstNoteIndex++]);

neumes.push(neume);

if (includeCurrNote === false) {
currNoteIndex--;

if (includePrevNote === false)
currNoteIndex--;

neume.keepWithNext = true;
neume.trailingSpace = intraNeumeSpacing;
}
Expand Down Expand Up @@ -655,7 +667,7 @@ export var Gabc = {
return new Neumes.Apostropha();
},
handle: function(currNote, prevNote) {
if (currNote.staffPosition === prevNote.staffPosition && currNote.shape === NoteShape.Stropha)
if (currNote.staffPosition === prevNote.staffPosition)
return distrophaState;
else
return createNeume(new Neumes.Apostropha(), false);
Expand All @@ -667,10 +679,18 @@ export var Gabc = {
return new Neumes.Distropha();
},
handle: function(currNote, prevNote) {
if (currNote.staffPosition === prevNote.staffPosition && currNote.shape === NoteShape.Stropha)
if (currNote.staffPosition === prevNote.staffPosition)
return createNeume(new Neumes.Tristropha(), true);
else
return createNeume(new Neumes.Distropha(), false);
return createNeume(apostrophaState.neume(), false, false);

// distropha state is interesting because we have to be able to
// unwind back to an apostropha/punctum if necessary... hh gets us to
// the distropha state, but if the next note is a g, then instead
// of a distropha, we want a punctum/podatus. so the only
// way to create a distropha is be manually terminating it with
// some gabc spacing, or ending the notation run entirely (which
// will end up calling distrophaState.neume())
}
};

Expand Down Expand Up @@ -702,8 +722,8 @@ export var Gabc = {

while (currNoteIndex < notes.length) {

prevNote = currNote;
currNote = notes[currNoteIndex];
var prevNote = currNoteIndex > 0 ? notes[currNoteIndex - 1] : null;
var currNote = notes[currNoteIndex];

state = state.handle(currNote, prevNote);

Expand Down

0 comments on commit 36bac6b

Please sign in to comment.