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/beats.js
CHANGED
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
var __values = (this && this.__values) || function(o) {
|
|
2
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
-
if (m) return m.call(o);
|
|
4
|
-
if (o && typeof o.length === "number") return {
|
|
5
|
-
next: function () {
|
|
6
|
-
if (o && i >= o.length) o = void 0;
|
|
7
|
-
return { value: o && o[i++], done: !o };
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
-
if (ar || !(i in from)) {
|
|
31
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
-
ar[i] = from[i];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
-
};
|
|
37
1
|
import * as TSU from "@panyam/tsutils";
|
|
38
|
-
import { Group, Space } from "./";
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
2
|
+
import { AtomType, Group, Space } from "./";
|
|
3
|
+
import { WindowIterator } from "./iterators";
|
|
4
|
+
import { GridModel, GridCell, ColAlign, GridLayoutGroup } from "./grids";
|
|
5
|
+
const ZERO = TSU.Num.Fraction.ZERO;
|
|
6
|
+
const ONE = TSU.Num.Fraction.ONE;
|
|
7
|
+
export class Beat {
|
|
8
|
+
constructor(index, role, offset, duration, barIndex, beatIndex, instance, prevBeat, nextBeat) {
|
|
44
9
|
this.index = index;
|
|
45
10
|
this.role = role;
|
|
46
11
|
this.offset = offset;
|
|
@@ -50,12 +15,10 @@ var Beat = (function () {
|
|
|
50
15
|
this.instance = instance;
|
|
51
16
|
this.prevBeat = prevBeat;
|
|
52
17
|
this.nextBeat = nextBeat;
|
|
53
|
-
this.layoutLine = -1;
|
|
54
|
-
this.layoutColumn = -1;
|
|
55
18
|
this.uuid = Beat.idCounter++;
|
|
56
19
|
this.atomIsPlaceholder = false;
|
|
57
20
|
}
|
|
58
|
-
|
|
21
|
+
debugValue() {
|
|
59
22
|
return {
|
|
60
23
|
index: this.index,
|
|
61
24
|
role: this.role.name,
|
|
@@ -66,29 +29,17 @@ var Beat = (function () {
|
|
|
66
29
|
instance: this.instance,
|
|
67
30
|
atom: this.atom.debugValue(),
|
|
68
31
|
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
enumerable: false,
|
|
82
|
-
configurable: true
|
|
83
|
-
});
|
|
84
|
-
Object.defineProperty(Beat.prototype, "remaining", {
|
|
85
|
-
get: function () {
|
|
86
|
-
return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;
|
|
87
|
-
},
|
|
88
|
-
enumerable: false,
|
|
89
|
-
configurable: true
|
|
90
|
-
});
|
|
91
|
-
Beat.prototype.add = function (atom) {
|
|
32
|
+
}
|
|
33
|
+
get endOffset() {
|
|
34
|
+
return this.offset.plus(this.duration);
|
|
35
|
+
}
|
|
36
|
+
get filled() {
|
|
37
|
+
return this.remaining.isZero;
|
|
38
|
+
}
|
|
39
|
+
get remaining() {
|
|
40
|
+
return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;
|
|
41
|
+
}
|
|
42
|
+
add(atom) {
|
|
92
43
|
if (this.remaining.cmp(atom.duration) < 0) {
|
|
93
44
|
return false;
|
|
94
45
|
}
|
|
@@ -103,353 +54,78 @@ var Beat = (function () {
|
|
|
103
54
|
this.atom.addAtoms(true, atom);
|
|
104
55
|
}
|
|
105
56
|
return true;
|
|
106
|
-
};
|
|
107
|
-
Beat.prototype.ensureUniformSpaces = function (atoms, slotsPerBeat) {
|
|
108
|
-
if (slotsPerBeat === void 0) { slotsPerBeat = 1; }
|
|
109
|
-
var lcm = 1;
|
|
110
|
-
var gcd = 0;
|
|
111
|
-
atoms.forEach(function (a, index) {
|
|
112
|
-
a.duration = a.duration.factorized;
|
|
113
|
-
var currDen = a.duration.den;
|
|
114
|
-
if (currDen != 1) {
|
|
115
|
-
lcm *= currDen;
|
|
116
|
-
if (gcd == 0) {
|
|
117
|
-
gcd = a.duration.den;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
gcd = TSU.Num.gcdof(gcd, currDen);
|
|
121
|
-
lcm /= gcd;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
var baseDur = new TSU.Num.Fraction(1, lcm);
|
|
126
|
-
var currOffset = this.offset;
|
|
127
|
-
for (var i = 0; i < atoms.length;) {
|
|
128
|
-
var fa = atoms[i];
|
|
129
|
-
var numSpaces = lcm == 1 ? fa.duration.num - 1 : lcm / fa.duration.den - 1;
|
|
130
|
-
fa.duration = baseDur;
|
|
131
|
-
currOffset = currOffset.plus(baseDur);
|
|
132
|
-
i++;
|
|
133
|
-
for (var j = 0; j < numSpaces; j++, i++) {
|
|
134
|
-
var space = new Space(baseDur);
|
|
135
|
-
space.isContinuation = true;
|
|
136
|
-
atoms.splice(i, 0, new FlatAtom(space));
|
|
137
|
-
atoms.splice(i, 0, new FlatAtom(space));
|
|
138
|
-
currOffset = currOffset.plus(baseDur);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
Beat.idCounter = 0;
|
|
143
|
-
return Beat;
|
|
144
|
-
}());
|
|
145
|
-
export { Beat };
|
|
146
|
-
var BeatLayout = (function () {
|
|
147
|
-
function BeatLayout(layoutParams) {
|
|
148
|
-
this.layoutParams = layoutParams;
|
|
149
|
-
this.bcolNextList = new Map();
|
|
150
|
-
this.beatColumns = new Map();
|
|
151
|
-
this.startingColumns = [];
|
|
152
|
-
this.columnForBeat = new Map();
|
|
153
|
-
this.DEBUG = false;
|
|
154
|
-
this.roleSpacing = 10;
|
|
155
|
-
this.rowSpacing = 15;
|
|
156
57
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.beatColumns.set(key, bcol);
|
|
164
|
-
if (bcol.offset.isZero) {
|
|
165
|
-
this.startingColumns.push(bcol);
|
|
58
|
+
get preMarkers() {
|
|
59
|
+
const out = [];
|
|
60
|
+
let curr = this.atom;
|
|
61
|
+
while (curr != null) {
|
|
62
|
+
for (const marker of curr.markersBefore || []) {
|
|
63
|
+
out.push(marker);
|
|
166
64
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
try {
|
|
170
|
-
for (var _b = __values(this.beatColumns.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
171
|
-
var other = _c.value;
|
|
172
|
-
if (other.offset.plus(other.duration).equals(offset)) {
|
|
173
|
-
this.addSuccessor(other, bcol);
|
|
174
|
-
}
|
|
175
|
-
else if (other.offset.equals(endOffset)) {
|
|
176
|
-
this.addSuccessor(bcol, other);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
181
|
-
finally {
|
|
182
|
-
try {
|
|
183
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
184
|
-
}
|
|
185
|
-
finally { if (e_1) throw e_1.error; }
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return bcol;
|
|
190
|
-
};
|
|
191
|
-
BeatLayout.keyFor = function (offset, duration) {
|
|
192
|
-
return offset.factorized.toString() + ":" + duration.factorized.toString();
|
|
193
|
-
};
|
|
194
|
-
BeatLayout.prototype.addSuccessor = function (prev, next) {
|
|
195
|
-
TSU.assert(prev.offset.plus(prev.duration).equals(next.offset), "BeatColumns are not adjacent to each other");
|
|
196
|
-
var prevKey = BeatLayout.keyFor(prev.offset, prev.duration);
|
|
197
|
-
var nextKey = BeatLayout.keyFor(next.offset, next.duration);
|
|
198
|
-
var nextset = this.bcolNextList.get(prevKey) || null;
|
|
199
|
-
if (!nextset) {
|
|
200
|
-
nextset = new Set();
|
|
201
|
-
this.bcolNextList.set(prevKey, nextset);
|
|
202
|
-
}
|
|
203
|
-
nextset.add(nextKey);
|
|
204
|
-
};
|
|
205
|
-
BeatLayout.prototype.addBeat = function (beat) {
|
|
206
|
-
var lp = this.layoutParams;
|
|
207
|
-
var _a = __read(lp.getBeatLocation(beat), 3), layoutLine = _a[0], layoutColumn = _a[1], rowOffset = _a[2];
|
|
208
|
-
var bcol = this.getBeatColumn(rowOffset, beat.duration);
|
|
209
|
-
bcol.add(beat);
|
|
210
|
-
this.columnForBeat.set(beat.uuid, bcol);
|
|
211
|
-
beat.layoutLine = layoutLine;
|
|
212
|
-
beat.layoutColumn = layoutColumn;
|
|
213
|
-
return bcol;
|
|
214
|
-
};
|
|
215
|
-
BeatLayout.prototype.neighborsOf = function (beatColumn) {
|
|
216
|
-
var e_2, _a;
|
|
217
|
-
var out = [];
|
|
218
|
-
var endOffset = beatColumn.offset.plus(beatColumn.duration);
|
|
219
|
-
try {
|
|
220
|
-
for (var _b = __values(this.beatColumns.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
221
|
-
var other = _c.value;
|
|
222
|
-
if (endOffset.equals(other.offset)) {
|
|
223
|
-
out.push(other);
|
|
224
|
-
}
|
|
65
|
+
if (curr.type == AtomType.GROUP) {
|
|
66
|
+
curr = curr.atoms.first;
|
|
225
67
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
finally {
|
|
229
|
-
try {
|
|
230
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
68
|
+
else {
|
|
69
|
+
curr = null;
|
|
231
70
|
}
|
|
232
|
-
finally { if (e_2) throw e_2.error; }
|
|
233
71
|
}
|
|
234
72
|
return out;
|
|
235
|
-
};
|
|
236
|
-
BeatLayout.prototype.evalColumnSizes = function (beatViewDelegate) {
|
|
237
|
-
var e_3, _a, e_4, _b;
|
|
238
|
-
var queue = __spreadArray([], __read(this.startingColumns), false);
|
|
239
|
-
var xForOffsets = {};
|
|
240
|
-
while (queue.length > 0) {
|
|
241
|
-
var nextQueue = [];
|
|
242
|
-
try {
|
|
243
|
-
for (var queue_1 = (e_3 = void 0, __values(queue)), queue_1_1 = queue_1.next(); !queue_1_1.done; queue_1_1 = queue_1.next()) {
|
|
244
|
-
var bcol = queue_1_1.value;
|
|
245
|
-
var offset = bcol.offset.factorized;
|
|
246
|
-
var colWidth = bcol.evalMaxWidth(beatViewDelegate);
|
|
247
|
-
var currX = 0;
|
|
248
|
-
if (!bcol.offset.isZero) {
|
|
249
|
-
TSU.assert(offset.toString() in xForOffsets, "Cannot find x for given offset");
|
|
250
|
-
currX = xForOffsets[offset.toString()];
|
|
251
|
-
}
|
|
252
|
-
bcol.setX(currX, beatViewDelegate);
|
|
253
|
-
var endOffset = offset.plus(bcol.duration, true);
|
|
254
|
-
xForOffsets[endOffset.toString()] = Math.max(xForOffsets[endOffset.toString()] || 0, currX + colWidth + bcol.paddingLeft + bcol.paddingRight);
|
|
255
|
-
try {
|
|
256
|
-
for (var _c = (e_4 = void 0, __values(this.beatColumns.values())), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
257
|
-
var other = _d.value;
|
|
258
|
-
if (endOffset.equals(other.offset)) {
|
|
259
|
-
nextQueue.push(other);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
264
|
-
finally {
|
|
265
|
-
try {
|
|
266
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
267
|
-
}
|
|
268
|
-
finally { if (e_4) throw e_4.error; }
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
273
|
-
finally {
|
|
274
|
-
try {
|
|
275
|
-
if (queue_1_1 && !queue_1_1.done && (_a = queue_1.return)) _a.call(queue_1);
|
|
276
|
-
}
|
|
277
|
-
finally { if (e_3) throw e_3.error; }
|
|
278
|
-
}
|
|
279
|
-
queue = nextQueue;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
BeatLayout.prototype.layoutBeatsForLine = function (line, allRoleBeats, beatViewDelegate) {
|
|
283
|
-
var lp = this.layoutParams;
|
|
284
|
-
var currBeats = line.roles.map(function (l, index) { return allRoleBeats[index][0]; });
|
|
285
|
-
var currY = this.roleSpacing;
|
|
286
|
-
var numDone = 0;
|
|
287
|
-
do {
|
|
288
|
-
numDone = 0;
|
|
289
|
-
for (var currRole = 0; currRole < currBeats.length; currRole++) {
|
|
290
|
-
var currBeat = currBeats[currRole];
|
|
291
|
-
if (currBeat) {
|
|
292
|
-
var temp = currBeat;
|
|
293
|
-
var numBeatsInRow = lp.lineBreaks[currBeat.layoutLine];
|
|
294
|
-
var maxHeight = 0;
|
|
295
|
-
var currX = 15;
|
|
296
|
-
for (var i = currBeat.layoutColumn; i < numBeatsInRow && currBeat; i++, currBeat = currBeat.nextBeat, numDone++) {
|
|
297
|
-
var beatView = beatViewDelegate.viewForBeat(currBeat);
|
|
298
|
-
beatView.y = currY;
|
|
299
|
-
if (this.DEBUG) {
|
|
300
|
-
beatView.x = currX;
|
|
301
|
-
beatView.refreshLayout();
|
|
302
|
-
currX += beatView.width;
|
|
303
|
-
}
|
|
304
|
-
maxHeight = Math.max(maxHeight, beatView.minSize.height);
|
|
305
|
-
}
|
|
306
|
-
currBeat = temp;
|
|
307
|
-
for (var i = currBeat.layoutColumn; i < numBeatsInRow && currBeat; i++, currBeat = currBeat.nextBeat, numDone++) {
|
|
308
|
-
var beatView = beatViewDelegate.viewForBeat(currBeat);
|
|
309
|
-
beatView.height = maxHeight;
|
|
310
|
-
}
|
|
311
|
-
currY += maxHeight;
|
|
312
|
-
currY += this.roleSpacing;
|
|
313
|
-
}
|
|
314
|
-
currBeats[currRole] = currBeat;
|
|
315
|
-
}
|
|
316
|
-
currY += this.rowSpacing;
|
|
317
|
-
} while (numDone > 0);
|
|
318
|
-
};
|
|
319
|
-
return BeatLayout;
|
|
320
|
-
}());
|
|
321
|
-
export { BeatLayout };
|
|
322
|
-
var BeatRow = (function () {
|
|
323
|
-
function BeatRow(layoutLine, rowIndex) {
|
|
324
|
-
this.layoutLine = layoutLine;
|
|
325
|
-
this.rowIndex = rowIndex;
|
|
326
|
-
this._y = 0;
|
|
327
|
-
this._maxHeight = 0;
|
|
328
|
-
this.needsLayout = false;
|
|
329
|
-
this.rowSpacing = 5;
|
|
330
|
-
this.beats = [];
|
|
331
|
-
}
|
|
332
|
-
Object.defineProperty(BeatRow.prototype, "y", {
|
|
333
|
-
get: function () {
|
|
334
|
-
return this._y;
|
|
335
|
-
},
|
|
336
|
-
set: function (val) {
|
|
337
|
-
this._y = val;
|
|
338
|
-
this.needsLayout = true;
|
|
339
|
-
},
|
|
340
|
-
enumerable: false,
|
|
341
|
-
configurable: true
|
|
342
|
-
});
|
|
343
|
-
BeatRow.prototype.add = function (beat) {
|
|
344
|
-
this.beats.push(beat);
|
|
345
|
-
this.needsLayout = true;
|
|
346
|
-
};
|
|
347
|
-
return BeatRow;
|
|
348
|
-
}());
|
|
349
|
-
export { BeatRow };
|
|
350
|
-
var BeatColumn = (function () {
|
|
351
|
-
function BeatColumn(offset, duration) {
|
|
352
|
-
this.offset = offset;
|
|
353
|
-
this.duration = duration;
|
|
354
|
-
this._x = 0;
|
|
355
|
-
this._maxWidth = 0;
|
|
356
|
-
this.needsLayout = false;
|
|
357
|
-
this.atomSpacing = 5;
|
|
358
|
-
this.paddingLeft = 15;
|
|
359
|
-
this.paddingRight = 15;
|
|
360
|
-
this.beats = [];
|
|
361
|
-
offset = offset.factorized;
|
|
362
|
-
duration = duration.factorized;
|
|
363
73
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
BeatColumn.prototype.setX = function (val, beatViewDelegate) {
|
|
372
|
-
var e_5, _a;
|
|
373
|
-
this._x = val;
|
|
374
|
-
try {
|
|
375
|
-
for (var _b = __values(this.beats), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
376
|
-
var beat = _c.value;
|
|
377
|
-
var beatView = beatViewDelegate.viewForBeat(beat);
|
|
378
|
-
beatView.x = val + this.paddingLeft;
|
|
379
|
-
beatView.width = this._maxWidth;
|
|
74
|
+
get postMarkers() {
|
|
75
|
+
const out = [];
|
|
76
|
+
let curr = this.atom;
|
|
77
|
+
while (curr != null) {
|
|
78
|
+
out.splice(0, 0, ...(curr.markersAfter || []));
|
|
79
|
+
if (curr.type == AtomType.GROUP) {
|
|
80
|
+
curr = curr.atoms.last;
|
|
380
81
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
finally {
|
|
384
|
-
try {
|
|
385
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
386
|
-
}
|
|
387
|
-
finally { if (e_5) throw e_5.error; }
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
Object.defineProperty(BeatColumn.prototype, "maxWidth", {
|
|
391
|
-
get: function () {
|
|
392
|
-
return this._maxWidth + this.paddingLeft + this.paddingRight;
|
|
393
|
-
},
|
|
394
|
-
enumerable: false,
|
|
395
|
-
configurable: true
|
|
396
|
-
});
|
|
397
|
-
BeatColumn.prototype.setPadding = function (left, right) {
|
|
398
|
-
if (left >= 0) {
|
|
399
|
-
this.paddingLeft = left;
|
|
400
|
-
}
|
|
401
|
-
if (right >= 0) {
|
|
402
|
-
this.paddingRight = right;
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
BeatColumn.prototype.evalMaxWidth = function (beatViewDelegate) {
|
|
406
|
-
var e_6, _a;
|
|
407
|
-
this._maxWidth = 0;
|
|
408
|
-
try {
|
|
409
|
-
for (var _b = __values(this.beats), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
410
|
-
var beat = _c.value;
|
|
411
|
-
var beatView = beatViewDelegate.viewForBeat(beat);
|
|
412
|
-
var minSize = beatView.minSize;
|
|
413
|
-
if (minSize.width > this._maxWidth) {
|
|
414
|
-
this._maxWidth = minSize.width;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
419
|
-
finally {
|
|
420
|
-
try {
|
|
421
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
82
|
+
else {
|
|
83
|
+
curr = null;
|
|
422
84
|
}
|
|
423
|
-
finally { if (e_6) throw e_6.error; }
|
|
424
85
|
}
|
|
425
|
-
return
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return BeatColumn;
|
|
432
|
-
}());
|
|
433
|
-
export { BeatColumn };
|
|
434
|
-
var BeatsBuilder = (function () {
|
|
435
|
-
function BeatsBuilder(role, layoutParams, startOffset) {
|
|
436
|
-
if (startOffset === void 0) { startOffset = ZERO; }
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
Beat.idCounter = 0;
|
|
90
|
+
export class BeatsBuilder {
|
|
91
|
+
constructor(role, layoutParams, startOffset = ZERO, ...atoms) {
|
|
437
92
|
this.role = role;
|
|
438
93
|
this.layoutParams = layoutParams;
|
|
439
94
|
this.startOffset = startOffset;
|
|
440
95
|
this.beats = [];
|
|
441
|
-
|
|
96
|
+
const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);
|
|
442
97
|
this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);
|
|
443
98
|
this.windowIter = new WindowIterator();
|
|
444
99
|
this.beatOffset = beatOffset;
|
|
445
100
|
this.startIndex = index;
|
|
101
|
+
this.addAtoms(...atoms);
|
|
102
|
+
}
|
|
103
|
+
addAtoms(...atoms) {
|
|
104
|
+
this.windowIter.push(...atoms);
|
|
105
|
+
while (this.windowIter.hasMore) {
|
|
106
|
+
let currBeat = this.beats[this.beats.length - 1];
|
|
107
|
+
if (this.beats.length == 0 || currBeat.filled) {
|
|
108
|
+
currBeat = this.addBeat();
|
|
109
|
+
}
|
|
110
|
+
const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);
|
|
111
|
+
TSU.assert(remAtoms.length > 0, "Atleast one element should have been available here");
|
|
112
|
+
for (const atom of remAtoms) {
|
|
113
|
+
TSU.assert(currBeat.add(atom), "Should return true as we are already using a duration iterator here");
|
|
114
|
+
if (this.onAtomAdded)
|
|
115
|
+
this.onAtomAdded(atom, currBeat);
|
|
116
|
+
}
|
|
117
|
+
if (currBeat.filled) {
|
|
118
|
+
if (this.onBeatFilled)
|
|
119
|
+
this.onBeatFilled(currBeat);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
446
122
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
123
|
+
addBeat() {
|
|
124
|
+
const numBeats = this.beats.length;
|
|
125
|
+
const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];
|
|
126
|
+
const nextCP = this.cycleIter.next().value;
|
|
127
|
+
const apb = this.layoutParams.beatDuration;
|
|
128
|
+
const newBeat = new Beat(lastBeat == null ? this.startIndex : lastBeat.index + 1, this.role, lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset, nextCP[1].timesNum(apb), nextCP[0][0], nextCP[0][1], nextCP[0][2], lastBeat, null);
|
|
453
129
|
if (lastBeat == null && this.beatOffset.isGT(ZERO)) {
|
|
454
130
|
newBeat.add(new Space(this.beatOffset.timesNum(apb)));
|
|
455
131
|
}
|
|
@@ -459,43 +135,155 @@ var BeatsBuilder = (function () {
|
|
|
459
135
|
if (this.onBeatAdded)
|
|
460
136
|
this.onBeatAdded(newBeat);
|
|
461
137
|
return newBeat;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export class BeatColumn extends ColAlign {
|
|
141
|
+
constructor(offset, endOffset, markerType) {
|
|
142
|
+
super();
|
|
143
|
+
this.offset = offset;
|
|
144
|
+
this.endOffset = endOffset;
|
|
145
|
+
this.markerType = markerType;
|
|
146
|
+
this.atomSpacing = 5;
|
|
147
|
+
offset = offset.factorized;
|
|
148
|
+
endOffset = endOffset.factorized;
|
|
149
|
+
this.key = BeatColumn.keyFor(offset, endOffset, markerType);
|
|
150
|
+
}
|
|
151
|
+
static keyFor(offset, endOffset, markerType = 0) {
|
|
152
|
+
offset = offset.factorized;
|
|
153
|
+
endOffset = endOffset.factorized;
|
|
154
|
+
if (markerType < 0) {
|
|
155
|
+
return ":" + offset.toString();
|
|
468
156
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
157
|
+
else if (markerType > 0) {
|
|
158
|
+
return endOffset.toString() + ":";
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return offset.toString() + ":" + endOffset.toString();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export class BeatColDAG {
|
|
166
|
+
constructor(layoutGroup) {
|
|
167
|
+
this.layoutGroup = layoutGroup;
|
|
168
|
+
this.beatColumns = new Map();
|
|
169
|
+
}
|
|
170
|
+
getBeatColumn(offset, endOffset, markerType = 0) {
|
|
171
|
+
const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);
|
|
172
|
+
if (newcreated) {
|
|
173
|
+
if (markerType == 0) {
|
|
174
|
+
const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);
|
|
175
|
+
const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);
|
|
176
|
+
prevcol.addSuccessor(bcol);
|
|
177
|
+
bcol.addSuccessor(nextcol);
|
|
178
|
+
for (const other of this.beatColumns.values()) {
|
|
179
|
+
if (other.markerType == -1 && endOffset.equals(other.offset)) {
|
|
180
|
+
nextcol.addSuccessor(other);
|
|
181
|
+
}
|
|
182
|
+
else if (other.markerType == 1 && other.endOffset.equals(offset)) {
|
|
183
|
+
other.addSuccessor(prevcol);
|
|
184
|
+
}
|
|
489
185
|
}
|
|
490
|
-
finally { if (e_7) throw e_7.error; }
|
|
491
186
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
187
|
+
}
|
|
188
|
+
return bcol;
|
|
189
|
+
}
|
|
190
|
+
ensureBeatColumn(offset, endOffset, markerType = 0) {
|
|
191
|
+
const key = BeatColumn.keyFor(offset, endOffset, markerType);
|
|
192
|
+
let bcol = this.beatColumns.get(key) || null;
|
|
193
|
+
const newcreated = bcol == null;
|
|
194
|
+
if (!bcol) {
|
|
195
|
+
bcol = new BeatColumn(offset, endOffset, markerType);
|
|
196
|
+
this.beatColumns.set(key, bcol);
|
|
197
|
+
}
|
|
198
|
+
return [bcol, newcreated];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
export class GlobalBeatLayout {
|
|
202
|
+
constructor() {
|
|
203
|
+
this.gridModelsForLine = new Map();
|
|
204
|
+
this.roleBeatsForLine = new Map();
|
|
205
|
+
this.beatColDAGsByLP = new Map();
|
|
206
|
+
this.gridLayoutGroup = new GridLayoutGroup();
|
|
207
|
+
}
|
|
208
|
+
getGridModelForLine(lineid) {
|
|
209
|
+
let out = this.gridModelsForLine.get(lineid) || null;
|
|
210
|
+
if (!out) {
|
|
211
|
+
out = new GridModel();
|
|
212
|
+
this.gridLayoutGroup.addGridModel(out);
|
|
213
|
+
this.gridModelsForLine.set(lineid, out);
|
|
214
|
+
}
|
|
215
|
+
return out;
|
|
216
|
+
}
|
|
217
|
+
beatColDAGForLP(lpid) {
|
|
218
|
+
let out = this.beatColDAGsByLP.get(lpid) || null;
|
|
219
|
+
if (!out) {
|
|
220
|
+
out = new BeatColDAG(this.gridLayoutGroup);
|
|
221
|
+
this.beatColDAGsByLP.set(lpid, out);
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
addLine(line) {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
const gridModel = this.getGridModelForLine(line.uuid);
|
|
228
|
+
(_a = gridModel.eventHub) === null || _a === void 0 ? void 0 : _a.startBatchMode();
|
|
229
|
+
this.lineToRoleBeats(line, gridModel);
|
|
230
|
+
(_b = gridModel.eventHub) === null || _b === void 0 ? void 0 : _b.commitBatch();
|
|
231
|
+
}
|
|
232
|
+
lineToRoleBeats(line, gridModel) {
|
|
233
|
+
const lp = line.layoutParams;
|
|
234
|
+
const roleBeats = [];
|
|
235
|
+
this.roleBeatsForLine.set(line.uuid, roleBeats);
|
|
236
|
+
const lineOffset = line.offset.divbyNum(lp.beatDuration);
|
|
237
|
+
for (const role of line.roles) {
|
|
238
|
+
const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);
|
|
239
|
+
roleBeats.push(bb.beats);
|
|
240
|
+
for (const beat of bb.beats) {
|
|
241
|
+
this.addBeat(beat, gridModel);
|
|
495
242
|
}
|
|
496
243
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
244
|
+
return roleBeats;
|
|
245
|
+
}
|
|
246
|
+
addBeat(beat, gridModel) {
|
|
247
|
+
const line = beat.role.line;
|
|
248
|
+
const lp = line.layoutParams;
|
|
249
|
+
const beatColDAG = this.beatColDAGForLP(lp.uuid);
|
|
250
|
+
const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);
|
|
251
|
+
const colEnd = rowOffset.plus(beat.duration, true);
|
|
252
|
+
const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);
|
|
253
|
+
const roleIndex = beat.role.line.indexOfRole(beat.role.name);
|
|
254
|
+
const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;
|
|
255
|
+
const realCol = 1 + layoutColumn * 3;
|
|
256
|
+
const preMarkers = beat.preMarkers;
|
|
257
|
+
if (preMarkers.length > 0) {
|
|
258
|
+
const val = {
|
|
259
|
+
beat: beat,
|
|
260
|
+
markers: preMarkers,
|
|
261
|
+
};
|
|
262
|
+
const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);
|
|
263
|
+
gridModel.setValue(realRow, realCol - 1, val, (gridRow, col) => {
|
|
264
|
+
const cell = new GridCell(gridRow, col);
|
|
265
|
+
cell.colAlign = precol;
|
|
266
|
+
return cell;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
const postMarkers = beat.postMarkers;
|
|
270
|
+
if (postMarkers.length > 0) {
|
|
271
|
+
const val = {
|
|
272
|
+
beat: beat,
|
|
273
|
+
markers: postMarkers,
|
|
274
|
+
};
|
|
275
|
+
const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);
|
|
276
|
+
gridModel.setValue(realRow, realCol + 1, val, (gridRow, col) => {
|
|
277
|
+
const cell = new GridCell(gridRow, col);
|
|
278
|
+
cell.colAlign = postcol;
|
|
279
|
+
return cell;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return gridModel.setValue(realRow, realCol, beat, (gridRow, col) => {
|
|
283
|
+
const cell = new GridCell(gridRow, col);
|
|
284
|
+
cell.colAlign = bcol;
|
|
285
|
+
return cell;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
501
289
|
//# sourceMappingURL=beats.js.map
|