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