notations 0.0.48 → 0.0.51
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/lib/cjs/beats.d.ts +36 -71
- package/lib/cjs/beats.js +225 -432
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/beatutils.d.ts +3 -0
- package/lib/cjs/beatutils.js +64 -0
- package/lib/cjs/beatutils.js.map +1 -0
- package/lib/cjs/beatview.d.ts +18 -0
- package/lib/cjs/beatview.js +62 -0
- package/lib/cjs/beatview.js.map +1 -0
- package/lib/cjs/carnatic/LineView.d.ts +2 -7
- package/lib/cjs/carnatic/LineView.js +13 -31
- package/lib/cjs/carnatic/LineView.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.d.ts +9 -7
- package/lib/cjs/carnatic/NotationView.js +90 -153
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/atomviews.js +149 -287
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.d.ts +18 -10
- package/lib/cjs/carnatic/beatviews.js +59 -91
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.d.ts +1 -1
- package/lib/cjs/carnatic/embelishments.js +189 -283
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/carnatic/gamakas.js +15 -47
- package/lib/cjs/carnatic/gamakas.js.map +1 -1
- package/lib/cjs/commands.js +111 -271
- package/lib/cjs/commands.js.map +1 -1
- package/lib/cjs/core.d.ts +6 -1
- package/lib/cjs/core.js +288 -493
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.js +175 -367
- package/lib/cjs/cycle.js.map +1 -1
- package/lib/cjs/entity.js +48 -102
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/grids.d.ts +124 -1
- package/lib/cjs/grids.js +546 -6
- package/lib/cjs/grids.js.map +1 -1
- package/lib/cjs/iterators.js +96 -234
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.d.ts +1 -1
- package/lib/cjs/layouts.js +62 -98
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.d.ts +2 -2
- package/lib/cjs/loader.js +23 -123
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.d.ts +0 -3
- package/lib/cjs/notation.js +139 -241
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/parser.d.ts +2 -0
- package/lib/cjs/parser.js +222 -219
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.js +149 -283
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.d.ts +8 -0
- package/lib/cjs/utils.js +60 -55
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/beats.d.ts +36 -71
- package/lib/esm/beats.js +218 -430
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/beatutils.d.ts +3 -0
- package/lib/esm/beatutils.js +37 -0
- package/lib/esm/beatutils.js.map +1 -0
- package/lib/esm/beatview.d.ts +18 -0
- package/lib/esm/beatview.js +35 -0
- package/lib/esm/beatview.js.map +1 -0
- package/lib/esm/carnatic/LineView.d.ts +2 -7
- package/lib/esm/carnatic/LineView.js +12 -31
- package/lib/esm/carnatic/LineView.js.map +1 -1
- package/lib/esm/carnatic/NotationView.d.ts +9 -7
- package/lib/esm/carnatic/NotationView.js +88 -152
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/carnatic/atomviews.js +144 -284
- package/lib/esm/carnatic/atomviews.js.map +1 -1
- package/lib/esm/carnatic/beatviews.d.ts +18 -10
- package/lib/esm/carnatic/beatviews.js +53 -87
- package/lib/esm/carnatic/beatviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.d.ts +1 -1
- package/lib/esm/carnatic/embelishments.js +187 -296
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/carnatic/gamakas.js +14 -48
- package/lib/esm/carnatic/gamakas.js.map +1 -1
- package/lib/esm/commands.js +100 -271
- package/lib/esm/commands.js.map +1 -1
- package/lib/esm/core.d.ts +6 -1
- package/lib/esm/core.js +286 -502
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/cycle.js +172 -367
- package/lib/esm/cycle.js.map +1 -1
- package/lib/esm/entity.js +48 -104
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/grids.d.ts +124 -1
- package/lib/esm/grids.js +515 -5
- package/lib/esm/grids.js.map +1 -1
- package/lib/esm/iterators.js +93 -235
- package/lib/esm/iterators.js.map +1 -1
- package/lib/esm/layouts.d.ts +1 -1
- package/lib/esm/layouts.js +60 -97
- package/lib/esm/layouts.js.map +1 -1
- package/lib/esm/loader.d.ts +2 -2
- package/lib/esm/loader.js +20 -120
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.d.ts +0 -3
- package/lib/esm/notation.js +135 -242
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/parser.d.ts +2 -0
- package/lib/esm/parser.js +216 -214
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.js +148 -288
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/utils.d.ts +8 -0
- package/lib/esm/utils.js +55 -51
- package/lib/esm/utils.js.map +1 -1
- package/package.json +2 -1
package/lib/esm/core.js
CHANGED
|
@@ -1,69 +1,7 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
28
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
29
|
-
if (!m) return o;
|
|
30
|
-
var i = m.call(o), r, ar = [], e;
|
|
31
|
-
try {
|
|
32
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
33
|
-
}
|
|
34
|
-
catch (error) { e = { error: error }; }
|
|
35
|
-
finally {
|
|
36
|
-
try {
|
|
37
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
38
|
-
}
|
|
39
|
-
finally { if (e) throw e.error; }
|
|
40
|
-
}
|
|
41
|
-
return ar;
|
|
42
|
-
};
|
|
43
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
44
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
45
|
-
if (ar || !(i in from)) {
|
|
46
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
47
|
-
ar[i] = from[i];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
51
|
-
};
|
|
52
|
-
var __values = (this && this.__values) || function(o) {
|
|
53
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
54
|
-
if (m) return m.call(o);
|
|
55
|
-
if (o && typeof o.length === "number") return {
|
|
56
|
-
next: function () {
|
|
57
|
-
if (o && i >= o.length) o = void 0;
|
|
58
|
-
return { value: o && o[i++], done: !o };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
62
|
-
};
|
|
63
1
|
import * as TSU from "@panyam/tsutils";
|
|
64
2
|
import { Entity, TimedEntity } from "./entity";
|
|
65
|
-
|
|
66
|
-
|
|
3
|
+
const ZERO = TSU.Num.Fraction.ZERO;
|
|
4
|
+
const ONE = TSU.Num.Fraction.ONE;
|
|
67
5
|
export var AtomType;
|
|
68
6
|
(function (AtomType) {
|
|
69
7
|
AtomType["NOTE"] = "Note";
|
|
@@ -75,289 +13,237 @@ export var AtomType;
|
|
|
75
13
|
AtomType["REST"] = "Rest";
|
|
76
14
|
AtomType["MARKER"] = "Marker";
|
|
77
15
|
})(AtomType || (AtomType = {}));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
Atom.prototype.debugValue = function () {
|
|
91
|
-
var out = _super.prototype.debugValue.call(this);
|
|
16
|
+
export class Atom extends TimedEntity {
|
|
17
|
+
constructor(duration = ONE) {
|
|
18
|
+
super();
|
|
19
|
+
this.nextSibling = null;
|
|
20
|
+
this.prevSibling = null;
|
|
21
|
+
this.parentGroup = null;
|
|
22
|
+
this.isContinuation = false;
|
|
23
|
+
this._duration = duration || ONE;
|
|
24
|
+
}
|
|
25
|
+
debugValue() {
|
|
26
|
+
const out = super.debugValue();
|
|
92
27
|
if (!this.duration.isOne) {
|
|
93
28
|
out.duration = this.duration.factorized.toString();
|
|
94
29
|
}
|
|
95
30
|
if (this.isContinuation) {
|
|
96
31
|
out.isContinuation = true;
|
|
97
32
|
}
|
|
33
|
+
if ((this.markersBefore || []).length > 0) {
|
|
34
|
+
out.mbef = this.markersBefore.map((m) => m.debugValue());
|
|
35
|
+
}
|
|
36
|
+
if ((this.markersAfter || []).length > 0) {
|
|
37
|
+
out.maft = this.markersAfter.map((m) => m.debugValue());
|
|
38
|
+
}
|
|
98
39
|
return out;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
40
|
+
}
|
|
41
|
+
copyTo(another) {
|
|
42
|
+
super.copyTo(another);
|
|
102
43
|
another._duration = new TSU.Num.Fraction(this.duration.num, this.duration.den);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
var LeafAtom = (function (_super) {
|
|
118
|
-
__extends(LeafAtom, _super);
|
|
119
|
-
function LeafAtom() {
|
|
120
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
121
|
-
_this.beforeRest = false;
|
|
122
|
-
return _this;
|
|
123
|
-
}
|
|
124
|
-
LeafAtom.prototype.splitAt = function (duration) {
|
|
44
|
+
}
|
|
45
|
+
get duration() {
|
|
46
|
+
return this._duration;
|
|
47
|
+
}
|
|
48
|
+
set duration(d) {
|
|
49
|
+
this._duration = d;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class LeafAtom extends Atom {
|
|
53
|
+
constructor() {
|
|
54
|
+
super(...arguments);
|
|
55
|
+
this.beforeRest = false;
|
|
56
|
+
}
|
|
57
|
+
splitAt(duration) {
|
|
125
58
|
if (this.duration.cmp(duration) > 0) {
|
|
126
|
-
|
|
59
|
+
const spillOver = this.createSpilloverSpace(this.duration.minus(duration));
|
|
127
60
|
spillOver.isContinuation = true;
|
|
128
61
|
this.duration = duration;
|
|
129
62
|
return spillOver;
|
|
130
63
|
}
|
|
131
64
|
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
65
|
+
}
|
|
66
|
+
createSpilloverSpace(duration) {
|
|
134
67
|
return new Space(duration);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return this.beforeRest ?
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (isSilent === void 0) { isSilent = false; }
|
|
173
|
-
var _this = _super.call(this, duration) || this;
|
|
174
|
-
_this.isSilent = false;
|
|
175
|
-
_this.isSilent = isSilent;
|
|
176
|
-
return _this;
|
|
177
|
-
}
|
|
178
|
-
Space.prototype.debugValue = function () {
|
|
179
|
-
return __assign(__assign({}, _super.prototype.debugValue.call(this)), { isSilent: this.isSilent });
|
|
180
|
-
};
|
|
181
|
-
Space.prototype.toString = function () {
|
|
182
|
-
return "Space(".concat(this.duration, "-").concat(this.isSilent, ")");
|
|
183
|
-
};
|
|
184
|
-
Space.prototype.copyTo = function (another) {
|
|
185
|
-
_super.prototype.copyTo.call(this, another);
|
|
68
|
+
}
|
|
69
|
+
debugValue() {
|
|
70
|
+
return this.beforeRest ? Object.assign(Object.assign({}, super.debugValue()), { beforeRest: true }) : super.debugValue();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class Marker extends Entity {
|
|
74
|
+
constructor(text, isBefore = true) {
|
|
75
|
+
super();
|
|
76
|
+
this.text = text;
|
|
77
|
+
this.isBefore = isBefore;
|
|
78
|
+
}
|
|
79
|
+
debugValue() {
|
|
80
|
+
return Object.assign(Object.assign({}, super.debugValue()), { text: this.text, before: this.isBefore });
|
|
81
|
+
}
|
|
82
|
+
toString() {
|
|
83
|
+
return `Marker(${this.text}-${this.isBefore})`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export class Rest extends LeafAtom {
|
|
87
|
+
constructor() {
|
|
88
|
+
super(ZERO);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export class Space extends LeafAtom {
|
|
92
|
+
constructor(duration = ONE, isSilent = false) {
|
|
93
|
+
super(duration);
|
|
94
|
+
this.isSilent = false;
|
|
95
|
+
this.isSilent = isSilent;
|
|
96
|
+
}
|
|
97
|
+
debugValue() {
|
|
98
|
+
return Object.assign(Object.assign({}, super.debugValue()), { isSilent: this.isSilent });
|
|
99
|
+
}
|
|
100
|
+
toString() {
|
|
101
|
+
return `Space(${this.duration}-${this.isSilent})`;
|
|
102
|
+
}
|
|
103
|
+
copyTo(another) {
|
|
104
|
+
super.copyTo(another);
|
|
186
105
|
another.isSilent = this.isSilent;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
106
|
+
}
|
|
107
|
+
equals(another) {
|
|
108
|
+
return super.equals(another) && this.isSilent == another.isSilent;
|
|
109
|
+
}
|
|
110
|
+
createSpilloverSpace(duration) {
|
|
111
|
+
const out = super.createSpilloverSpace(duration);
|
|
193
112
|
out.isSilent = this.isSilent;
|
|
194
113
|
return out;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
_this.embelishments = [];
|
|
206
|
-
return _this;
|
|
207
|
-
}
|
|
208
|
-
Literal.prototype.debugValue = function () {
|
|
209
|
-
var out = __assign(__assign({}, _super.prototype.debugValue.call(this)), { value: this.value });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export class Literal extends LeafAtom {
|
|
117
|
+
constructor(value, duration = ONE) {
|
|
118
|
+
super(duration);
|
|
119
|
+
this.value = value;
|
|
120
|
+
this.embelishments = [];
|
|
121
|
+
}
|
|
122
|
+
debugValue() {
|
|
123
|
+
const out = Object.assign(Object.assign({}, super.debugValue()), { value: this.value });
|
|
210
124
|
if (this.embelishments.length > 0) {
|
|
211
|
-
out.embs = this.embelishments.map(
|
|
125
|
+
out.embs = this.embelishments.map((e) => ("debugValue" in e ? e.debugValue() : e));
|
|
212
126
|
}
|
|
213
127
|
return out;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
128
|
+
}
|
|
129
|
+
toString() {
|
|
130
|
+
return `Lit(${this.duration}-${this.value})`;
|
|
131
|
+
}
|
|
132
|
+
equals(another) {
|
|
133
|
+
return super.equals(another) && this.value == another.value;
|
|
134
|
+
}
|
|
135
|
+
copyTo(another) {
|
|
136
|
+
super.copyTo(another);
|
|
223
137
|
another.value = this.value;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
var Syllable = (function (_super) {
|
|
229
|
-
__extends(Syllable, _super);
|
|
230
|
-
function Syllable() {
|
|
231
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
232
|
-
}
|
|
233
|
-
Syllable.fromLit = function (lit) {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export class Syllable extends Literal {
|
|
141
|
+
static fromLit(lit) {
|
|
234
142
|
if (lit.type == AtomType.SYLLABLE)
|
|
235
143
|
return lit;
|
|
236
|
-
|
|
144
|
+
const out = new Syllable(lit.value, lit.duration);
|
|
237
145
|
out.embelishments = lit.embelishments;
|
|
238
146
|
out.beforeRest = lit.beforeRest;
|
|
239
147
|
return out;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
_this.octave = 0;
|
|
255
|
-
_this.shift = 0;
|
|
256
|
-
_this.octave = octave;
|
|
257
|
-
_this.shift = shift;
|
|
258
|
-
return _this;
|
|
259
|
-
}
|
|
260
|
-
Note.fromLit = function (lit) {
|
|
148
|
+
}
|
|
149
|
+
toString() {
|
|
150
|
+
return `Syll(${this.duration}-${this.value})`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export class Note extends Literal {
|
|
154
|
+
constructor(value, duration = ONE, octave = 0, shift = 0) {
|
|
155
|
+
super(value, duration);
|
|
156
|
+
this.octave = 0;
|
|
157
|
+
this.shift = 0;
|
|
158
|
+
this.octave = octave;
|
|
159
|
+
this.shift = shift;
|
|
160
|
+
}
|
|
161
|
+
static fromLit(lit) {
|
|
261
162
|
if (lit.type == AtomType.NOTE)
|
|
262
163
|
return lit;
|
|
263
|
-
|
|
164
|
+
const out = new Note(lit.value, lit.duration);
|
|
264
165
|
out.embelishments = lit.embelishments;
|
|
265
166
|
out.beforeRest = lit.beforeRest;
|
|
266
167
|
return out;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
168
|
+
}
|
|
169
|
+
debugValue() {
|
|
170
|
+
const out = Object.assign({}, super.debugValue());
|
|
270
171
|
if (this.octave != 0)
|
|
271
172
|
out.octave = this.octave;
|
|
272
173
|
if (this.shift != 0)
|
|
273
174
|
out.shift = this.shift;
|
|
274
175
|
return out;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
176
|
+
}
|
|
177
|
+
toString() {
|
|
178
|
+
return `Note(${this.duration}-${this.value}-${this.octave})`;
|
|
179
|
+
}
|
|
180
|
+
equals(another) {
|
|
181
|
+
return super.equals(another) && this.octave == another.octave && this.shift == another.shift;
|
|
182
|
+
}
|
|
183
|
+
copyTo(another) {
|
|
184
|
+
super.copyTo(another);
|
|
284
185
|
another.octave = this.octave;
|
|
285
186
|
another.shift = this.shift;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var _this = _super.call(this, atoms.length == 0 ? ZERO : ONE) || this;
|
|
298
|
-
_this.durationIsMultiplier = false;
|
|
299
|
-
_this.atoms = new TSU.Lists.ValueList();
|
|
300
|
-
_this.addAtoms.apply(_this, __spreadArray([false], __read(atoms), false));
|
|
301
|
-
return _this;
|
|
302
|
-
}
|
|
303
|
-
Group.prototype.equals = function (another, expect) {
|
|
304
|
-
if (expect === void 0) { expect = false; }
|
|
305
|
-
if (!_super.prototype.equals.call(this, another))
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
export class Group extends Atom {
|
|
190
|
+
constructor(...atoms) {
|
|
191
|
+
super(atoms.length == 0 ? ZERO : ONE);
|
|
192
|
+
this.durationIsMultiplier = false;
|
|
193
|
+
this.atoms = new TSU.Lists.ValueList();
|
|
194
|
+
this.addAtoms(false, ...atoms);
|
|
195
|
+
}
|
|
196
|
+
equals(another, expect = false) {
|
|
197
|
+
if (!super.equals(another))
|
|
306
198
|
return false;
|
|
307
|
-
return this.atoms.equals(another.atoms,
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
199
|
+
return this.atoms.equals(another.atoms, (a1, a2) => a1.equals(a2));
|
|
200
|
+
}
|
|
201
|
+
copyTo(another) {
|
|
202
|
+
super.copyTo(another);
|
|
311
203
|
another.durationIsMultiplier = this.durationIsMultiplier;
|
|
312
|
-
this.atoms.forEach(
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
enumerable: false,
|
|
324
|
-
configurable: true
|
|
325
|
-
});
|
|
326
|
-
Group.prototype.setDurationAsMultiplier = function (asMultiplier) {
|
|
327
|
-
if (asMultiplier === void 0) { asMultiplier = true; }
|
|
204
|
+
this.atoms.forEach((atom) => another.atoms.add(atom.clone()));
|
|
205
|
+
}
|
|
206
|
+
get duration() {
|
|
207
|
+
if (this.durationIsMultiplier) {
|
|
208
|
+
return this.totalChildDuration.divby(this._duration);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return this._duration;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
setDurationAsMultiplier(asMultiplier = true) {
|
|
328
215
|
this.durationIsMultiplier = asMultiplier;
|
|
329
216
|
return this;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (asMultiplier === void 0) { asMultiplier = false; }
|
|
217
|
+
}
|
|
218
|
+
setDuration(d, asMultiplier = false) {
|
|
333
219
|
this._duration = d;
|
|
334
220
|
this.durationIsMultiplier = asMultiplier;
|
|
335
221
|
return this;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
222
|
+
}
|
|
223
|
+
debugValue() {
|
|
224
|
+
const out = Object.assign(Object.assign({}, super.debugValue()), { atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) });
|
|
339
225
|
if (this.durationIsMultiplier)
|
|
340
226
|
out.durationIsMultiplier = true;
|
|
341
227
|
return out;
|
|
342
|
-
}
|
|
343
|
-
|
|
228
|
+
}
|
|
229
|
+
splitAt(requiredDuration) {
|
|
344
230
|
if (this.duration.isLTE(requiredDuration) || requiredDuration.isLTE(ZERO)) {
|
|
345
231
|
return null;
|
|
346
232
|
}
|
|
347
|
-
|
|
233
|
+
const targetGroup = new Group();
|
|
348
234
|
if (this.durationIsMultiplier) {
|
|
349
235
|
targetGroup.durationIsMultiplier = true;
|
|
350
236
|
targetGroup._duration = this._duration;
|
|
351
237
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
238
|
+
let remainingDur = this.duration;
|
|
239
|
+
const totalChildDuration = this.totalChildDuration;
|
|
240
|
+
const durationFactor = this.durationIsMultiplier
|
|
355
241
|
? ONE.divby(this._duration)
|
|
356
242
|
: this._duration.divby(totalChildDuration, true);
|
|
357
243
|
while (remainingDur.isGT(requiredDuration) && this.atoms.last) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
244
|
+
const lastChild = this.atoms.last;
|
|
245
|
+
const childDuration = lastChild.duration.times(durationFactor);
|
|
246
|
+
const newDuration = remainingDur.minus(childDuration);
|
|
361
247
|
if (newDuration.isGTE(requiredDuration)) {
|
|
362
248
|
this.removeAtoms(true, lastChild);
|
|
363
249
|
targetGroup.insertAtomsAt(targetGroup.atoms.first, true, lastChild);
|
|
@@ -366,8 +252,8 @@ var Group = (function (_super) {
|
|
|
366
252
|
}
|
|
367
253
|
}
|
|
368
254
|
else {
|
|
369
|
-
|
|
370
|
-
|
|
255
|
+
const newRequiredDur = requiredDuration.minus(newDuration, true).divby(durationFactor, true);
|
|
256
|
+
const spillOver = lastChild.splitAt(newRequiredDur);
|
|
371
257
|
if (spillOver == null) {
|
|
372
258
|
throw new Error("Spill over cannot be null here");
|
|
373
259
|
}
|
|
@@ -385,52 +271,32 @@ var Group = (function (_super) {
|
|
|
385
271
|
remainingDur = newDuration;
|
|
386
272
|
}
|
|
387
273
|
return targetGroup;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
enumerable: false,
|
|
396
|
-
configurable: true
|
|
397
|
-
});
|
|
398
|
-
Group.prototype.insertAtomsAt = function (beforeAtom, adjustDuration) {
|
|
399
|
-
var e_1, _a;
|
|
400
|
-
if (adjustDuration === void 0) { adjustDuration = false; }
|
|
401
|
-
var atoms = [];
|
|
402
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
403
|
-
atoms[_i - 2] = arguments[_i];
|
|
404
|
-
}
|
|
274
|
+
}
|
|
275
|
+
get totalChildDuration() {
|
|
276
|
+
let out = ZERO;
|
|
277
|
+
this.atoms.forEach((atom) => (out = out.plus(atom.duration)));
|
|
278
|
+
return out;
|
|
279
|
+
}
|
|
280
|
+
insertAtomsAt(beforeAtom, adjustDuration = false, ...atoms) {
|
|
405
281
|
adjustDuration = adjustDuration && !this.durationIsMultiplier;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
if (atom.parentGroup != this) {
|
|
412
|
-
throw new Error("Atom belongs to another parent. Remove it first");
|
|
413
|
-
}
|
|
414
|
-
atom.parentGroup.removeAtoms(false, atom);
|
|
415
|
-
}
|
|
416
|
-
if (atom.type == AtomType.REST) {
|
|
417
|
-
var last = this.atoms.last;
|
|
418
|
-
if (last && last.type != AtomType.GROUP && last.type != AtomType.LABEL) {
|
|
419
|
-
last.beforeRest = true;
|
|
420
|
-
}
|
|
282
|
+
const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;
|
|
283
|
+
for (const atom of atoms) {
|
|
284
|
+
if (atom.parentGroup != null) {
|
|
285
|
+
if (atom.parentGroup != this) {
|
|
286
|
+
throw new Error("Atom belongs to another parent. Remove it first");
|
|
421
287
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
288
|
+
atom.parentGroup.removeAtoms(false, atom);
|
|
289
|
+
}
|
|
290
|
+
if (atom.type == AtomType.REST) {
|
|
291
|
+
const last = this.atoms.last;
|
|
292
|
+
if (last && last.type != AtomType.GROUP && last.type != AtomType.LABEL) {
|
|
293
|
+
last.beforeRest = true;
|
|
425
294
|
}
|
|
426
295
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
try {
|
|
431
|
-
if (atoms_1_1 && !atoms_1_1.done && (_a = atoms_1.return)) _a.call(atoms_1);
|
|
296
|
+
else {
|
|
297
|
+
atom.parentGroup = this;
|
|
298
|
+
this.atoms.add(atom, beforeAtom);
|
|
432
299
|
}
|
|
433
|
-
finally { if (e_1) throw e_1.error; }
|
|
434
300
|
}
|
|
435
301
|
if (adjustDuration) {
|
|
436
302
|
if (this._duration.isZero) {
|
|
@@ -439,47 +305,26 @@ var Group = (function (_super) {
|
|
|
439
305
|
this._duration = this.totalChildDuration;
|
|
440
306
|
}
|
|
441
307
|
else {
|
|
442
|
-
|
|
308
|
+
const scaleFactor = this.totalChildDuration.divby(oldChildDuration);
|
|
443
309
|
this._duration = this._duration.times(scaleFactor, true);
|
|
444
310
|
}
|
|
445
311
|
}
|
|
446
312
|
return this;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
atoms[_i - 1] = arguments[_i];
|
|
453
|
-
}
|
|
454
|
-
return this.insertAtomsAt.apply(this, __spreadArray([null, adjustDuration], __read(atoms), false));
|
|
455
|
-
};
|
|
456
|
-
Group.prototype.removeAtoms = function (adjustDuration) {
|
|
457
|
-
var e_2, _a;
|
|
458
|
-
if (adjustDuration === void 0) { adjustDuration = false; }
|
|
459
|
-
var atoms = [];
|
|
460
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
461
|
-
atoms[_i - 1] = arguments[_i];
|
|
462
|
-
}
|
|
313
|
+
}
|
|
314
|
+
addAtoms(adjustDuration = false, ...atoms) {
|
|
315
|
+
return this.insertAtomsAt(null, adjustDuration, ...atoms);
|
|
316
|
+
}
|
|
317
|
+
removeAtoms(adjustDuration = false, ...atoms) {
|
|
463
318
|
adjustDuration = adjustDuration && !this.durationIsMultiplier;
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
this.atoms.remove(atom);
|
|
470
|
-
atom.parentGroup = null;
|
|
471
|
-
}
|
|
472
|
-
else if (atom.parentGroup != null) {
|
|
473
|
-
throw new Error("Atom cannot be removed as it does not belong to this group");
|
|
474
|
-
}
|
|
319
|
+
const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;
|
|
320
|
+
for (const atom of atoms) {
|
|
321
|
+
if (atom.parentGroup == this) {
|
|
322
|
+
this.atoms.remove(atom);
|
|
323
|
+
atom.parentGroup = null;
|
|
475
324
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
finally {
|
|
479
|
-
try {
|
|
480
|
-
if (atoms_2_1 && !atoms_2_1.done && (_a = atoms_2.return)) _a.call(atoms_2);
|
|
325
|
+
else if (atom.parentGroup != null) {
|
|
326
|
+
throw new Error("Atom cannot be removed as it does not belong to this group");
|
|
481
327
|
}
|
|
482
|
-
finally { if (e_2) throw e_2.error; }
|
|
483
328
|
}
|
|
484
329
|
if (adjustDuration) {
|
|
485
330
|
if (this._duration.isZero) {
|
|
@@ -488,161 +333,100 @@ var Group = (function (_super) {
|
|
|
488
333
|
this._duration = this.totalChildDuration;
|
|
489
334
|
}
|
|
490
335
|
else {
|
|
491
|
-
|
|
336
|
+
const scaleFactor = this.totalChildDuration.divby(oldChildDuration);
|
|
492
337
|
this._duration = this._duration.times(scaleFactor, true);
|
|
493
338
|
}
|
|
494
339
|
}
|
|
495
340
|
return this;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
finally {
|
|
521
|
-
try {
|
|
522
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
523
|
-
}
|
|
524
|
-
finally { if (e_3) throw e_3.error; }
|
|
525
|
-
}
|
|
526
|
-
return true;
|
|
527
|
-
},
|
|
528
|
-
enumerable: false,
|
|
529
|
-
configurable: true
|
|
530
|
-
});
|
|
531
|
-
Line.prototype.debugValue = function () {
|
|
532
|
-
var out = __assign(__assign({}, _super.prototype.debugValue.call(this)), { roles: this.roles.map(function (r) { return r.debugValue(); }) });
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
export class Line extends Entity {
|
|
344
|
+
constructor() {
|
|
345
|
+
super(...arguments);
|
|
346
|
+
this.offset = ZERO;
|
|
347
|
+
this.roles = [];
|
|
348
|
+
this.marginText = "";
|
|
349
|
+
}
|
|
350
|
+
indexOfRole(name) {
|
|
351
|
+
for (let i = 0; i < this.roles.length; i++) {
|
|
352
|
+
if (this.roles[i].name == name)
|
|
353
|
+
return i;
|
|
354
|
+
}
|
|
355
|
+
return -1;
|
|
356
|
+
}
|
|
357
|
+
get isEmpty() {
|
|
358
|
+
for (const r of this.roles)
|
|
359
|
+
if (!r.isEmpty)
|
|
360
|
+
return false;
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
debugValue() {
|
|
364
|
+
const out = Object.assign(Object.assign({}, super.debugValue()), { roles: this.roles.map((r) => r.debugValue()) });
|
|
533
365
|
if (!this.offset.isZero) {
|
|
534
366
|
out.offset = this.offset.toString();
|
|
535
367
|
}
|
|
536
368
|
return out;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
another.roles = this.roles.map(
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
atoms[_i - 2] = arguments[_i];
|
|
546
|
-
}
|
|
547
|
-
var role = this.ensureRole(roleName, defaultToNotes);
|
|
548
|
-
role.addAtoms.apply(role, __spreadArray([], __read(atoms), false));
|
|
369
|
+
}
|
|
370
|
+
copyTo(another) {
|
|
371
|
+
super.copyTo(another);
|
|
372
|
+
another.roles = this.roles.map((r) => r.clone());
|
|
373
|
+
}
|
|
374
|
+
addAtoms(roleName, defaultToNotes, ...atoms) {
|
|
375
|
+
const role = this.ensureRole(roleName, defaultToNotes);
|
|
376
|
+
role.addAtoms(...atoms);
|
|
549
377
|
return this;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
378
|
+
}
|
|
379
|
+
ensureRole(roleName, defaultToNotes) {
|
|
380
|
+
let ri = this.roles.findIndex((r) => r.name == roleName);
|
|
553
381
|
if (ri < 0) {
|
|
554
382
|
ri = this.roles.length;
|
|
555
|
-
|
|
383
|
+
const role = new Role(this, roleName);
|
|
556
384
|
role.defaultToNotes = defaultToNotes;
|
|
557
385
|
this.roles.push(role);
|
|
558
386
|
}
|
|
559
387
|
return this.roles[ri];
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
try {
|
|
566
|
-
for (var _b = __values(this.roles), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
567
|
-
var role = _c.value;
|
|
568
|
-
max = TSU.Num.Fraction.max(role.duration, max);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
572
|
-
finally {
|
|
573
|
-
try {
|
|
574
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
575
|
-
}
|
|
576
|
-
finally { if (e_4) throw e_4.error; }
|
|
577
|
-
}
|
|
578
|
-
return max;
|
|
579
|
-
},
|
|
580
|
-
enumerable: false,
|
|
581
|
-
configurable: true
|
|
582
|
-
});
|
|
583
|
-
return Line;
|
|
584
|
-
}(Entity));
|
|
585
|
-
export { Line };
|
|
586
|
-
var Role = (function (_super) {
|
|
587
|
-
__extends(Role, _super);
|
|
588
|
-
function Role(line, name) {
|
|
589
|
-
var _this = _super.call(this) || this;
|
|
590
|
-
_this.line = line;
|
|
591
|
-
_this.name = name;
|
|
592
|
-
_this.defaultToNotes = true;
|
|
593
|
-
_this.atoms = [];
|
|
594
|
-
return _this;
|
|
595
|
-
}
|
|
596
|
-
Object.defineProperty(Role.prototype, "isEmpty", {
|
|
597
|
-
get: function () {
|
|
598
|
-
return this.atoms.length == 0;
|
|
599
|
-
},
|
|
600
|
-
enumerable: false,
|
|
601
|
-
configurable: true
|
|
602
|
-
});
|
|
603
|
-
Role.prototype.debugValue = function () {
|
|
604
|
-
return { name: this.name, atoms: this.atoms.map(function (a) { return a.debugValue(); }) };
|
|
605
|
-
};
|
|
606
|
-
Role.prototype.addAtoms = function () {
|
|
607
|
-
var e_5, _a;
|
|
608
|
-
var atoms = [];
|
|
609
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
610
|
-
atoms[_i] = arguments[_i];
|
|
388
|
+
}
|
|
389
|
+
get duration() {
|
|
390
|
+
let max = ZERO;
|
|
391
|
+
for (const role of this.roles) {
|
|
392
|
+
max = TSU.Num.Fraction.max(role.duration, max);
|
|
611
393
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
394
|
+
return max;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
export class Role extends Entity {
|
|
398
|
+
constructor(line, name) {
|
|
399
|
+
super();
|
|
400
|
+
this.line = line;
|
|
401
|
+
this.name = name;
|
|
402
|
+
this.defaultToNotes = true;
|
|
403
|
+
this.atoms = [];
|
|
404
|
+
}
|
|
405
|
+
get isEmpty() {
|
|
406
|
+
return this.atoms.length == 0;
|
|
407
|
+
}
|
|
408
|
+
debugValue() {
|
|
409
|
+
return { name: this.name, atoms: this.atoms.map((a) => a.debugValue()) };
|
|
410
|
+
}
|
|
411
|
+
addAtoms(...atoms) {
|
|
412
|
+
let last = null;
|
|
413
|
+
for (const atom of atoms) {
|
|
414
|
+
if (atom.type == AtomType.REST) {
|
|
415
|
+
if (last && last.type != AtomType.GROUP && last.type != AtomType.LABEL) {
|
|
416
|
+
last.beforeRest = true;
|
|
623
417
|
}
|
|
624
|
-
last = atom;
|
|
625
418
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
finally {
|
|
629
|
-
try {
|
|
630
|
-
if (atoms_3_1 && !atoms_3_1.done && (_a = atoms_3.return)) _a.call(atoms_3);
|
|
419
|
+
else {
|
|
420
|
+
this.atoms.push(atom);
|
|
631
421
|
}
|
|
632
|
-
|
|
422
|
+
last = atom;
|
|
633
423
|
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
another.addAtoms
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
enumerable: false,
|
|
643
|
-
configurable: true
|
|
644
|
-
});
|
|
645
|
-
return Role;
|
|
646
|
-
}(Entity));
|
|
647
|
-
export { Role };
|
|
424
|
+
}
|
|
425
|
+
copyTo(another) {
|
|
426
|
+
another.addAtoms(...this.atoms);
|
|
427
|
+
}
|
|
428
|
+
get duration() {
|
|
429
|
+
return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
648
432
|
//# sourceMappingURL=core.js.map
|