notations 0.0.47 → 0.0.50
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 +73 -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 +230 -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 +71 -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 +225 -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/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
2
|
import { Group, Space } from "./";
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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,12 @@ var Beat = (function () {
|
|
|
50
15
|
this.instance = instance;
|
|
51
16
|
this.prevBeat = prevBeat;
|
|
52
17
|
this.nextBeat = nextBeat;
|
|
18
|
+
this.uuid = Beat.idCounter++;
|
|
53
19
|
this.layoutLine = -1;
|
|
54
20
|
this.layoutColumn = -1;
|
|
55
|
-
this.uuid = Beat.idCounter++;
|
|
56
21
|
this.atomIsPlaceholder = false;
|
|
57
22
|
}
|
|
58
|
-
|
|
23
|
+
debugValue() {
|
|
59
24
|
return {
|
|
60
25
|
index: this.index,
|
|
61
26
|
role: this.role.name,
|
|
@@ -66,29 +31,17 @@ var Beat = (function () {
|
|
|
66
31
|
instance: this.instance,
|
|
67
32
|
atom: this.atom.debugValue(),
|
|
68
33
|
};
|
|
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) {
|
|
34
|
+
}
|
|
35
|
+
get endOffset() {
|
|
36
|
+
return this.offset.plus(this.duration);
|
|
37
|
+
}
|
|
38
|
+
get filled() {
|
|
39
|
+
return this.remaining.isZero;
|
|
40
|
+
}
|
|
41
|
+
get remaining() {
|
|
42
|
+
return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;
|
|
43
|
+
}
|
|
44
|
+
add(atom) {
|
|
92
45
|
if (this.remaining.cmp(atom.duration) < 0) {
|
|
93
46
|
return false;
|
|
94
47
|
}
|
|
@@ -103,353 +56,48 @@ var Beat = (function () {
|
|
|
103
56
|
this.atom.addAtoms(true, atom);
|
|
104
57
|
}
|
|
105
58
|
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
|
-
}
|
|
157
|
-
BeatLayout.prototype.getBeatColumn = function (offset, duration) {
|
|
158
|
-
var e_1, _a;
|
|
159
|
-
var key = BeatLayout.keyFor(offset, duration);
|
|
160
|
-
var bcol = this.beatColumns.get(key) || null;
|
|
161
|
-
if (!bcol) {
|
|
162
|
-
bcol = new BeatColumn(offset, duration);
|
|
163
|
-
this.beatColumns.set(key, bcol);
|
|
164
|
-
if (bcol.offset.isZero) {
|
|
165
|
-
this.startingColumns.push(bcol);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
var endOffset = offset.plus(duration);
|
|
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
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
228
|
-
finally {
|
|
229
|
-
try {
|
|
230
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
231
|
-
}
|
|
232
|
-
finally { if (e_2) throw e_2.error; }
|
|
233
|
-
}
|
|
234
|
-
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
59
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
-
}
|
|
364
|
-
Object.defineProperty(BeatColumn.prototype, "x", {
|
|
365
|
-
get: function () {
|
|
366
|
-
return this._x;
|
|
367
|
-
},
|
|
368
|
-
enumerable: false,
|
|
369
|
-
configurable: true
|
|
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;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
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);
|
|
422
|
-
}
|
|
423
|
-
finally { if (e_6) throw e_6.error; }
|
|
424
|
-
}
|
|
425
|
-
return this._maxWidth;
|
|
426
|
-
};
|
|
427
|
-
BeatColumn.prototype.add = function (beat) {
|
|
428
|
-
this.beats.push(beat);
|
|
429
|
-
this.needsLayout = true;
|
|
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; }
|
|
60
|
+
}
|
|
61
|
+
Beat.idCounter = 0;
|
|
62
|
+
export class BeatsBuilder {
|
|
63
|
+
constructor(role, layoutParams, startOffset = ZERO, ...atoms) {
|
|
437
64
|
this.role = role;
|
|
438
65
|
this.layoutParams = layoutParams;
|
|
439
66
|
this.startOffset = startOffset;
|
|
440
67
|
this.beats = [];
|
|
441
|
-
|
|
68
|
+
const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);
|
|
442
69
|
this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);
|
|
443
70
|
this.windowIter = new WindowIterator();
|
|
444
71
|
this.beatOffset = beatOffset;
|
|
445
72
|
this.startIndex = index;
|
|
73
|
+
this.addAtoms(...atoms);
|
|
446
74
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
75
|
+
addAtoms(...atoms) {
|
|
76
|
+
this.windowIter.push(...atoms);
|
|
77
|
+
while (this.windowIter.hasMore) {
|
|
78
|
+
let currBeat = this.beats[this.beats.length - 1];
|
|
79
|
+
if (this.beats.length == 0 || currBeat.filled) {
|
|
80
|
+
currBeat = this.addBeat();
|
|
81
|
+
}
|
|
82
|
+
const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);
|
|
83
|
+
TSU.assert(remAtoms.length > 0, "Atleast one element should have been available here");
|
|
84
|
+
for (const atom of remAtoms) {
|
|
85
|
+
TSU.assert(currBeat.add(atom), "Should return true as we are already using a duration iterator here");
|
|
86
|
+
if (this.onAtomAdded)
|
|
87
|
+
this.onAtomAdded(atom, currBeat);
|
|
88
|
+
}
|
|
89
|
+
if (currBeat.filled) {
|
|
90
|
+
if (this.onBeatFilled)
|
|
91
|
+
this.onBeatFilled(currBeat);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
addBeat() {
|
|
96
|
+
const numBeats = this.beats.length;
|
|
97
|
+
const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];
|
|
98
|
+
const nextCP = this.cycleIter.next().value;
|
|
99
|
+
const apb = this.layoutParams.beatDuration;
|
|
100
|
+
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
101
|
if (lastBeat == null && this.beatOffset.isGT(ZERO)) {
|
|
454
102
|
newBeat.add(new Space(this.beatOffset.timesNum(apb)));
|
|
455
103
|
}
|
|
@@ -459,43 +107,129 @@ var BeatsBuilder = (function () {
|
|
|
459
107
|
if (this.onBeatAdded)
|
|
460
108
|
this.onBeatAdded(newBeat);
|
|
461
109
|
return newBeat;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export class BeatColumn extends ColAlign {
|
|
113
|
+
constructor(offset, endOffset, markerType) {
|
|
114
|
+
super();
|
|
115
|
+
this.offset = offset;
|
|
116
|
+
this.endOffset = endOffset;
|
|
117
|
+
this.markerType = markerType;
|
|
118
|
+
this.atomSpacing = 5;
|
|
119
|
+
offset = offset.factorized;
|
|
120
|
+
endOffset = endOffset.factorized;
|
|
121
|
+
this.key = BeatColumn.keyFor(offset, endOffset, markerType);
|
|
122
|
+
}
|
|
123
|
+
static keyFor(offset, endOffset, markerType = 0) {
|
|
124
|
+
offset = offset.factorized;
|
|
125
|
+
endOffset = endOffset.factorized;
|
|
126
|
+
if (markerType < 0) {
|
|
127
|
+
return ":" + offset.toString();
|
|
468
128
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
129
|
+
else if (markerType > 0) {
|
|
130
|
+
return endOffset.toString() + ":";
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return offset.toString() + ":" + endOffset.toString();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export class BeatColDAG {
|
|
138
|
+
constructor(layoutGroup) {
|
|
139
|
+
this.layoutGroup = layoutGroup;
|
|
140
|
+
this.beatColumns = new Map();
|
|
141
|
+
}
|
|
142
|
+
getBeatColumn(offset, endOffset, markerType = 0) {
|
|
143
|
+
const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);
|
|
144
|
+
if (newcreated) {
|
|
145
|
+
if (markerType == 0) {
|
|
146
|
+
const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);
|
|
147
|
+
const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);
|
|
148
|
+
prevcol.addSuccessor(bcol);
|
|
149
|
+
bcol.addSuccessor(nextcol);
|
|
150
|
+
for (const other of this.beatColumns.values()) {
|
|
151
|
+
if (other.markerType == -1 && endOffset.equals(other.offset)) {
|
|
152
|
+
nextcol.addSuccessor(other);
|
|
153
|
+
}
|
|
154
|
+
else if (other.markerType == 1 && other.endOffset.equals(offset)) {
|
|
155
|
+
other.addSuccessor(prevcol);
|
|
156
|
+
}
|
|
489
157
|
}
|
|
490
|
-
finally { if (e_7) throw e_7.error; }
|
|
491
|
-
}
|
|
492
|
-
if (currBeat.filled) {
|
|
493
|
-
if (this.onBeatFilled)
|
|
494
|
-
this.onBeatFilled(currBeat);
|
|
495
158
|
}
|
|
496
159
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
160
|
+
return bcol;
|
|
161
|
+
}
|
|
162
|
+
ensureBeatColumn(offset, endOffset, markerType = 0) {
|
|
163
|
+
const key = BeatColumn.keyFor(offset, endOffset, markerType);
|
|
164
|
+
let bcol = this.beatColumns.get(key) || null;
|
|
165
|
+
const newcreated = bcol == null;
|
|
166
|
+
if (!bcol) {
|
|
167
|
+
bcol = new BeatColumn(offset, endOffset, markerType);
|
|
168
|
+
this.beatColumns.set(key, bcol);
|
|
169
|
+
}
|
|
170
|
+
return [bcol, newcreated];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export class GlobalBeatLayout {
|
|
174
|
+
constructor() {
|
|
175
|
+
this.gridModelsForLine = new Map();
|
|
176
|
+
this.roleBeatsForLine = new Map();
|
|
177
|
+
this.beatColDAGsByLP = new Map();
|
|
178
|
+
this.gridLayoutGroup = new GridLayoutGroup();
|
|
179
|
+
}
|
|
180
|
+
getGridModelForLine(lineid) {
|
|
181
|
+
let out = this.gridModelsForLine.get(lineid) || null;
|
|
182
|
+
if (!out) {
|
|
183
|
+
out = new GridModel();
|
|
184
|
+
this.gridLayoutGroup.addGridModel(out);
|
|
185
|
+
this.gridModelsForLine.set(lineid, out);
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
beatColDAGForLP(lpid) {
|
|
190
|
+
let out = this.beatColDAGsByLP.get(lpid) || null;
|
|
191
|
+
if (!out) {
|
|
192
|
+
out = new BeatColDAG(this.gridLayoutGroup);
|
|
193
|
+
this.beatColDAGsByLP.set(lpid, out);
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
addLine(line) {
|
|
198
|
+
var _a, _b;
|
|
199
|
+
const gridModel = this.getGridModelForLine(line.uuid);
|
|
200
|
+
(_a = gridModel.eventHub) === null || _a === void 0 ? void 0 : _a.startBatchMode();
|
|
201
|
+
this.lineToRoleBeats(line, gridModel);
|
|
202
|
+
(_b = gridModel.eventHub) === null || _b === void 0 ? void 0 : _b.commitBatch();
|
|
203
|
+
}
|
|
204
|
+
lineToRoleBeats(line, gridModel) {
|
|
205
|
+
const lp = line.layoutParams;
|
|
206
|
+
const roleBeats = [];
|
|
207
|
+
this.roleBeatsForLine.set(line.uuid, roleBeats);
|
|
208
|
+
const lineOffset = line.offset.divbyNum(lp.beatDuration);
|
|
209
|
+
for (const role of line.roles) {
|
|
210
|
+
const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);
|
|
211
|
+
roleBeats.push(bb.beats);
|
|
212
|
+
for (const beat of bb.beats) {
|
|
213
|
+
this.addBeat(beat, gridModel);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return roleBeats;
|
|
217
|
+
}
|
|
218
|
+
addBeat(beat, gridModel) {
|
|
219
|
+
const line = beat.role.line;
|
|
220
|
+
const lp = line.layoutParams;
|
|
221
|
+
const beatColDAG = this.beatColDAGForLP(lp.uuid);
|
|
222
|
+
const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);
|
|
223
|
+
const colEnd = rowOffset.plus(beat.duration, true);
|
|
224
|
+
const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);
|
|
225
|
+
const roleIndex = beat.role.line.indexOfRole(beat.role.name);
|
|
226
|
+
const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;
|
|
227
|
+
const realCol = layoutColumn * 3;
|
|
228
|
+
return gridModel.setValue(realRow, realCol, beat, (gridRow, col) => {
|
|
229
|
+
const cell = new GridCell(gridRow, col);
|
|
230
|
+
cell.colAlign = bcol;
|
|
231
|
+
return cell;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
501
235
|
//# sourceMappingURL=beats.js.map
|