Skip to content

Commit

Permalink
Add sori and koron microtonal glyphs (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
Huji authored and Silverwolf90 committed Dec 28, 2016
1 parent f48cba5 commit d5dc1f1
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/easyscore.js
Expand Up @@ -131,7 +131,7 @@ class Grammar {
SVAL() { return { token: "['][^']*[']" }; }
NOTENAME() { return { token: '[a-gA-G]' }; }
OCTAVE() { return { token: '[0-9]+' }; }
ACCIDENTALS() { return { token: 'bbs|bb|bss|bs|b|db|d|##|#|n|\\+\\+-|\\+-|\\+\\+|\\+' }; }
ACCIDENTALS() { return { token: 'bbs|bb|bss|bs|b|db|d|##|#|n|\\+\\+-|\\+-|\\+\\+|\\+|k|o' }; }
DURATIONS() { return { token: '[0-9whq]+' }; }
TYPES() { return { token: '[rRsSxX]' }; }
LPAREN() { return { token: '[(]' }; }
Expand Down
8 changes: 8 additions & 0 deletions src/fonts/microtonal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/fonts/vexflow_font.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/tables.js
Expand Up @@ -291,6 +291,8 @@ Flow.accidentalCodes.accidentals = {
'++-': { code: 'v7a', parenRightPaddingAdjustment: -1 },
'bs': { code: 'vb7', parenRightPaddingAdjustment: -1 },
'bss': { code: 'v39', parenRightPaddingAdjustment: -1 },
'o': { code: 'vd0', parenRightPaddingAdjustment: -1 },
'k': { code: 'vd1', parenRightPaddingAdjustment: -1 },
};

Flow.accidentalColumnsTable = {
Expand Down
61 changes: 61 additions & 0 deletions tests/accidental_tests.js
Expand Up @@ -26,6 +26,7 @@ Vex.Flow.Test.Accidental = (function() {
Vex.Flow.Test.runTests('Accidental Arrangement Special Cases', Vex.Flow.Test.Accidental.specialCases);
Vex.Flow.Test.runTests('Multi Voice', Vex.Flow.Test.Accidental.multiVoice);
Vex.Flow.Test.runTests('Microtonal', Vex.Flow.Test.Accidental.microtonal);
Vex.Flow.Test.runTests('Microtonal (Iranian)', Vex.Flow.Test.Accidental.microtonal_iranian);
test('Automatic Accidentals - Simple Tests', Vex.Flow.Test.Accidental.autoAccidentalWorking);
Vex.Flow.Test.runTests('Automatic Accidentals', Vex.Flow.Test.Accidental.automaticAccidentals0);
Vex.Flow.Test.runTests('Automatic Accidentals - C major scale in Ab', Vex.Flow.Test.Accidental.automaticAccidentals1);
Expand Down Expand Up @@ -358,6 +359,66 @@ Vex.Flow.Test.Accidental = (function() {
Vex.Flow.Test.plotLegendForNoteWidth(ctx, 580, 140);
ok(true, 'Microtonal Accidental');
},

microtonal_iranian: function(options) {
var assert = options.assert;
var vf = VF.Test.makeFactory(options, 700, 240);
var newAccid = makeNewAccid(vf);
var ctx = vf.getContext();
vf.Stave({ x: 10, y: 10, width: 650 });

var notes = [
vf.StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: '1' })
.addAccidental(0, newAccid('k'))
.addAccidental(1, newAccid('o')),

vf.StaveNote({ keys: ['d/4', 'e/4', 'f/4', 'a/4', 'c/5', 'e/5', 'g/5'], duration: '2' })
.addAccidental(0, newAccid('b'))
.addAccidental(1, newAccid('k'))
.addAccidental(2, newAccid('n'))
.addAccidental(3, newAccid('o'))
.addAccidental(4, newAccid('#'))
.addAccidental(5, newAccid('bb'))
.addAccidental(6, newAccid('##')),

vf.StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4', 'c/5', 'e/5', 'g/5'], duration: '16' })
.addAccidental(0, newAccid('o'))
.addAccidental(1, newAccid('k'))
.addAccidental(2, newAccid('n'))
.addAccidental(3, newAccid('b'))
.addAccidental(4, newAccid('bb'))
.addAccidental(5, newAccid('##'))
.addAccidental(6, newAccid('#')),

vf.StaveNote({ keys: ['a/3', 'c/4', 'e/4', 'b/4', 'd/5', 'g/5'], duration: '1' })
.addAccidental(0, newAccid('#'))
.addAccidental(1, newAccid('o').setAsCautionary())
.addAccidental(2, newAccid('n').setAsCautionary())
.addAccidental(3, newAccid('b'))
.addAccidental(4, newAccid('k').setAsCautionary()),

vf.StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4'], duration: '16' })
.addAccidental(0, newAccid('k'))
.addAccidental(1, newAccid('k'))
.addAccidental(2, newAccid('k'))
.addAccidental(3, newAccid('k')),
];

VF.Formatter.SimpleFormat(notes, 0, { paddingBetween: 35 });

notes.forEach(function(note, index) {
Vex.Flow.Test.plotNoteWidth(vf.getContext(), note, 140);
assert.ok(note.getAccidentals().length > 0, 'Note ' + index + ' has accidentals');
note.getAccidentals().forEach(function(accid, index) {
assert.ok(accid.getWidth() > 0, 'Accidental ' + index + ' has set width');
});
});

vf.draw();

Vex.Flow.Test.plotLegendForNoteWidth(ctx, 580, 140);
ok(true, 'Microtonal Accidental (Iranian)');
},

automaticAccidentals0: function(options) {
var vf = VF.Test.makeFactory(options, 700, 200);
Expand Down
7 changes: 4 additions & 3 deletions tests/easyscore_tests.js
Expand Up @@ -34,12 +34,13 @@ Vex.Flow.Test.EasyScore = (function() {
var score = new VF.EasyScore();
var mustPass = [
'c3', 'c##3, cb3', 'Cn3', 'f3//x', '(c##3 cbb3 cn3), cb3',
'cbbs7', 'cbb7', 'cbss7', 'cbs7', 'cb7', 'cdb7', 'cd7', 'c##7', 'c#7', 'cn7', 'c++-7', 'c++7', 'c+-7', 'c+7',
'(cbs3 bbs3 dbs3), ebs3', '(cd7 cbb3 cn3), cb3',
'cbbs7', 'cbb7', 'cbss7', 'cbs7', 'cb7', 'cdb7', 'cd7', 'c##7', 'c#7', 'cn7', 'c++-7',
'c++7', 'c+-7', 'c+7', '(cbs3 bbs3 dbs3), ebs3', '(cd7 cbb3 cn3), cb3', 'co7', 'ck7',
];
var mustFail = [
'ct3', 'cdbb7', '(cq cbb3 cn3), cb3', '(cdd7 cbb3 cn3), cb3',
'cbbbs7', 'cbbss7', 'cbsss7', 'csbs7', 'cddb7', 'cddbb7', 'cdd7', 'c##b7', 'c#bs7', 'cnb#7', 'c+#+b-d7', 'c+--7', 'c++--7', 'c+++7',
'cbbbs7', 'cbbss7', 'cbsss7', 'csbs7', 'cddb7', 'cddbb7', 'cdd7', 'c##b7', 'c#bs7',
'cnb#7', 'c+#+b-d7', 'c+--7', 'c++--7', 'c+++7', 'cbk7', 'cok7', 'cko7', 'c#s7',
];

mustPass.forEach(function(line) { assert.equal(score.parse(line).success, true, line); });
Expand Down

0 comments on commit d5dc1f1

Please sign in to comment.