abcjs 6.0.0-beta.36 → 6.0.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +11 -6
- package/RELEASE.md +25 -15
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic-min.js.LICENSE +2 -2
- package/dist/abcjs-basic.js +84 -52
- package/dist/abcjs-basic.js.map +1 -1
- package/dist/abcjs-plugin-min.js +2 -2
- package/dist/abcjs-plugin-min.js.LICENSE +2 -2
- package/index.js +23 -1
- package/license.js +1 -1
- package/package.json +1 -1
- package/plugin.js +23 -1
- package/src/api/abc_tunebook_svg.js +7 -5
- package/src/synth/create-synth.js +51 -10
- package/src/write/abc_engraver_controller.js +4 -4
- package/src/write/draw/draw.js +2 -2
- package/test.js +23 -0
- package/version.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**!
|
|
2
|
-
Copyright (c) 2009-
|
|
2
|
+
Copyright (c) 2009-2022 Paul Rosen and Gregory Dyke
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,5 +19,5 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
19
19
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
20
|
THE SOFTWARE.
|
|
21
21
|
|
|
22
|
-
**This text is from: http://opensource.org/licenses/MIT**
|
|
22
|
+
**This text is from: http://opensource.org/licenses/MIT**
|
|
23
23
|
!**/
|
package/index.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/**!
|
|
2
|
+
Copyright (c) 2009-2022 Paul Rosen and Gregory Dyke
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
**This text is from: http://opensource.org/licenses/MIT**
|
|
23
|
+
!**/
|
|
2
24
|
var version = require('./version');
|
|
3
25
|
var animation = require('./src/api/abc_animation');
|
|
4
26
|
var tuneBook = require('./src/api/abc_tunebook');
|
package/license.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**!
|
|
2
|
-
Copyright (c) 2009-
|
|
2
|
+
Copyright (c) 2009-2022 Paul Rosen and Gregory Dyke
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/**!
|
|
2
|
+
Copyright (c) 2009-2022 Paul Rosen and Gregory Dyke
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
**This text is from: http://opensource.org/licenses/MIT**
|
|
23
|
+
!**/
|
|
2
24
|
// abc_plugin.js: Find everything which looks like abc and convert it
|
|
3
25
|
|
|
4
26
|
/*global abcjs_is_user_script, abcjs_plugin_autostart */
|
|
@@ -28,7 +28,7 @@ try {
|
|
|
28
28
|
// if we aren't in a browser, this code will crash, but it is not needed then either.
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function renderOne(div, tune, params, tuneNumber) {
|
|
31
|
+
function renderOne(div, tune, params, tuneNumber, lineOffset) {
|
|
32
32
|
if (params.viewportHorizontal) {
|
|
33
33
|
// Create an inner div that holds the music, so that the passed in div will be the viewport.
|
|
34
34
|
div.innerHTML = '<div class="abcjs-inner"></div>';
|
|
@@ -50,7 +50,7 @@ function renderOne(div, tune, params, tuneNumber) {
|
|
|
50
50
|
else
|
|
51
51
|
div.innerHTML = "";
|
|
52
52
|
var engraver_controller = new EngraverController(div, params);
|
|
53
|
-
engraver_controller.engraveABC(tune, tuneNumber);
|
|
53
|
+
engraver_controller.engraveABC(tune, tuneNumber, lineOffset);
|
|
54
54
|
tune.engraver = engraver_controller;
|
|
55
55
|
if (params.viewportVertical || params.viewportHorizontal) {
|
|
56
56
|
// If we added a wrapper around the div, then we need to size the wrapper, too.
|
|
@@ -113,6 +113,7 @@ function renderEachLineSeparately(div, tune, params, tuneNumber) {
|
|
|
113
113
|
var currentScrollY = div.parentNode.scrollTop; // If there is scrolling it will be lost during the redraw so remember it.
|
|
114
114
|
var currentScrollX = div.parentNode.scrollLeft;
|
|
115
115
|
div.innerHTML = "";
|
|
116
|
+
var lineCount = 0;
|
|
116
117
|
for (var k = 0; k < tunes.length; k++) {
|
|
117
118
|
var lineEl = document.createElement("div");
|
|
118
119
|
div.appendChild(lineEl);
|
|
@@ -132,7 +133,8 @@ function renderEachLineSeparately(div, tune, params, tuneNumber) {
|
|
|
132
133
|
tunes[k].formatting = parseCommon.clone(tunes[k].formatting);
|
|
133
134
|
tunes[k].formatting.stretchlast = true;
|
|
134
135
|
}
|
|
135
|
-
renderOne(lineEl, tunes[k], ep, tuneNumber);
|
|
136
|
+
renderOne(lineEl, tunes[k], ep, tuneNumber, lineCount);
|
|
137
|
+
lineCount += tunes[k].lines.length;
|
|
136
138
|
if (k === 0)
|
|
137
139
|
tune.engraver = tunes[k].engraver;
|
|
138
140
|
else {
|
|
@@ -213,7 +215,7 @@ var renderAbc = function(output, abc, parserParams, engraverParams, renderParams
|
|
|
213
215
|
return tune;
|
|
214
216
|
}
|
|
215
217
|
else if (removeDiv || !params.oneSvgPerLine || tune.lines.length < 2)
|
|
216
|
-
renderOne(div, tune, params, tuneNumber);
|
|
218
|
+
renderOne(div, tune, params, tuneNumber, 0);
|
|
217
219
|
else
|
|
218
220
|
renderEachLineSeparately(div, tune, params, tuneNumber);
|
|
219
221
|
if (removeDiv)
|
|
@@ -238,7 +240,7 @@ function doLineWrapping(div, tune, tuneNumber, abcString, params) {
|
|
|
238
240
|
tune.warnings = warnings;
|
|
239
241
|
}
|
|
240
242
|
if (!params.oneSvgPerLine || tune.lines.length < 2)
|
|
241
|
-
renderOne(div, tune, ret.revisedParams, tuneNumber);
|
|
243
|
+
renderOne(div, tune, ret.revisedParams, tuneNumber, 0);
|
|
242
244
|
else
|
|
243
245
|
renderEachLineSeparately(div, tune, ret.revisedParams, tuneNumber);
|
|
244
246
|
tune.explanation = ret.explanation;
|
|
@@ -12,10 +12,10 @@ var soundsCache = require('./sounds-cache');
|
|
|
12
12
|
// TODO-PER: remove the midi tests from here: I don't think the object can be constructed unless it passes.
|
|
13
13
|
var notSupportedMessage = "MIDI is not supported in this browser.";
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var originalSoundFontUrl = "https://paulrosen.github.io/midi-js-soundfonts/abcjs/";
|
|
16
16
|
// These are the original soundfonts supplied. They will need a volume boost:
|
|
17
|
-
var
|
|
18
|
-
var
|
|
17
|
+
var defaultSoundFontUrl = "https://paulrosen.github.io/midi-js-soundfonts/FluidR3_GM/";
|
|
18
|
+
var alternateSoundFontUrl = "https://paulrosen.github.io/midi-js-soundfonts/MusyngKite/";
|
|
19
19
|
|
|
20
20
|
function CreateSynth() {
|
|
21
21
|
var self = this;
|
|
@@ -45,18 +45,59 @@ function CreateSynth() {
|
|
|
45
45
|
self.soundFontUrl += '/';
|
|
46
46
|
if (params.soundFontVolumeMultiplier || params.soundFontVolumeMultiplier === 0)
|
|
47
47
|
self.soundFontVolumeMultiplier = params.soundFontVolumeMultiplier;
|
|
48
|
-
else if (self.soundFontUrl ===
|
|
49
|
-
self.soundFontVolumeMultiplier =
|
|
50
|
-
else if (self.soundFontUrl ===
|
|
51
|
-
self.soundFontVolumeMultiplier = 0.
|
|
48
|
+
else if (self.soundFontUrl === defaultSoundFontUrl || self.soundFontUrl === alternateSoundFontUrl)
|
|
49
|
+
self.soundFontVolumeMultiplier = 3.0;
|
|
50
|
+
else if (self.soundFontUrl === originalSoundFontUrl)
|
|
51
|
+
self.soundFontVolumeMultiplier = 0.4;
|
|
52
52
|
else
|
|
53
53
|
self.soundFontVolumeMultiplier = 1.0;
|
|
54
54
|
if (params.programOffsets)
|
|
55
55
|
self.programOffsets = params.programOffsets;
|
|
56
|
-
else if (self.soundFontUrl ===
|
|
56
|
+
else if (self.soundFontUrl === originalSoundFontUrl)
|
|
57
57
|
self.programOffsets = {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
58
|
+
"bright_acoustic_piano": 20,
|
|
59
|
+
"honkytonk_piano": 20,
|
|
60
|
+
"electric_piano_1": 30,
|
|
61
|
+
"electric_piano_2": 30,
|
|
62
|
+
"harpsichord": 40,
|
|
63
|
+
"clavinet": 20,
|
|
64
|
+
"celesta": 20,
|
|
65
|
+
"glockenspiel": 40,
|
|
66
|
+
"vibraphone": 30,
|
|
67
|
+
"marimba": 35,
|
|
68
|
+
"xylophone": 30,
|
|
69
|
+
"tubular_bells": 35,
|
|
70
|
+
"dulcimer": 30,
|
|
71
|
+
"drawbar_organ": 20,
|
|
72
|
+
"percussive_organ": 25,
|
|
73
|
+
"rock_organ": 20,
|
|
74
|
+
"church_organ": 40,
|
|
75
|
+
"reed_organ": 40,
|
|
76
|
+
"accordion": 40,
|
|
77
|
+
"harmonica": 40,
|
|
78
|
+
"acoustic_guitar_nylon": 20,
|
|
79
|
+
"acoustic_guitar_steel": 30,
|
|
80
|
+
"electric_guitar_jazz": 25,
|
|
81
|
+
"electric_guitar_clean": 15,
|
|
82
|
+
"electric_guitar_muted": 35,
|
|
83
|
+
"overdriven_guitar": 25,
|
|
84
|
+
"distortion_guitar": 20,
|
|
85
|
+
"guitar_harmonics": 30,
|
|
86
|
+
"electric_bass_finger": 15,
|
|
87
|
+
"electric_bass_pick": 30,
|
|
88
|
+
"fretless_bass": 40,
|
|
89
|
+
"violin": 105,
|
|
90
|
+
"viola": 50,
|
|
91
|
+
"cello": 40,
|
|
92
|
+
"contrabass": 60,
|
|
93
|
+
"trumpet": 10,
|
|
94
|
+
"trombone": 90,
|
|
95
|
+
"alto_sax": 20,
|
|
96
|
+
"tenor_sax": 20,
|
|
97
|
+
"clarinet": 20,
|
|
98
|
+
"flute": 50,
|
|
99
|
+
"banjo": 50,
|
|
100
|
+
"woodblock": 20,
|
|
60
101
|
};
|
|
61
102
|
else
|
|
62
103
|
self.programOffsets = {};
|
|
@@ -88,7 +88,7 @@ EngraverController.prototype.reset = function() {
|
|
|
88
88
|
/**
|
|
89
89
|
* run the engraving process
|
|
90
90
|
*/
|
|
91
|
-
EngraverController.prototype.engraveABC = function(abctunes, tuneNumber) {
|
|
91
|
+
EngraverController.prototype.engraveABC = function(abctunes, tuneNumber, lineOffset) {
|
|
92
92
|
if (abctunes[0]===undefined) {
|
|
93
93
|
abctunes = [abctunes];
|
|
94
94
|
}
|
|
@@ -99,7 +99,7 @@ EngraverController.prototype.engraveABC = function(abctunes, tuneNumber) {
|
|
|
99
99
|
tuneNumber = i;
|
|
100
100
|
this.getFontAndAttr = new GetFontAndAttr(abctunes[i].formatting, this.classes);
|
|
101
101
|
this.getTextSize = new GetTextSize(this.getFontAndAttr, this.renderer.paper);
|
|
102
|
-
this.engraveTune(abctunes[i], tuneNumber);
|
|
102
|
+
this.engraveTune(abctunes[i], tuneNumber, lineOffset);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
@@ -227,7 +227,7 @@ EngraverController.prototype.constructTuneElements = function (abcTune) {
|
|
|
227
227
|
abcTune.bottomText = new BottomText(abcTune.metaText, this.width, this.renderer.isPrint, this.renderer.padding.left, this.renderer.spacing, this.getTextSize);
|
|
228
228
|
};
|
|
229
229
|
|
|
230
|
-
EngraverController.prototype.engraveTune = function (abcTune, tuneNumber) {
|
|
230
|
+
EngraverController.prototype.engraveTune = function (abcTune, tuneNumber, lineOffset) {
|
|
231
231
|
var scale = this.setupTune(abcTune, tuneNumber);
|
|
232
232
|
|
|
233
233
|
// Create all of the element objects that will appear on the page.
|
|
@@ -242,7 +242,7 @@ EngraverController.prototype.engraveTune = function (abcTune, tuneNumber) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
// Do all the writing to the SVG
|
|
245
|
-
var ret = draw(this.renderer, this.classes, abcTune, this.width, maxWidth, this.responsive, scale, this.selectTypes, tuneNumber);
|
|
245
|
+
var ret = draw(this.renderer, this.classes, abcTune, this.width, maxWidth, this.responsive, scale, this.selectTypes, tuneNumber, lineOffset);
|
|
246
246
|
this.staffgroups = ret.staffgroups;
|
|
247
247
|
this.selectables = ret.selectables;
|
|
248
248
|
|
package/src/write/draw/draw.js
CHANGED
|
@@ -4,7 +4,7 @@ var nonMusic = require('./non-music');
|
|
|
4
4
|
var spacing = require('../abc_spacing');
|
|
5
5
|
var Selectables = require('./selectables');
|
|
6
6
|
|
|
7
|
-
function draw(renderer, classes, abcTune, width, maxWidth, responsive, scale, selectTypes, tuneNumber) {
|
|
7
|
+
function draw(renderer, classes, abcTune, width, maxWidth, responsive, scale, selectTypes, tuneNumber, lineOffset) {
|
|
8
8
|
var selectables = new Selectables(renderer.paper, selectTypes, tuneNumber);
|
|
9
9
|
renderer.moveY(renderer.padding.top);
|
|
10
10
|
nonMusic(renderer, abcTune.topText, selectables);
|
|
@@ -20,7 +20,7 @@ function draw(renderer, classes, abcTune, width, maxWidth, responsive, scale, se
|
|
|
20
20
|
if (staffgroups.length >= 1)
|
|
21
21
|
addStaffPadding(renderer, renderer.spacing.staffSeparation, staffgroups[staffgroups.length - 1], abcLine.staffGroup);
|
|
22
22
|
var staffgroup = engraveStaffLine(renderer, abcLine.staffGroup, selectables,line);
|
|
23
|
-
staffgroup.line = line; // If there are non-music lines then the staffgroup array won't line up with the line array, so this keeps track.
|
|
23
|
+
staffgroup.line = lineOffset+line; // If there are non-music lines then the staffgroup array won't line up with the line array, so this keeps track.
|
|
24
24
|
staffgroups.push(staffgroup);
|
|
25
25
|
} else if (abcLine.nonMusic) {
|
|
26
26
|
nonMusic(renderer, abcLine.nonMusic, selectables);
|
package/test.js
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**!
|
|
2
|
+
Copyright (c) 2009-2022 Paul Rosen and Gregory Dyke
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
**This text is from: http://opensource.org/licenses/MIT**
|
|
23
|
+
!**/
|
|
1
24
|
var abcjs = require('./index');
|
|
2
25
|
var version = require('./version');
|
|
3
26
|
var Parse = require('./src/parse/abc_parse');
|
package/version.js
CHANGED