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