Skip to content

Commit

Permalink
Merge pull request #1259 from rvilarl/easyscoreMutedHarmonySlash
Browse files Browse the repository at this point in the history
Easyscore support for muted, harmony, slash and ghost notes I (muted, harmony, slash)
  • Loading branch information
0xfe authored Dec 19, 2021
2 parents 3ccbd64 + 29fa14f commit 13724d4
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/easyscore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class EasyScoreGrammar implements Grammar {
return { token: '[0-9whq]+' };
}
TYPES(): Rule {
return { token: '[rRsSxX]' };
return { token: '[rRsSmMhH]' };
}
LPAREN(): Rule {
return { token: '[(]' };
Expand Down
92 changes: 88 additions & 4 deletions tests/easyscore_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const EasyScoreTests = {
test('Options', options);
const run = VexFlowTests.runTests;
run('Draw Basic', drawBasicTest);
run('Draw Basic Muted', drawBasicMutedTest);
run('Draw Basic Harmonic', drawBasicHarmonicTest);
run('Draw Basic Slash', drawBasicSlashTest);
run('Draw Accidentals', drawAccidentalsTest);
run('Draw Beams', drawBeamsTest);
run('Draw Tuplets', drawTupletsTest);
Expand Down Expand Up @@ -55,7 +58,7 @@ function createShortcuts(score: EasyScore) {
*/
function basic(): void {
const score = new EasyScore();
const mustPass = ['c4', 'c#4', 'c4/r', 'c#5', 'c3/x', 'c3//x'];
const mustPass = ['c4', 'c#4', 'c4/r', 'c#5', 'c3/m', 'c3//m', 'c3//h', 'c3/s', 'c3//s'];
const mustFail = ['', '()', '7', '(c#4 e5 g6'];

mustPass.forEach((line) => equal(score.parse(line).success, true, line));
Expand All @@ -68,7 +71,7 @@ function accidentals(): void {
'c3',
'c##3, cb3',
'Cn3',
'f3//x',
'f3//m',
'(c##3 cbb3 cn3), cb3',
'cbbs7',
'cbb7',
Expand Down Expand Up @@ -135,7 +138,7 @@ function chords(): void {
'(c##4 cbb4 cn4)/w, (c#5 cb2 a3)/32',
'(d##4 cbb4 cn4)/w/r, (c#5 cb2 a3)',
'(c##4 cbb4 cn4)/4, (c#5 cb2 a3)',
'(c##4 cbb4 cn4)/x, (c#5 cb2 a3)',
'(c##4 cbb4 cn4)/m, (c#5 cb2 a3)',
];
const mustFail = ['(c)'];

Expand All @@ -162,7 +165,7 @@ function dots(): void {

function types(): void {
const score = new EasyScore();
const mustPass = ['c3/4/x.', 'c##3//r.., cb3', 'c##3/x.., cb3', 'c##3/r.., cb3', 'd##3/w/s, cb3/q...', 'Fb4'];
const mustPass = ['c3/4/m.', 'c##3//r.., cb3', 'c##3/m.., cb3', 'c##3/r.., cb3', 'd##3/w/s, cb3/q...', 'Fb4'];
const mustFail = ['c4/q/U', '(c##4, cbb4 cn4)/w.., (c#5 cb2 a3)/32', 'z#3'];

mustPass.forEach((line) => equal(score.parse(line).success, true, line));
Expand Down Expand Up @@ -212,6 +215,87 @@ function drawBasicTest(options: TestOptions): void {
expect(0);
}

function drawBasicMutedTest(options: TestOptions): void {
const f = VexFlowTests.makeFactory(options, 600, 350);
const score = f.EasyScore();
const system = f.System();

const { voice, notes } = createShortcuts(score);

system
.addStave({
voices: [
voice(notes('(d4 e4 g4)/q/m, c4/q/m, c4/q/r, c4/q/m', { stem: 'down' })),
voice(notes('c#5/h/m., c5/q/m', { stem: 'up' })),
],
})
.addClef('treble');

system
.addStave({
voices: [voice(notes('c#3/q/m, cn3/q/m, bb3/q/m, d##3/q/m', { clef: 'bass' }))],
})
.addClef('bass');
system.addConnector().setType(StaveConnector.type.BRACKET);

f.draw();
expect(0);
}

function drawBasicHarmonicTest(options: TestOptions): void {
const f = VexFlowTests.makeFactory(options, 600, 350);
const score = f.EasyScore();
const system = f.System();

const { voice, notes } = createShortcuts(score);

system
.addStave({
voices: [
voice(notes('(d4 e4 g4)/q/h, c4/q/h, c4/q/r, c4/q/h', { stem: 'down' })),
voice(notes('c#5/h/h., c5/q/h', { stem: 'up' })),
],
})
.addClef('treble');

system
.addStave({
voices: [voice(notes('c#3/q/h, cn3/q/h, bb3/q/h, d##3/q/h', { clef: 'bass' }))],
})
.addClef('bass');
system.addConnector().setType(StaveConnector.type.BRACKET);

f.draw();
expect(0);
}

function drawBasicSlashTest(options: TestOptions): void {
const f = VexFlowTests.makeFactory(options, 600, 350);
const score = f.EasyScore();
const system = f.System();

const { voice, notes } = createShortcuts(score);

system
.addStave({
voices: [
voice(notes('(d4 e4 g4)/q/s, c4/q/s, c4/q/r, c4/q/s', { stem: 'down' })),
voice(notes('c#5/h/s., c5/q/s', { stem: 'up' })),
],
})
.addClef('treble');

system
.addStave({
voices: [voice(notes('c#3/q/s, cn3/q/s, bb3/q/s, d##3/q/s', { clef: 'bass' }))],
})
.addClef('bass');
system.addConnector().setType(StaveConnector.type.BRACKET);

f.draw();
expect(0);
}

function drawAccidentalsTest(options: TestOptions): void {
const f = VexFlowTests.makeFactory(options, 600, 350);
const score = f.EasyScore();
Expand Down

0 comments on commit 13724d4

Please sign in to comment.