Skip to content

Commit

Permalink
Merge pull request #3 from Nairam/feature/128th_note_support
Browse files Browse the repository at this point in the history
Feature/128th note support
  • Loading branch information
l3v5y committed Jul 7, 2013
2 parents 6f5d4ed + 27d1c17 commit 6b43afc
Show file tree
Hide file tree
Showing 5 changed files with 636 additions and 12 deletions.
566 changes: 565 additions & 1 deletion src/fonts/vexflow_font.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/stavenote.js
Expand Up @@ -95,6 +95,7 @@ Vex.Flow.StaveNote.prototype.init = function(note_struct) {
// Lengthen 32nd & 64th note stems for additional flags/beams
if (this.duration == "32") this.render_options.stem_height = 45;
if (this.duration == "64") this.render_options.stem_height = 50;
if (this.duration == "128") this.render_options.stem_height = 55;

var auto_stem_direction;
if (note_struct.auto_stem) {
Expand Down Expand Up @@ -238,6 +239,11 @@ Vex.Flow.StaveNote.prototype.getStemMinumumLength = function() {
else
length = 40;
break;
case "128":
if (this.beam == null)
length = 55;
else
length = 45;
}
return length;
}
Expand Down
46 changes: 44 additions & 2 deletions src/tables.js
Expand Up @@ -530,7 +530,8 @@ Vex.Flow.durationToTicks.durations = {
"16": Vex.Flow.RESOLUTION / 16,
"32": Vex.Flow.RESOLUTION / 32,
"64": Vex.Flow.RESOLUTION / 64,
"256": Vex.Flow.RESOLUTION / 256
"128": Vex.Flow.RESOLUTION / 128,
"256": Vex.Flow.RESOLUTION / 256
};

Vex.Flow.durationAliases = {
Expand Down Expand Up @@ -802,7 +803,7 @@ Vex.Flow.durationToGlyph.duration_codes = {
},
"64": {
common: {
beam_count: 3,
beam_count: 4,
head_width: 10.5,
stem: true,
stem_offset: 0,
Expand Down Expand Up @@ -840,6 +841,47 @@ Vex.Flow.durationToGlyph.duration_codes = {
position: "B/4"
}
}
},
"128": {
common: {
beam_count: 5,
head_width: 10.5,
stem: true,
stem_offset:0,
flag: true,
code_flag_upstem: "v9b",
code_flag_downstem: "v30",
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
"n": { // Hundred-twenty-eight note
code_head: "vb"
},
"h": { // Hundred-twenty-eight harmonic
code_head: "v22"
},
"m": { // Hundred-twenty-eight muted
code_head: "v3e"
},
"r": { // Hundred-twenty-eight rest
code_head: "vaa",
head_width: 20,
stem: false,
flag: false,
rest: true,
position: "B/4",
dot_shiftY: 1.5,
line_above: 2.0,
line_below: 3.0
},
"s": { // Hundred-twenty-eight rest
// Drawn with canvas primitives
head_width: 15,
position: "B/4"
}
}
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/transform.html
Expand Up @@ -58,7 +58,7 @@
"v1d": true, "v1e": true, "v1f": true, "v22": true,
"v23": true, "v25": true, "v26": true, "v27": true,
"v28": true, "v2a": true, "v2d": true, "v2f": true,
"v33": true, "v38": true, "v3b": true, "v3c": true, "v3e": true, "v3f": true,
"v30": true, "v33": true, "v38": true, "v3b": true, "v3c": true, "v3e": true, "v3f": true,
"v40": true, "v41": true, "v42": true, "v43": true,
"v44": true, "v45": true, "v46": true, "v47": true, "v49": true,
"v4a": true, "v4d": true, "v4e": true, "v52": true,
Expand All @@ -67,8 +67,8 @@
"v79": true, "v7c": true, "v7d": true, "v7f": true, "v80": true,
"v81": true, "v83": true, "v84": true, "v8b": true,
"v8c": true, "v8f": true, "v92": true, "v93": true, "v94": true,
"v95": true, "v97": true, "v9a": true, "v9c": true,
"va3": true, "va5": true, "va9": true, "vad": true, "vb6": true,
"v95": true, "v97": true, "v9a": true, "v9b": true, "v9c": true,
"vaa": true, "va3": true, "va5": true, "va9": true, "vad": true, "vb6": true,
"vb3": true, "vb9": true, "vba": true, "vbf": true, "vc3": true };

// Get number of glyphs and rename elements
Expand Down
24 changes: 18 additions & 6 deletions tests/stavenote_tests.js
Expand Up @@ -402,7 +402,7 @@ Vex.Flow.Test.StaveNote.draw = function(options, contextBuilder) {
var restKey = options.params.restKey;

var ctx = new contextBuilder(options.canvas_sel, 700, 180);
var stave = new Vex.Flow.Stave(10, 30, 650);
var stave = new Vex.Flow.Stave(10, 30, 750);

stave.setContext(ctx);
stave.addClef(clef);
Expand All @@ -426,6 +426,7 @@ Vex.Flow.Test.StaveNote.draw = function(options, contextBuilder) {
{ clef: clef, keys: lowerKeys, duration: "16"},
{ clef: clef, keys: higherKeys, duration: "32"},
{ clef: clef, keys: higherKeys, duration: "64"},
{ clef: clef, keys: higherKeys, duration: "128"},
{ clef: clef, keys: lowerKeys, duration: "w",
stem_direction: -1},
{ clef: clef, keys: lowerKeys, duration: "h",
Expand All @@ -440,6 +441,8 @@ Vex.Flow.Test.StaveNote.draw = function(options, contextBuilder) {
stem_direction: -1},
{ clef: clef, keys: lowerKeys, duration: "64",
stem_direction: -1},
{ clef: clef, keys: lowerKeys, duration: "128",
stem_direction: -1},

{ clef: clef, keys: restKeys, duration: "wr"},
{ clef: clef, keys: restKeys, duration: "hr"},
Expand All @@ -448,6 +451,7 @@ Vex.Flow.Test.StaveNote.draw = function(options, contextBuilder) {
{ clef: clef, keys: restKeys, duration: "16r"},
{ clef: clef, keys: restKeys, duration: "32r"},
{ clef: clef, keys: restKeys, duration: "64r"},
{ clef: clef, keys: restKeys, duration: "128r"},
{ keys: ["x/4"], duration: "h"}
];
expect(notes.length * 2);
Expand All @@ -467,7 +471,7 @@ Vex.Flow.Test.StaveNote.drawBoundingBoxes = function(options, contextBuilder) {
var restKey = options.params.restKey;

var ctx = new contextBuilder(options.canvas_sel, 700, 180);
var stave = new Vex.Flow.Stave(10, 30, 650);
var stave = new Vex.Flow.Stave(10, 30, 750);

stave.setContext(ctx);
stave.addClef(clef);
Expand All @@ -491,6 +495,7 @@ Vex.Flow.Test.StaveNote.drawBoundingBoxes = function(options, contextBuilder) {
{ clef: clef, keys: lowerKeys, duration: "16"},
{ clef: clef, keys: higherKeys, duration: "32"},
{ clef: clef, keys: higherKeys, duration: "64"},
{ clef: clef, keys: higherKeys, duration: "128"},
{ clef: clef, keys: lowerKeys, duration: "w",
stem_direction: -1},
{ clef: clef, keys: lowerKeys, duration: "h",
Expand All @@ -505,6 +510,7 @@ Vex.Flow.Test.StaveNote.drawBoundingBoxes = function(options, contextBuilder) {
stem_direction: -1},
{ clef: clef, keys: lowerKeys, duration: "64",
stem_direction: -1},
{ clef: clef, keys: lowerKeys, duration: "128"},

{ clef: clef, keys: restKeys, duration: "wr"},
{ clef: clef, keys: restKeys, duration: "hr"},
Expand All @@ -513,6 +519,7 @@ Vex.Flow.Test.StaveNote.drawBoundingBoxes = function(options, contextBuilder) {
{ clef: clef, keys: restKeys, duration: "16r"},
{ clef: clef, keys: restKeys, duration: "32r"},
{ clef: clef, keys: restKeys, duration: "64r"},
{ clef: clef, keys: restKeys, duration: "128r"},
{ keys: ["x/4"], duration: "h"}
];
expect(notes.length * 2);
Expand All @@ -529,8 +536,8 @@ Vex.Flow.Test.StaveNote.drawBoundingBoxes = function(options, contextBuilder) {
Vex.Flow.Test.StaveNote.drawBass = function(options, contextBuilder) {
expect(36);
var ctx = new contextBuilder(options.canvas_sel, 600, 280);
var stave = new Vex.Flow.Stave(10, 10, 550);
var stave2 = new Vex.Flow.Stave(10, 150, 550);
var stave = new Vex.Flow.Stave(10, 10, 650);
var stave2 = new Vex.Flow.Stave(10, 150, 650);
stave.setContext(ctx);
stave.addClef('bass');
stave.draw();
Expand Down Expand Up @@ -621,13 +628,15 @@ Vex.Flow.Test.StaveNote.drawHarmonicAndMuted = function(options,
{ keys: ["c/4", "e/4", "a/4"], duration: "16h"},
{ keys: ["c/4", "e/4", "a/4"], duration: "32h"},
{ keys: ["c/4", "e/4", "a/4"], duration: "64h"},
{ keys: ["c/4", "e/4", "a/4"], duration: "128h"},
{ keys: ["c/4", "e/4", "a/4"], duration: "wh", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "hh", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "qh", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "8h", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "16h", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "32h", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "64h", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "128h", stem_direction: -1},

{ keys: ["c/4", "e/4", "a/4"], duration: "wm"},
{ keys: ["c/4", "e/4", "a/4"], duration: "hm"},
Expand All @@ -636,13 +645,15 @@ Vex.Flow.Test.StaveNote.drawHarmonicAndMuted = function(options,
{ keys: ["c/4", "e/4", "a/4"], duration: "16m"},
{ keys: ["c/4", "e/4", "a/4"], duration: "32m"},
{ keys: ["c/4", "e/4", "a/4"], duration: "64m"},
{ keys: ["c/4", "e/4", "a/4"], duration: "128m"},
{ keys: ["c/4", "e/4", "a/4"], duration: "wm", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "hm", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "qm", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "8m", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "16m", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "32m", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "64m", stem_direction: -1}
{ keys: ["c/4", "e/4", "a/4"], duration: "64m", stem_direction: -1},
{ keys: ["c/4", "e/4", "a/4"], duration: "128m", stem_direction: -1}
];
expect(notes.length * 2);

Expand All @@ -669,7 +680,8 @@ Vex.Flow.Test.StaveNote.drawSlash = function(options, contextBuilder) {
{ keys: ["b/4"], duration: "8s", stem_direction: -1},
{ keys: ["b/4"], duration: "16s", stem_direction: -1},
{ keys: ["b/4"], duration: "32s", stem_direction: -1},
{ keys: ["b/4"], duration: "64s", stem_direction: -1}
{ keys: ["b/4"], duration: "64s", stem_direction: -1},
{ keys: ["b/4"], duration: "128s", stem_direction: -1}
];
expect(notes.length * 2);

Expand Down

0 comments on commit 6b43afc

Please sign in to comment.