Skip to content

Commit

Permalink
Merge pull request #104 from notengrafik/pr/release-2.2.0-fixed
Browse files Browse the repository at this point in the history
Pr/release 2.2.0 fixed
  • Loading branch information
ahankinson authored Jun 13, 2019
2 parents 75e6cfc + 2e6c302 commit 30e4608
Show file tree
Hide file tree
Showing 29 changed files with 590 additions and 153 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,27 @@ $> cd sibmei // cd into the sibmei source directory
$> npm install // installs the packages listed in the sibmei package.json directory
```

You need to create a symbolic link from the Sibelius plugin folder to the build folder in the sibmei directory. The paths are system dependent.

Example for Mac:

````
$> ln -s "~/path/to/sibmei/build/MEI Export" "~/Library/Application Support/Avid/Sibelius 7.5/Plugins/MEI Export"
````

Example for Windows (run as administrator):

````
> mklink %APPDATA%\Avid\Sibelius\Plugins\MEI Export" "%HOMEPATH%\path\to\sibmei\build\MEI Export"
````

Then, to start developing the plugin, you should run `gulp develop`. This will watch the folder for changes, build, and deploy the plugin. **To make your changes active, you will need to "unload" and "reload" the plugin in Sibelius.**

## Unit tests

The unit tests use the [sib-test](https://github.com/tido/sib-test) plugin, also developed by Tido. You should download and install this plugin first, and then you can run the unit tests by running the `testsibmei.plg` plugin.
The unit tests use the [sib-test](https://github.com/tido/sib-test) plugin, also developed by Tido. You should download and install this plugin first. Test can be run either by

* starting `testsibmei.plg` from the plugin editing window or
* starting Sibmei Test Runner from the menu/ribbon.

The former has the advantage that you don't have to open and close the "Edit Plugins" window between tests, the latter has the advantage of closing all test files after completed tests.
8 changes: 7 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var child = require('child_process');
var c = require('ansi-colors');
var l = require('fancy-log');
var Q = require('q');
var plgconf = require('./plgconfig');

gulp.task('develop:build', function(callback)
{
Expand All @@ -32,7 +33,12 @@ gulp.task('develop:build', function(callback)
l.info(c.blue('Output: ') + '\n' + stdout);
deferred.resolve();
});


l.info(c.blue('Copying test data'));
const destPath = plgconf.plgPath + '/' + plgconf.plgCategory + '/sibmeiTestSibs';
gulp.src('test/sibmeiTestSibs/*.sib', {base: 'test/sibmeiTestSibs'})
.pipe(gulp.dest(destPath));

return deferred.promise;
});

Expand Down
18 changes: 15 additions & 3 deletions lib/sibmei_batch_sib.plg
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@
{
Initialize "()
{
AddToPluginsMenu(_PluginMenuName,'Run');
AddToPluginsMenu(_PluginMenuName,'Run');
}"

Run "()
{
folder = Sibelius.SelectFolder();

if (IsObject(folder))
if (null != folder)
{
ConvertFolder(folder);
}
}"

ConvertFolder "(folder)
{

if (not IsObject(folder))
{
Sibelius.MessageBox('Not a folder object: ' & folder);
}
else
{
// count files for progress dialog
numFiles = folder.FileCount('SIB');
Expand Down
12 changes: 12 additions & 0 deletions lib/sibmei_test_runner.plg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

{
Initialize "()
{
AddToPluginsMenu('Sibmei Test Runner', 'Run');
}"

Run "()
{
Testsibmei2.Run();
}"
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha --recursive"
},
"author": "",
"license": "ISC",
Expand All @@ -16,6 +16,9 @@
"fancy-log": "^1.3.2",
"gulp": "^3.9.1",
"gulp-spawn": "^0.3.0",
"q": "^1.5.1"
"q": "^1.5.1",
"fontoxpath": "^2.12.1",
"slimdom-sax-parser": "^1.1.3",
"mocha": "^5.2.0"
}
}
13 changes: 9 additions & 4 deletions plgconfig.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
var config = {
plgPath: process.env.HOME + '/Library/Application Support/Avid/Sibelius 7.5/Plugins',
// As Sibelius's plugin folder path depends on the OS, Sibelius version and
// possibly other factors, we just compile everything to ./build. A developer
// must create a symbolic link to the build folder from the Sibelius plugin
// folder.
plgPath: './build',
plgCategory: 'MEI Export',
pluginFilename: 'sibmei2.plg',
linkLibraries: ['libmei.plg', 'sibmei_batch_mxml.plg', 'sibmei_batch_sib.plg'],
linkLibraries: [
'libmei.plg', 'sibmei_batch_mxml.plg', 'sibmei_batch_sib.plg', 'sibmei_test_runner.plg'
],
importDir: './import',
buildDir: './build',
srcDir: './src',
testDir: './test',
testDir: './test/sib-test',
libDir: './lib',
};

module.exports = config;

Binary file removed sibs/accidentals.sib
Binary file not shown.
2 changes: 1 addition & 1 deletion src/ExportConverters.mss
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function HasVisibleAccidental (noteobj) {
// Sibelius 7.1.3 introduced the IsAccidentalVisible parameter. Sweet.
if (Sibelius.ProgramVersion >= 7130)
{
return noteobj.IsAccidentalVisible;
return noteobj.IsAccidentalVisible and (noteobj.AccidentalStyle != HiddenAcc);
}

// If it has a cautionary accidental, it's most likely to be visible.
Expand Down
81 changes: 78 additions & 3 deletions src/ExportGenerators.mss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function GenerateMEIHeader () {
// takes in a Sibelius Score object
// returns a libmei tree (i.e., nested objects and arrays) with a MEI header with metadata
score = Self._property:ActiveScore;


header = libmei.MeiHead();
Self._property:HeaderElement = header;
Expand Down Expand Up @@ -181,7 +181,7 @@ function GenerateMEIMusic () {

// start with the first bar.
FIRST_BAR = 1;
mdiv = sibmei2.GenerateMDiv(FIRST_BAR);
mdiv = GenerateMDiv(FIRST_BAR);
libmei.AddChild(body, mdiv);

barmap = ConvertSibeliusStructure(score);
Expand Down Expand Up @@ -644,6 +644,13 @@ function GenerateLayers (staffnum, measurenum) {
{
l._property:PrevNote = note;
}

if (bobj.ArpeggioType != ArpeggioTypeNone) {
arpeg = GenerateArpeggio(bobj);
mobjs = Self._property:MeasureObjects;
mobjs.Push(arpeg._id);
Self._property:MeasureObjects = mobjs;
}
}
case('BarRest')
{
Expand Down Expand Up @@ -682,6 +689,10 @@ function GenerateLayers (staffnum, measurenum) {
{
mobj = GenerateLine(bobj);
}
case('ArpeggioLine')
{
mobj = GenerateArpeggio(bobj);
}
case('RepeatTimeLine')
{
RegisterVolta(bobj);
Expand Down Expand Up @@ -1516,6 +1527,70 @@ function GenerateLine (bobj) {
} //$end


function GenerateArpeggio (bobj) {
//$module(ExportGenerators.mss)
arpeg = libmei.Arpeg();
orientation = null;

switch (bobj.Type)
{
case ('NoteRest')
{
switch (bobj.ArpeggioType)
{
case (ArpeggioTypeUp)
{
orientation = 1;
}
case (ArpeggioTypeDown)
{
orientation = -1;
}
}
if (bobj.ArpeggioBottomDy > bobj.ArpeggioTopDy)
{
// Arpeggio was manipulated to be upside down
orientation = -1 * orientation;
}
}
case ('ArpeggioLine')
{
if (bobj.StyleId != 'line.staff.arpeggio') {
// This means: Line style is line.staff.arpeggio.up or
// line.staff.arpeggio.down.
// Strangely, the line style does not really matter for the
// visual orientation of the arpeggio. As long as RhDy and
// and Dy properties are identical, arpeggios look the same,
// independant of the two line styles with arrowheads.
orientation = bobj.RhDy - bobj.Dy;
}
}
}

if (orientation = null)
{
libmei.AddAttribute(arpeg, 'arrow', 'false');
}
else
{
libmei.AddAttribute(arpeg, 'arrow', 'true');

if (orientation > 0)
{
libmei.AddAttribute(arpeg, 'order', 'up');
}
else
{
libmei.AddAttribute(arpeg, 'order', 'down');
}
}

arpeg = AddBarObjectInfoToElement(bobj, arpeg);

return arpeg;
} //$end


function GenerateTrill (bobj) {
//$module(ExportGenerators.mss)
/* There are two types of trills in Sibelius: A line object and a
Expand Down Expand Up @@ -1883,4 +1958,4 @@ function GenerateSmuflAltsym (glyphnum, glyphname) {
}

return '#' & symbolIds[glyphnum];
} //$end
} //$end
32 changes: 20 additions & 12 deletions src/ExportProcessors.mss
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ function ProcessScore () {
libmei.AddAttribute(mei, 'xmlns', 'http://www.music-encoding.org/ns/mei');
libmei.AddAttribute(mei, 'meiversion', '3.0.0');

header = sibmei2.GenerateMEIHeader();
header = GenerateMEIHeader();
libmei.AddChild(mei, header);

music = sibmei2.GenerateMEIMusic();
music = GenerateMEIMusic();
libmei.AddChild(mei, music);

} //$end
Expand Down Expand Up @@ -183,12 +183,12 @@ function ProcessLyric (lyricobj, objectPositions) {
syllables in an array until we reach the end of the word, and then
attach them to the notes.
*/

if (lyricobj.Text = '')
{
return null;
}

styleparts = MSplitString(lyricobj.StyleId, '.');
verse_id = styleparts[5];
verse_id_arr = MSplitString(verse_id, false);
Expand Down Expand Up @@ -256,11 +256,21 @@ function ProcessLyric (lyricobj, objectPositions) {

if (j = 0)
{
libmei.AddAttribute(sylel, 'wordpos', 'i'); // 'initial'

//add a wordpos only for partial words
if (lyric_word.Length > 1)
{
libmei.AddAttribute(sylel, 'con', 'd');
libmei.AddAttribute(sylel, 'wordpos', 'i'); // 'initial'

libmei.AddAttribute(sylel, 'con', 'd'); //dash syllable connector
}

//it is also possible, that an initial syllable has an underscore as an extender, if it is the only syllable of a word
if (lyric_word.Length = 1)
{
if (syl.NumNotes > 1)
{
libmei.AddAttribute(sylel, 'con', 'u'); // 'underscore'
}
}
}
else
Expand All @@ -282,12 +292,10 @@ function ProcessLyric (lyricobj, objectPositions) {
}
}

syltext = libmei.GetText(sylel);

if (utils.Pos('_', syltext) > -1)
if (utils.Pos('_', syl.Text) > -1)
{
// Syllable elision. split this syllable element by underscore.
syllables = MSplitString(syltext, '_');
syllables = MSplitString(syl.Text, '_');
sylarray = CreateSparseArray();

// reset the text of the first syllable element to the first half of the syllable.
Expand Down Expand Up @@ -479,7 +487,7 @@ function ProcessTremolo (bobj) {
Log('Fingered tremolo: ' & bobj.DoubleTremolos);
tremEl = libmei.FTrem();
libmei.AddAttribute(tremEl, 'slash', bobj.DoubleTremolos);
libmei.AddAttribute(tremEl, 'measperf')
libmei.AddAttribute(tremEl, 'measperf');

} //$end

Expand Down
3 changes: 1 addition & 2 deletions src/Utilities.mss
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ function rstrip (str) {

function Log (message) {
//$module(Utilities.mss)
result = Sibelius.AppendLineToFile(Self._property:Logfile, message, True);
Trace(Self._property:Logfile & ' ' & result);
Sibelius.AppendLineToFile(Self._property:Logfile, message, True);
} //$end

function NormalizedBeamProp (noteRest) {
Expand Down
1 change: 0 additions & 1 deletion test/GLOBALS.mss

This file was deleted.

Binary file removed test/Initialize.mss
Binary file not shown.
Binary file removed test/Run.mss
Binary file not shown.
31 changes: 31 additions & 0 deletions test/mocha/test-arpeggios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";

const assert = require('assert');
const xpath = require('fontoxpath');
const utils = require('./utils');

describe("Arpeggios", () => {
const mei = utils.getTestMeiDom('arpeggios.mei');

it("writes 3 arpeggios in each of the 3 measures", () => {
assert.strictEqual(xpath.evaluateXPath('//*:arpeg', mei).length, 9);
});
it("writes arpeggios with up arrow on beat 2 of each measure", () => {
const upArpeggiosOnBeat2 = xpath.evaluateXPath(
'//*:arpeg[@arrow="true"][@tstamp="2"][@order="up"]', mei
);
assert.strictEqual(upArpeggiosOnBeat2.length, 3);
});
it("writes arpeggios with down arrow on beat 3 of each measure", () => {
const downArpeggiosOnBeat3 = xpath.evaluateXPath(
'//*:arpeg[@arrow="true"][@tstamp="3"][@order="down"]', mei
);
assert.strictEqual(downArpeggiosOnBeat3.length, 3);
});
it("writes arrowless arpeggios on beat 4 of each measures", () => {
const arrowlessArpeggionsOnBeat4 = xpath.evaluateXPath(
'//*:arpeg[@arrow="false"][@tstamp="4"][not(@order)]', mei
)
assert.strictEqual(arrowlessArpeggionsOnBeat4.length, 3);
});
});
Loading

0 comments on commit 30e4608

Please sign in to comment.