notations 0.0.40 → 0.0.45
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/README.md +38 -0
- package/lib/cjs/beats.d.ts +111 -0
- package/lib/cjs/beats.js +523 -0
- package/lib/cjs/beats.js.map +1 -0
- package/lib/cjs/carnatic/LineView.d.ts +20 -0
- package/lib/cjs/carnatic/LineView.js +69 -0
- package/lib/cjs/carnatic/LineView.js.map +1 -0
- package/lib/cjs/carnatic/NotationView.d.ts +31 -0
- package/lib/cjs/carnatic/NotationView.js +250 -0
- package/lib/cjs/carnatic/NotationView.js.map +1 -0
- package/lib/cjs/carnatic/atomviews.d.ts +14 -7
- package/lib/cjs/carnatic/atomviews.js +170 -137
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.d.ts +10 -14
- package/lib/cjs/carnatic/beatviews.js +53 -108
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.d.ts +38 -32
- package/lib/cjs/carnatic/embelishments.js +35 -20
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/carnatic/index.d.ts +2 -0
- package/lib/cjs/carnatic/index.js +2 -0
- package/lib/cjs/carnatic/index.js.map +1 -1
- package/lib/cjs/core.d.ts +15 -73
- package/lib/cjs/core.js +200 -568
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.d.ts +47 -0
- package/lib/cjs/cycle.js +492 -0
- package/lib/cjs/cycle.js.map +1 -0
- package/lib/cjs/entity.d.ts +24 -0
- package/lib/cjs/entity.js +135 -0
- package/lib/cjs/entity.js.map +1 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.js +3 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/iterators.d.ts +14 -2
- package/lib/cjs/iterators.js +79 -7
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.d.ts +7 -106
- package/lib/cjs/layouts.js +4 -478
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.d.ts +2 -1
- package/lib/cjs/loader.js +32 -27
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.d.ts +3 -1
- package/lib/cjs/notation.js +6 -4
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/parser.js +6 -5
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.d.ts +35 -14
- package/lib/cjs/shapes.js +153 -43
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.d.ts +2 -1
- package/lib/cjs/utils.js +20 -8
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/beats.d.ts +111 -0
- package/lib/esm/beats.js +501 -0
- package/lib/esm/beats.js.map +1 -0
- package/lib/esm/carnatic/LineView.d.ts +20 -0
- package/lib/esm/carnatic/LineView.js +47 -0
- package/lib/esm/carnatic/LineView.js.map +1 -0
- package/lib/esm/carnatic/NotationView.d.ts +31 -0
- package/lib/esm/carnatic/NotationView.js +228 -0
- package/lib/esm/carnatic/NotationView.js.map +1 -0
- package/lib/esm/carnatic/atomviews.d.ts +14 -7
- package/lib/esm/carnatic/atomviews.js +170 -137
- package/lib/esm/carnatic/atomviews.js.map +1 -1
- package/lib/esm/carnatic/beatviews.d.ts +10 -14
- package/lib/esm/carnatic/beatviews.js +54 -109
- package/lib/esm/carnatic/beatviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.d.ts +38 -32
- package/lib/esm/carnatic/embelishments.js +34 -19
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/carnatic/index.d.ts +2 -0
- package/lib/esm/carnatic/index.js +2 -0
- package/lib/esm/carnatic/index.js.map +1 -1
- package/lib/esm/core.d.ts +15 -73
- package/lib/esm/core.js +196 -564
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/cycle.d.ts +47 -0
- package/lib/esm/cycle.js +470 -0
- package/lib/esm/cycle.js.map +1 -0
- package/lib/esm/entity.d.ts +24 -0
- package/lib/esm/entity.js +132 -0
- package/lib/esm/entity.js.map +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/iterators.d.ts +14 -2
- package/lib/esm/iterators.js +75 -3
- package/lib/esm/iterators.js.map +1 -1
- package/lib/esm/layouts.d.ts +7 -106
- package/lib/esm/layouts.js +1 -475
- package/lib/esm/layouts.js.map +1 -1
- package/lib/esm/loader.d.ts +2 -1
- package/lib/esm/loader.js +28 -24
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.d.ts +3 -1
- package/lib/esm/notation.js +3 -1
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/parser.js +6 -5
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.d.ts +35 -14
- package/lib/esm/shapes.js +152 -42
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/utils.d.ts +2 -1
- package/lib/esm/utils.js +19 -7
- package/lib/esm/utils.js.map +1 -1
- package/package.json +33 -28
- package/styles/NotationView.scss +35 -0
package/lib/esm/layouts.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
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
1
|
var __read = (this && this.__read) || function (o, n) {
|
|
13
2
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
3
|
if (!m) return o;
|
|
@@ -25,472 +14,9 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
25
14
|
}
|
|
26
15
|
return ar;
|
|
27
16
|
};
|
|
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
17
|
import * as TSU from "@panyam/tsutils";
|
|
38
|
-
import {
|
|
39
|
-
import { AtomIterator, DurationIterator, FlatAtom } from "./iterators";
|
|
18
|
+
import { Cycle, CycleCursor } from "./cycle";
|
|
40
19
|
var ZERO = TSU.Num.Fraction.ZERO;
|
|
41
|
-
var Beat = (function () {
|
|
42
|
-
function Beat(index, role, offset, duration, barIndex, beatIndex, instance, prevBeat, nextBeat) {
|
|
43
|
-
this.index = index;
|
|
44
|
-
this.role = role;
|
|
45
|
-
this.offset = offset;
|
|
46
|
-
this.duration = duration;
|
|
47
|
-
this.barIndex = barIndex;
|
|
48
|
-
this.beatIndex = beatIndex;
|
|
49
|
-
this.instance = instance;
|
|
50
|
-
this.prevBeat = prevBeat;
|
|
51
|
-
this.nextBeat = nextBeat;
|
|
52
|
-
this.layoutLine = -1;
|
|
53
|
-
this.layoutColumn = -1;
|
|
54
|
-
this.uuid = Beat.idCounter++;
|
|
55
|
-
this.atoms = [];
|
|
56
|
-
}
|
|
57
|
-
Beat.prototype.debugValue = function () {
|
|
58
|
-
return {
|
|
59
|
-
index: this.index,
|
|
60
|
-
role: this.role.name,
|
|
61
|
-
offset: this.offset.toString(),
|
|
62
|
-
duration: this.duration.toString(),
|
|
63
|
-
barIndex: this.barIndex,
|
|
64
|
-
beatIndex: this.beatIndex,
|
|
65
|
-
instance: this.instance,
|
|
66
|
-
atoms: this.atoms.map(function (a) { return a.debugValue(); }),
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
Object.defineProperty(Beat.prototype, "endOffset", {
|
|
70
|
-
get: function () {
|
|
71
|
-
return this.offset.plus(this.duration);
|
|
72
|
-
},
|
|
73
|
-
enumerable: false,
|
|
74
|
-
configurable: true
|
|
75
|
-
});
|
|
76
|
-
Object.defineProperty(Beat.prototype, "filled", {
|
|
77
|
-
get: function () {
|
|
78
|
-
return this.remaining.isZero;
|
|
79
|
-
},
|
|
80
|
-
enumerable: false,
|
|
81
|
-
configurable: true
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(Beat.prototype, "remaining", {
|
|
84
|
-
get: function () {
|
|
85
|
-
return this.duration.minus(this.atoms.reduce(function (a, b) { return a.plus(b.duration); }, ZERO));
|
|
86
|
-
},
|
|
87
|
-
enumerable: false,
|
|
88
|
-
configurable: true
|
|
89
|
-
});
|
|
90
|
-
Beat.prototype.add = function (atom) {
|
|
91
|
-
if (this.remaining.cmp(atom.duration) < 0) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
this.atoms.push(atom);
|
|
95
|
-
return true;
|
|
96
|
-
};
|
|
97
|
-
Beat.prototype.ensureUniformSpaces = function (slotsPerBeat) {
|
|
98
|
-
if (slotsPerBeat === void 0) { slotsPerBeat = 1; }
|
|
99
|
-
var lcm = 1;
|
|
100
|
-
var gcd = 0;
|
|
101
|
-
this.atoms.forEach(function (a, index) {
|
|
102
|
-
a.duration = a.duration.factorized;
|
|
103
|
-
var currDen = a.duration.den;
|
|
104
|
-
if (currDen != 1) {
|
|
105
|
-
lcm *= currDen;
|
|
106
|
-
if (gcd == 0) {
|
|
107
|
-
gcd = a.duration.den;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
gcd = TSU.Num.gcdof(gcd, currDen);
|
|
111
|
-
lcm /= gcd;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
var baseDur = new TSU.Num.Fraction(1, lcm);
|
|
116
|
-
var currOffset = this.offset;
|
|
117
|
-
for (var i = 0; i < this.atoms.length;) {
|
|
118
|
-
var fa = this.atoms[i];
|
|
119
|
-
var numSpaces = lcm == 1 ? fa.duration.num - 1 : lcm / fa.duration.den - 1;
|
|
120
|
-
fa.duration = baseDur;
|
|
121
|
-
currOffset = currOffset.plus(baseDur);
|
|
122
|
-
i++;
|
|
123
|
-
for (var j = 0; j < numSpaces; j++, i++) {
|
|
124
|
-
this.atoms.splice(i, 0, new FlatAtom(new Space(), {
|
|
125
|
-
isContinuation: true,
|
|
126
|
-
offset: currOffset.factorized,
|
|
127
|
-
duration: baseDur,
|
|
128
|
-
depth: fa.depth,
|
|
129
|
-
}));
|
|
130
|
-
currOffset = currOffset.plus(baseDur);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
Beat.idCounter = 0;
|
|
135
|
-
return Beat;
|
|
136
|
-
}());
|
|
137
|
-
export { Beat };
|
|
138
|
-
var BeatLayout = (function () {
|
|
139
|
-
function BeatLayout(layoutParams) {
|
|
140
|
-
this.layoutParams = layoutParams;
|
|
141
|
-
this.bcolNextList = new Map();
|
|
142
|
-
this.beatColumns = new Map();
|
|
143
|
-
this.startingColumns = [];
|
|
144
|
-
this.columnForBeat = new Map();
|
|
145
|
-
this.DEBUG = false;
|
|
146
|
-
this.roleSpacing = 10;
|
|
147
|
-
this.rowSpacing = 15;
|
|
148
|
-
}
|
|
149
|
-
BeatLayout.prototype.getBeatColumn = function (offset, duration) {
|
|
150
|
-
var e_1, _a;
|
|
151
|
-
var key = BeatLayout.keyFor(offset, duration);
|
|
152
|
-
var bcol = this.beatColumns.get(key) || null;
|
|
153
|
-
if (!bcol) {
|
|
154
|
-
bcol = new BeatColumn(offset, duration);
|
|
155
|
-
this.beatColumns.set(key, bcol);
|
|
156
|
-
if (bcol.offset.isZero) {
|
|
157
|
-
this.startingColumns.push(bcol);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
var endOffset = offset.plus(duration);
|
|
161
|
-
try {
|
|
162
|
-
for (var _b = __values(this.beatColumns.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
163
|
-
var other = _c.value;
|
|
164
|
-
if (other.offset.plus(other.duration).equals(offset)) {
|
|
165
|
-
this.addSuccessor(other, bcol);
|
|
166
|
-
}
|
|
167
|
-
else if (other.offset.equals(endOffset)) {
|
|
168
|
-
this.addSuccessor(bcol, other);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
173
|
-
finally {
|
|
174
|
-
try {
|
|
175
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
176
|
-
}
|
|
177
|
-
finally { if (e_1) throw e_1.error; }
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return bcol;
|
|
182
|
-
};
|
|
183
|
-
BeatLayout.keyFor = function (offset, duration) {
|
|
184
|
-
return offset.factorized.toString() + ":" + duration.factorized.toString();
|
|
185
|
-
};
|
|
186
|
-
BeatLayout.prototype.addSuccessor = function (prev, next) {
|
|
187
|
-
TSU.assert(prev.offset.plus(prev.duration).equals(next.offset), "BeatColumns are not adjacent to each other");
|
|
188
|
-
var prevKey = BeatLayout.keyFor(prev.offset, prev.duration);
|
|
189
|
-
var nextKey = BeatLayout.keyFor(next.offset, next.duration);
|
|
190
|
-
var nextset = this.bcolNextList.get(prevKey) || null;
|
|
191
|
-
if (!nextset) {
|
|
192
|
-
nextset = new Set();
|
|
193
|
-
this.bcolNextList.set(prevKey, nextset);
|
|
194
|
-
}
|
|
195
|
-
nextset.add(nextKey);
|
|
196
|
-
};
|
|
197
|
-
BeatLayout.prototype.addBeat = function (beat) {
|
|
198
|
-
var lp = this.layoutParams;
|
|
199
|
-
var _a = __read(lp.getBeatLocation(beat), 3), layoutLine = _a[0], layoutColumn = _a[1], rowOffset = _a[2];
|
|
200
|
-
var bcol = this.getBeatColumn(rowOffset, beat.duration);
|
|
201
|
-
bcol.add(beat);
|
|
202
|
-
this.columnForBeat.set(beat.uuid, bcol);
|
|
203
|
-
beat.layoutLine = layoutLine;
|
|
204
|
-
beat.layoutColumn = layoutColumn;
|
|
205
|
-
return bcol;
|
|
206
|
-
};
|
|
207
|
-
BeatLayout.prototype.neighborsOf = function (beatColumn) {
|
|
208
|
-
var e_2, _a;
|
|
209
|
-
var out = [];
|
|
210
|
-
var endOffset = beatColumn.offset.plus(beatColumn.duration);
|
|
211
|
-
try {
|
|
212
|
-
for (var _b = __values(this.beatColumns.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
213
|
-
var other = _c.value;
|
|
214
|
-
if (endOffset.equals(other.offset)) {
|
|
215
|
-
out.push(other);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
220
|
-
finally {
|
|
221
|
-
try {
|
|
222
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
223
|
-
}
|
|
224
|
-
finally { if (e_2) throw e_2.error; }
|
|
225
|
-
}
|
|
226
|
-
return out;
|
|
227
|
-
};
|
|
228
|
-
BeatLayout.prototype.evalColumnSizes = function (beatViewDelegate) {
|
|
229
|
-
var e_3, _a, e_4, _b;
|
|
230
|
-
var queue = __spreadArray([], __read(this.startingColumns), false);
|
|
231
|
-
var xForOffsets = {};
|
|
232
|
-
while (queue.length > 0) {
|
|
233
|
-
var nextQueue = [];
|
|
234
|
-
try {
|
|
235
|
-
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()) {
|
|
236
|
-
var bcol = queue_1_1.value;
|
|
237
|
-
var offset = bcol.offset.factorized;
|
|
238
|
-
var colWidth = bcol.evalMaxWidth(beatViewDelegate);
|
|
239
|
-
var currX = 0;
|
|
240
|
-
if (!bcol.offset.isZero) {
|
|
241
|
-
TSU.assert(offset.toString() in xForOffsets, "Cannot find x for given offset");
|
|
242
|
-
currX = xForOffsets[offset.toString()];
|
|
243
|
-
}
|
|
244
|
-
bcol.setX(currX, beatViewDelegate);
|
|
245
|
-
var endOffset = offset.plus(bcol.duration).factorized;
|
|
246
|
-
xForOffsets[endOffset.toString()] = Math.max(xForOffsets[endOffset.toString()] || 0, currX + colWidth + bcol.paddingLeft + bcol.paddingRight);
|
|
247
|
-
try {
|
|
248
|
-
for (var _c = (e_4 = void 0, __values(this.beatColumns.values())), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
249
|
-
var other = _d.value;
|
|
250
|
-
if (endOffset.equals(other.offset)) {
|
|
251
|
-
nextQueue.push(other);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
256
|
-
finally {
|
|
257
|
-
try {
|
|
258
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
259
|
-
}
|
|
260
|
-
finally { if (e_4) throw e_4.error; }
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
265
|
-
finally {
|
|
266
|
-
try {
|
|
267
|
-
if (queue_1_1 && !queue_1_1.done && (_a = queue_1.return)) _a.call(queue_1);
|
|
268
|
-
}
|
|
269
|
-
finally { if (e_3) throw e_3.error; }
|
|
270
|
-
}
|
|
271
|
-
queue = nextQueue;
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
BeatLayout.prototype.layoutBeatsForLine = function (line, allRoleBeats, beatViewDelegate) {
|
|
275
|
-
var lp = this.layoutParams;
|
|
276
|
-
var currBeats = line.roles.map(function (l, index) { return allRoleBeats[index][0]; });
|
|
277
|
-
var currY = this.roleSpacing;
|
|
278
|
-
var numDone = 0;
|
|
279
|
-
do {
|
|
280
|
-
numDone = 0;
|
|
281
|
-
for (var currRole = 0; currRole < currBeats.length; currRole++) {
|
|
282
|
-
var currBeat = currBeats[currRole];
|
|
283
|
-
if (currBeat) {
|
|
284
|
-
var temp = currBeat;
|
|
285
|
-
var numBeatsInRow = lp.lineBreaks[currBeat.layoutLine];
|
|
286
|
-
var maxHeight = 0;
|
|
287
|
-
var currX = 0;
|
|
288
|
-
for (var i = currBeat.layoutColumn; i < numBeatsInRow && currBeat; i++, currBeat = currBeat.nextBeat, numDone++) {
|
|
289
|
-
var beatView = beatViewDelegate.viewForBeat(currBeat);
|
|
290
|
-
beatView.y = currY;
|
|
291
|
-
if (this.DEBUG) {
|
|
292
|
-
beatView.x = currX;
|
|
293
|
-
beatView.refreshLayout();
|
|
294
|
-
currX += beatView.width;
|
|
295
|
-
}
|
|
296
|
-
maxHeight = Math.max(maxHeight, beatView.minSize.height);
|
|
297
|
-
}
|
|
298
|
-
currBeat = temp;
|
|
299
|
-
for (var i = currBeat.layoutColumn; i < numBeatsInRow && currBeat; i++, currBeat = currBeat.nextBeat, numDone++) {
|
|
300
|
-
var beatView = beatViewDelegate.viewForBeat(currBeat);
|
|
301
|
-
beatView.height = maxHeight;
|
|
302
|
-
}
|
|
303
|
-
currY += maxHeight;
|
|
304
|
-
currY += this.roleSpacing;
|
|
305
|
-
}
|
|
306
|
-
currBeats[currRole] = currBeat;
|
|
307
|
-
}
|
|
308
|
-
currY += this.rowSpacing;
|
|
309
|
-
} while (numDone > 0);
|
|
310
|
-
};
|
|
311
|
-
return BeatLayout;
|
|
312
|
-
}());
|
|
313
|
-
export { BeatLayout };
|
|
314
|
-
var BeatRow = (function () {
|
|
315
|
-
function BeatRow(layoutLine, rowIndex) {
|
|
316
|
-
this.layoutLine = layoutLine;
|
|
317
|
-
this.rowIndex = rowIndex;
|
|
318
|
-
this._y = 0;
|
|
319
|
-
this._maxHeight = 0;
|
|
320
|
-
this.needsLayout = false;
|
|
321
|
-
this.rowSpacing = 5;
|
|
322
|
-
this.beats = [];
|
|
323
|
-
}
|
|
324
|
-
Object.defineProperty(BeatRow.prototype, "y", {
|
|
325
|
-
get: function () {
|
|
326
|
-
return this._y;
|
|
327
|
-
},
|
|
328
|
-
set: function (val) {
|
|
329
|
-
this._y = val;
|
|
330
|
-
this.needsLayout = true;
|
|
331
|
-
},
|
|
332
|
-
enumerable: false,
|
|
333
|
-
configurable: true
|
|
334
|
-
});
|
|
335
|
-
BeatRow.prototype.add = function (beat) {
|
|
336
|
-
this.beats.push(beat);
|
|
337
|
-
this.needsLayout = true;
|
|
338
|
-
};
|
|
339
|
-
return BeatRow;
|
|
340
|
-
}());
|
|
341
|
-
export { BeatRow };
|
|
342
|
-
var BeatColumn = (function () {
|
|
343
|
-
function BeatColumn(offset, duration) {
|
|
344
|
-
this.offset = offset;
|
|
345
|
-
this.duration = duration;
|
|
346
|
-
this._x = 0;
|
|
347
|
-
this._maxWidth = 0;
|
|
348
|
-
this.needsLayout = false;
|
|
349
|
-
this.atomSpacing = 5;
|
|
350
|
-
this.paddingLeft = 15;
|
|
351
|
-
this.paddingRight = 15;
|
|
352
|
-
this.beats = [];
|
|
353
|
-
offset = offset.factorized;
|
|
354
|
-
duration = duration.factorized;
|
|
355
|
-
}
|
|
356
|
-
Object.defineProperty(BeatColumn.prototype, "x", {
|
|
357
|
-
get: function () {
|
|
358
|
-
return this._x;
|
|
359
|
-
},
|
|
360
|
-
enumerable: false,
|
|
361
|
-
configurable: true
|
|
362
|
-
});
|
|
363
|
-
BeatColumn.prototype.setX = function (val, beatViewDelegate) {
|
|
364
|
-
var e_5, _a;
|
|
365
|
-
this._x = val;
|
|
366
|
-
try {
|
|
367
|
-
for (var _b = __values(this.beats), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
368
|
-
var beat = _c.value;
|
|
369
|
-
var beatView = beatViewDelegate.viewForBeat(beat);
|
|
370
|
-
beatView.x = val + this.paddingLeft;
|
|
371
|
-
beatView.width = this._maxWidth;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
375
|
-
finally {
|
|
376
|
-
try {
|
|
377
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
378
|
-
}
|
|
379
|
-
finally { if (e_5) throw e_5.error; }
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
Object.defineProperty(BeatColumn.prototype, "maxWidth", {
|
|
383
|
-
get: function () {
|
|
384
|
-
return this._maxWidth + this.paddingLeft + this.paddingRight;
|
|
385
|
-
},
|
|
386
|
-
enumerable: false,
|
|
387
|
-
configurable: true
|
|
388
|
-
});
|
|
389
|
-
BeatColumn.prototype.setPadding = function (left, right) {
|
|
390
|
-
if (left >= 0) {
|
|
391
|
-
this.paddingLeft = left;
|
|
392
|
-
}
|
|
393
|
-
if (right >= 0) {
|
|
394
|
-
this.paddingRight = right;
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
BeatColumn.prototype.evalMaxWidth = function (beatViewDelegate) {
|
|
398
|
-
var e_6, _a;
|
|
399
|
-
this._maxWidth = 0;
|
|
400
|
-
try {
|
|
401
|
-
for (var _b = __values(this.beats), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
402
|
-
var beat = _c.value;
|
|
403
|
-
var beatView = beatViewDelegate.viewForBeat(beat);
|
|
404
|
-
var minSize = beatView.minSize;
|
|
405
|
-
if (minSize.width > this._maxWidth) {
|
|
406
|
-
this._maxWidth = minSize.width;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
411
|
-
finally {
|
|
412
|
-
try {
|
|
413
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
414
|
-
}
|
|
415
|
-
finally { if (e_6) throw e_6.error; }
|
|
416
|
-
}
|
|
417
|
-
return this._maxWidth;
|
|
418
|
-
};
|
|
419
|
-
BeatColumn.prototype.add = function (beat) {
|
|
420
|
-
this.beats.push(beat);
|
|
421
|
-
this.needsLayout = true;
|
|
422
|
-
};
|
|
423
|
-
return BeatColumn;
|
|
424
|
-
}());
|
|
425
|
-
export { BeatColumn };
|
|
426
|
-
var BeatsBuilder = (function () {
|
|
427
|
-
function BeatsBuilder(role, layoutParams, startOffset) {
|
|
428
|
-
if (startOffset === void 0) { startOffset = ZERO; }
|
|
429
|
-
this.role = role;
|
|
430
|
-
this.layoutParams = layoutParams;
|
|
431
|
-
this.startOffset = startOffset;
|
|
432
|
-
this.beats = [];
|
|
433
|
-
var _a = __read(layoutParams.cycle.getPosition(startOffset), 4), _b = __read(_a[1], 3), bar = _b[0], beat = _b[1], instance = _b[2], beatOffset = _a[2], index = _a[3];
|
|
434
|
-
this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);
|
|
435
|
-
this.atomIter = new AtomIterator();
|
|
436
|
-
this.durIter = new DurationIterator(this.atomIter);
|
|
437
|
-
this.beatOffset = beatOffset;
|
|
438
|
-
this.startIndex = index;
|
|
439
|
-
}
|
|
440
|
-
BeatsBuilder.prototype.addBeat = function () {
|
|
441
|
-
var numBeats = this.beats.length;
|
|
442
|
-
var lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];
|
|
443
|
-
var nextCP = this.cycleIter.next().value;
|
|
444
|
-
var apb = this.layoutParams.beatDuration;
|
|
445
|
-
var newBeat = new Beat(lastBeat == null ? this.startIndex : lastBeat.index + 1, this.role, lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb).factorized : lastBeat.endOffset, nextCP[1].timesNum(apb), nextCP[0][0], nextCP[0][1], nextCP[0][2], lastBeat, null);
|
|
446
|
-
if (lastBeat == null && this.beatOffset.isGT(ZERO)) {
|
|
447
|
-
newBeat.add(new FlatAtom(new Space(this.beatOffset.timesNum(apb))));
|
|
448
|
-
}
|
|
449
|
-
if (lastBeat)
|
|
450
|
-
lastBeat.nextBeat = newBeat;
|
|
451
|
-
this.beats.push(newBeat);
|
|
452
|
-
if (this.onBeatAdded)
|
|
453
|
-
this.onBeatAdded(newBeat);
|
|
454
|
-
return newBeat;
|
|
455
|
-
};
|
|
456
|
-
BeatsBuilder.prototype.addAtoms = function () {
|
|
457
|
-
var _a, e_7, _b;
|
|
458
|
-
var atoms = [];
|
|
459
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
460
|
-
atoms[_i] = arguments[_i];
|
|
461
|
-
}
|
|
462
|
-
(_a = this.atomIter).push.apply(_a, __spreadArray([], __read(atoms), false));
|
|
463
|
-
while (this.durIter.hasMore) {
|
|
464
|
-
var currBeat = this.beats[this.beats.length - 1];
|
|
465
|
-
if (this.beats.length == 0 || currBeat.filled) {
|
|
466
|
-
currBeat = this.addBeat();
|
|
467
|
-
}
|
|
468
|
-
var _c = __read(this.durIter.get(currBeat.remaining), 2), flatAtoms = _c[0], filled = _c[1];
|
|
469
|
-
TSU.assert(flatAtoms.length > 0, "Atleast one element should have been available here");
|
|
470
|
-
try {
|
|
471
|
-
for (var flatAtoms_1 = (e_7 = void 0, __values(flatAtoms)), flatAtoms_1_1 = flatAtoms_1.next(); !flatAtoms_1_1.done; flatAtoms_1_1 = flatAtoms_1.next()) {
|
|
472
|
-
var flatAtom = flatAtoms_1_1.value;
|
|
473
|
-
TSU.assert(currBeat.add(flatAtom), "Should return true as we are already using a duration iterator here");
|
|
474
|
-
if (this.onAtomAdded)
|
|
475
|
-
this.onAtomAdded(flatAtom, currBeat);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
479
|
-
finally {
|
|
480
|
-
try {
|
|
481
|
-
if (flatAtoms_1_1 && !flatAtoms_1_1.done && (_b = flatAtoms_1.return)) _b.call(flatAtoms_1);
|
|
482
|
-
}
|
|
483
|
-
finally { if (e_7) throw e_7.error; }
|
|
484
|
-
}
|
|
485
|
-
if (currBeat.filled) {
|
|
486
|
-
if (this.onBeatFilled)
|
|
487
|
-
this.onBeatFilled(currBeat);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
return BeatsBuilder;
|
|
492
|
-
}());
|
|
493
|
-
export { BeatsBuilder };
|
|
494
20
|
var LayoutParams = (function () {
|
|
495
21
|
function LayoutParams(config) {
|
|
496
22
|
this.uuid = LayoutParams.counter++;
|
package/lib/esm/layouts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layouts.js","sourceRoot":"","sources":["../../src/layouts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAA6B,KAAK,EAAQ,KAAK,EAAiB,WAAW,EAAE,MAAM,IAAI,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvE,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AAsBnC;IAQE,cACkB,KAAa,EACb,IAAU,EACV,MAAgB,EAChB,QAAkB,EAClB,QAAgB,EAChB,SAAiB,EACjB,QAAgB,EAChB,QAAqB,EAC9B,QAAqB;QARZ,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAM;QACV,WAAM,GAAN,MAAM,CAAU;QAChB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAa;QAC9B,aAAQ,GAAR,QAAQ,CAAa;QAf9B,eAAU,GAAG,CAAC,CAAC,CAAC;QAChB,iBAAY,GAAG,CAAC,CAAC,CAAC;QACT,SAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAGxB,UAAK,GAAe,EAAE,CAAC;IAW7B,CAAC;IAEJ,yBAAU,GAAV;QACE,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,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,YAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Line, Atom, CycleIterator, Space, Role, Cycle, CyclePosition, CycleCursor } from \"./\";\nimport { AtomIterator, DurationIterator, FlatAtom } from \"./iterators\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\n\n// export interface Embelishment { refreshLayout(): void; }\n\ninterface BeatViewDelegate {\n // A way to create all beats for an entire Line in one go (instead of one by one)\n viewForBeat(beat: Beat): BeatView;\n}\n\nexport interface BeatView {\n readonly beat: Beat;\n readonly needsLayout: boolean;\n readonly minSize: TSU.Geom.Size;\n x: number;\n y: number;\n width: number;\n height: number;\n refreshLayout(): void;\n setStyles(config: any): void;\n // readonly embelishments: Embelishment[];\n}\n\nexport class Beat {\n private static idCounter = 0;\n layoutLine = -1;\n layoutColumn = -1;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n readonly atoms: FlatAtom[] = [];\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atoms: this.atoms.map((a) => a.debugValue()),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.duration.minus(this.atoms.reduce((a, b) => a.plus(b.duration), ZERO));\n }\n\n add(atom: FlatAtom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n this.atoms.push(atom);\n return true;\n }\n\n ensureUniformSpaces(slotsPerBeat = 1): void {\n let lcm = 1;\n let gcd = 0;\n this.atoms.forEach((a, index) => {\n a.duration = a.duration.factorized;\n const currDen = a.duration.den;\n if (currDen != 1) {\n lcm *= currDen;\n if (gcd == 0) {\n gcd = a.duration.den;\n } else {\n gcd = TSU.Num.gcdof(gcd, currDen);\n lcm /= gcd;\n }\n }\n });\n\n // Easiest option is (without worrying about depths)\n // just adding this N number 1 / LCM sized spaces for\n // each note where N = (LCM / note.frac.den) - 1\n\n // eg in the case of something like (a beat with) the notes\n // A: 1/2, B: 1/4, C: 1/6\n // LCM (of dens) = 24\n // 12 (1/24) spaces, 6 (1/24)\n // A = (24 / 2) - 1 = 11 spaces after A\n // B = (24 / 4) - 1 = 5 spaces after B\n // C = (24 / 6) - 1 = 3 spaces after C\n // Total = 11 + 5 + 3 + 3 (for A + B + C) = 22 notes in the beat\n\n const baseDur = new TSU.Num.Fraction(1, lcm);\n let currOffset = this.offset;\n for (let i = 0; i < this.atoms.length; ) {\n const fa = this.atoms[i];\n const numSpaces = lcm == 1 ? fa.duration.num - 1 : lcm / fa.duration.den - 1;\n // reset its duration to 1 / LCM so we can add numSpaces after it\n fa.duration = baseDur;\n currOffset = currOffset.plus(baseDur);\n i++;\n for (let j = 0; j < numSpaces; j++, i++) {\n this.atoms.splice(\n i,\n 0,\n new FlatAtom(new Space(), {\n isContinuation: true,\n offset: currOffset.factorized,\n duration: baseDur,\n depth: fa.depth,\n }),\n );\n currOffset = currOffset.plus(baseDur);\n }\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatLayout {\n // beatColumns[i][j] returns all beats in a particular layoutLine and\n // layoutColumn the purpose of beatColumns is to ensure horizontal alignment\n // of beats in a single column\n bcolNextList = new Map<string, Set<string>>();\n beatColumns = new Map<string, BeatColumn>();\n // bcolsStartingAt = new Map<string, BeatColumn[]>();\n // bcolsEndingAt = new Map<string, BeatColumn[]>();\n startingColumns: BeatColumn[] = [];\n\n // Mapping from beat -> BeatColumn where it resides\n columnForBeat = new Map<number, BeatColumn>();\n\n constructor(public readonly layoutParams: LayoutParams) {}\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, duration: Fraction): BeatColumn {\n const key = BeatLayout.keyFor(offset, duration);\n let bcol = this.beatColumns.get(key) || null;\n if (!bcol) {\n bcol = new BeatColumn(offset, duration);\n this.beatColumns.set(key, bcol);\n if (bcol.offset.isZero) {\n // this is a \"starting\" column\n this.startingColumns.push(bcol);\n } else {\n const endOffset = offset.plus(duration);\n // Find all columns \"before\" this and add this as a neighbour to those\n // columsn before are such that their prev.offset + prev.duration == bcol.offset\n for (const other of this.beatColumns.values()) {\n if (other.offset.plus(other.duration).equals(offset)) {\n // mark us as a successor of other\n this.addSuccessor(other, bcol);\n } else if (other.offset.equals(endOffset)) {\n // mark other as a successor of us\n this.addSuccessor(bcol, other);\n }\n }\n\n // Similary find all columns who could \"next\" sets and add us to them\n }\n }\n return bcol;\n }\n\n protected static keyFor(offset: Fraction, duration: Fraction): string {\n return offset.factorized.toString() + \":\" + duration.factorized.toString();\n }\n\n protected addSuccessor(prev: BeatColumn, next: BeatColumn): void {\n TSU.assert(prev.offset.plus(prev.duration).equals(next.offset), \"BeatColumns are not adjacent to each other\");\n const prevKey = BeatLayout.keyFor(prev.offset, prev.duration);\n const nextKey = BeatLayout.keyFor(next.offset, next.duration);\n let nextset = this.bcolNextList.get(prevKey) || null;\n if (!nextset) {\n nextset = new Set<string>();\n this.bcolNextList.set(prevKey, nextset);\n }\n nextset.add(nextKey);\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which this beat was added.\n */\n addBeat(beat: Beat): BeatColumn {\n // Get the beat column at this index (and line) and add to it.\n const lp = this.layoutParams;\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const bcol = this.getBeatColumn(rowOffset, beat.duration);\n\n bcol.add(beat);\n\n // TODO: see if beat exists in another column\n this.columnForBeat.set(beat.uuid, bcol);\n beat.layoutLine = layoutLine;\n beat.layoutColumn = layoutColumn;\n return bcol;\n }\n\n /**\n * Return all beat columns that start immediately after the given beat column.\n */\n neighborsOf(beatColumn: BeatColumn): BeatColumn[] {\n const out: BeatColumn[] = [];\n const endOffset = beatColumn.offset.plus(beatColumn.duration);\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n out.push(other);\n }\n }\n return out;\n }\n\n readonly DEBUG = false;\n evalColumnSizes(beatViewDelegate: BeatViewDelegate): void {\n // Do a bread first traversal of the beat columns so those with earlier offsets will be\n // laidout and nudged so that later ones' offsets can be set only once.\n // TODO - should this be a priority queue - ie is there a need to sort these by\n // \"larger\" widths first?\n let queue: BeatColumn[] = [...this.startingColumns];\n const xForOffsets: TSU.StringMap<number> = {};\n while (queue.length > 0) {\n const nextQueue: BeatColumn[] = [];\n for (const bcol of queue) {\n const offset = bcol.offset.factorized;\n const colWidth = bcol.evalMaxWidth(beatViewDelegate);\n let currX = 0;\n if (!bcol.offset.isZero) {\n // this *must* be in xForOffsets as it would have been calculated by a previous bcol\n TSU.assert(offset.toString() in xForOffsets, \"Cannot find x for given offset\");\n currX = xForOffsets[offset.toString()];\n }\n bcol.setX(currX, beatViewDelegate);\n const endOffset = offset.plus(bcol.duration).factorized;\n xForOffsets[endOffset.toString()] = Math.max(\n xForOffsets[endOffset.toString()] || 0,\n currX + colWidth + bcol.paddingLeft + bcol.paddingRight,\n );\n // add all neighbours here\n // TODO - Use better lists of going through all beat cols\n // Also ensure we are adding in sorted order and avoiding duplicates\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n nextQueue.push(other);\n }\n }\n }\n queue = nextQueue;\n }\n }\n\n // Spacing between each role in a single row\n roleSpacing = 10;\n\n // Spacing between each row (a row can consist of multiple roles).\n rowSpacing = 15;\n layoutBeatsForLine(line: Line, allRoleBeats: Beat[][], beatViewDelegate: BeatViewDelegate): void {\n // Instead of starting currLayoutLine at 0 - it should start at the line of the\n // first beat being rendered\n const lp = this.layoutParams;\n const currBeats = line.roles.map((l, index) => allRoleBeats[index][0]) as (Beat | null)[];\n let currY = this.roleSpacing;\n let numDone = 0;\n do {\n numDone = 0;\n // Lay one role at a time upto numBeatsInLine number of beats\n for (let currRole = 0; currRole < currBeats.length; currRole++) {\n let currBeat: Beat | null = currBeats[currRole];\n if (currBeat) {\n const temp = currBeat;\n const numBeatsInRow = lp.lineBreaks[currBeat.layoutLine];\n let maxHeight = 0;\n let currX = 0;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.y = currY;\n if (this.DEBUG) {\n beatView.x = currX;\n beatView.refreshLayout();\n currX += beatView.width;\n }\n maxHeight = Math.max(maxHeight, beatView.minSize.height);\n }\n\n currBeat = temp;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.height = maxHeight;\n }\n // Should line heights be \"fixed\"?\n // Set height of all views in this row to same height and Y\n currY += maxHeight;\n currY += this.roleSpacing;\n }\n currBeats[currRole] = currBeat;\n }\n\n // currLayoutLine = (currLayoutLine + 1) % lp.lineBreaks.length;\n currY += this.rowSpacing;\n } while (numDone > 0);\n }\n}\n\nexport class BeatRow {\n protected _y = 0;\n protected _maxHeight = 0;\n needsLayout = false;\n rowSpacing = 5;\n beats: Beat[] = [];\n constructor(public readonly layoutLine: number, public rowIndex: number) {}\n\n get y(): number {\n return this._y;\n }\n\n set y(val: number) {\n this._y = val;\n this.needsLayout = true;\n }\n\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added to either this row or another row?\n this.beats.push(beat);\n this.needsLayout = true;\n }\n}\n\nexport class BeatColumn {\n protected _x = 0;\n protected _maxWidth = 0;\n needsLayout = false;\n atomSpacing = 5;\n paddingLeft = 15;\n paddingRight = 15;\n beats: Beat[] = [];\n constructor(public readonly offset: Fraction, public readonly duration: Fraction) {\n offset = offset.factorized;\n duration = duration.factorized;\n }\n\n get x(): number {\n return this._x;\n }\n\n setX(val: number, beatViewDelegate: BeatViewDelegate): void {\n this._x = val;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n beatView.x = val + this.paddingLeft;\n beatView.width = this._maxWidth;\n // console.log(\"ID, Setting x, width: \", beatView.beat.index, (beatView as any).x, (beatView as any).width);\n }\n }\n\n get maxWidth(): number {\n return this._maxWidth + this.paddingLeft + this.paddingRight;\n }\n\n setPadding(left: number, right: number): void {\n if (left >= 0) {\n this.paddingLeft = left;\n }\n if (right >= 0) {\n this.paddingRight = right;\n }\n }\n\n evalMaxWidth(beatViewDelegate: BeatViewDelegate): number {\n this._maxWidth = 0;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n // console.log( \"index, _minSize, refreshMinSize = \", beatView.beat.index, (beatView as any)._minSize, (beatView as any).refreshMinSize(),);\n const minSize = beatView.minSize;\n if (minSize.width > this._maxWidth) {\n this._maxWidth = minSize.width;\n }\n }\n return this._maxWidth;\n }\n\n /**\n * Adds a new beat to this column.\n * Returns true if the column's width has increased. This is an indicator\n * to the caller that a layout of all other views in this column is needed\n * so the refresh can be scheduled at some time.\n */\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added?\n this.beats.push(beat);\n this.needsLayout = true;\n /*\n const beatView = this.viewForBeat(beat);\n beatView.add(atomView);\n\n const lineWidth = beatView.requiredWidth;\n if (lineWidth > this._maxWidth) {\n this._maxWidth = lineWidth;\n return beatView;\n // return true;\n } else {\n // Our width is already less than max width so apply layout\n // on this line only - ie the \"entire\" beat column does not need\n // an update.\n beatView.layout();\n }\n return null;\n */\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n atomIter: AtomIterator;\n durIter: DurationIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (flatAtom: FlatAtom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.atomIter = new AtomIterator();\n this.durIter = new DurationIterator(this.atomIter);\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start at beginning\n // of a cycle. Butif the start offset is < 0 then the startIndex should also shift\n // accordingly\n this.startIndex = index;\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb).factorized : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new FlatAtom(new Space(this.beatOffset.timesNum(apb))));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.atomIter.push(...atoms);\n while (this.durIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [flatAtoms, filled] = this.durIter.get(currBeat.remaining);\n TSU.assert(flatAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const flatAtom of flatAtoms) {\n TSU.assert(currBeat.add(flatAtom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(flatAtom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n}\n\nexport class LayoutParams {\n private static counter = 0;\n readonly uuid = LayoutParams.counter++;\n beatDuration: number;\n cycle: Cycle;\n protected _lineBreaks: number[];\n private _rowStartOffsets: Fraction[];\n private _rowEndOffsets: Fraction[];\n private _rowDurations: Fraction[];\n private _totalLayoutDuration;\n private _beatLayouts: [CyclePosition, Fraction][][];\n private _totalBeats: number;\n\n constructor(config?: any) {\n config = config || {};\n this.beatDuration = config.beatDuration || 1;\n if (\"cycle\" in config) this.cycle = config.cycle;\n if (!this.cycle || this.cycle.duration.isZero) {\n this.cycle = Cycle.DEFAULT;\n }\n\n this._rowStartOffsets = [];\n this._rowEndOffsets = [];\n this._rowDurations = [];\n this._totalLayoutDuration = ZERO;\n this._totalBeats = 0;\n this._beatLayouts = [];\n this.lineBreaks = config.lineBreaks || config.layout || [];\n }\n\n equals(another: this): boolean {\n return (\n // super.equals(another) &&\n this.beatDuration == another.beatDuration &&\n this.cycle.equals(another.cycle) &&\n this.lineBreaksEqual(another._lineBreaks)\n );\n }\n\n lineBreaksEqual(another: number[]): boolean {\n return this._lineBreaks.length == another.length && this._lineBreaks.every((x, i) => x == another[i]);\n }\n\n debugValue(): any {\n return {\n // ...super.debugValue(),\n cycle: this.cycle?.debugValue(),\n beatDuration: this.beatDuration,\n lineBreaks: this._lineBreaks,\n };\n }\n\n /**\n * Returns the \"location\" of a beat within a layout.\n *\n * Lines are broken into beats of notes (which can be changed) and those beats\n * are aligned as per the specs in the LayoutParams (breaks).\n *\n * This methods returns the triple: [layoutLine, layoutColumn, rowOffset]\n * where\n *\n * layoutLine: The particular line in the layout break spec this index falls in. Note\n * that since lines can start with negative offsets, we can even return a\n * layoutLine that is towards the end and then go back to 0, eg 4, 0, 1, 2, 3, 4 ...\n * layoutColumn: The column within the layoutLine line where this beat falls.\n * rowOffset: The note offset of the beat from the start of the row/line\n * (not from the start of the cycle).\n *\n * Note the beatIndex can also be negative so we can return a beat starting from before\n * the cycle starting point.\n *\n * To calculate the \"real\" line globally simply do:\n *\n * realLine = [Math.floor(beatIndex / this.totalBeats) + layoutLine;\n */\n getBeatLocation(beat: Beat): [number, number, Fraction] {\n const modIndex = beat.index % this.totalBeats;\n let total = 0;\n for (let i = 0; i < this._lineBreaks.length; i++) {\n if (modIndex < total + this._lineBreaks[i]) {\n // TODO: What is the right offset here?\n let offset = ZERO;\n const startBeat = beat;\n if (modIndex > total) {\n const cursor = new CycleCursor(this.cycle, beat.barIndex, beat.beatIndex, beat.instance);\n let [pos, duration] = cursor.prev;\n for (let i = total; i < modIndex; i++) {\n [pos, duration] = cursor.prev;\n offset = offset.plus(duration.timesNum(this.beatDuration));\n }\n }\n return [i, modIndex - total, offset];\n }\n total += this._lineBreaks[i];\n }\n throw new Error(\"Invalid beat index: \" + beat.index);\n return [-1, -1, ZERO];\n }\n\n /**\n * Return the line layout - ie number of beats in each line - as a\n * repeating pattern.\n *\n * For example 4,2,4 indicates that the notes in our song should be\n * laid out 4 beats in line 1, 2 beats in line 2, 4 beats in line 3 and\n * 4 beats in line 4 and so on as long as there are more notes available\n * in this line.\n */\n get lineBreaks(): number[] {\n if (!this._lineBreaks || this._lineBreaks.length == 0) {\n // trigger a refresh\n this.lineBreaks = [this.cycle.beatCount];\n }\n return this._lineBreaks;\n }\n\n /**\n * Sets the line layout pattern.\n */\n set lineBreaks(val: number[]) {\n this._lineBreaks = val;\n this.refreshLayout();\n }\n\n refreshLayout(): void {\n const cycleIter = this.cycle.iterateBeats();\n const akb = this.beatDuration;\n this._beatLayouts = this.lineBreaks.map((numBeats, index) => {\n const beats: [CyclePosition, Fraction][] = [];\n // see what the beat lengths are here\n for (let i = 0; i < numBeats; i++) {\n const nextCP = cycleIter.next().value;\n nextCP[1] = nextCP[1].timesNum(akb);\n beats.push(nextCP);\n }\n return beats;\n });\n this._totalBeats = this.lineBreaks.reduce((a, b) => a + b, 0);\n this._rowDurations = this._beatLayouts.map((beats) => beats.reduce((x, y) => x.plus(y[1]), ZERO));\n this._rowDurations.forEach((rd, index) => {\n this._rowStartOffsets[index] = index == 0 ? ZERO : this._rowStartOffsets[index - 1].plus(rd);\n });\n this._rowEndOffsets = this._rowDurations.map((rd, index) => {\n return this._rowStartOffsets[index].plus(rd);\n });\n this._totalLayoutDuration = this._rowDurations.reduce((x, y) => x.plus(y), ZERO);\n }\n\n /**\n * Returns the number of beats in each line based on the line layout\n * after taking beatDuration into account.\n */\n get beatLayouts(): ReadonlyArray<ReadonlyArray<[CyclePosition, Fraction]>> {\n if (!this._beatLayouts || this._beatLayouts.length < this.lineBreaks.length) {\n this.refreshLayout();\n }\n return this._beatLayouts;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalBeats(): number {\n this.beatLayouts;\n return this._totalBeats;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalLayoutDuration(): Fraction {\n this.beatLayouts;\n return this._totalLayoutDuration;\n }\n\n /*\n layoutOffsetsFor(offset: Fraction, layoutLine = -1): [number, Fraction] {\n const m1 = offset.mod(this.totalLayoutDuration);\n\n // layoutLine = L such that layout[L].startOffset <= atom.offset % totalLayoutDuration < layout[L].endOffset\n // calculate layoutLine if not provided\n if (layoutLine < 0) {\n // this.beatLayouts should kick off eval of all row offsets, durations etc\n for (let i = 0; i < this.beatLayouts.length; i++) {\n let cmp = this._rowStartOffsets[i].cmp(m1);\n if (cmp >= 0) {\n cmp = m1.cmp(this._rowEndOffsets[i]);\n if (cmp < 0) {\n layoutLine = i;\n break;\n }\n }\n }\n }\n if (layoutLine < 0) {\n throw new Error(\"Atom offset falls outside beat layout range: \" + offset.toString());\n }\n\n // offset = atom.offset % totalLayoutDuration - rowOffset[layoutLine]\n const layoutOffset = m1.minus(this._rowStartOffsets[layoutLine]);\n return [layoutLine, layoutOffset];\n }\n */\n}\n"]}
|
|
1
|
+
{"version":3,"file":"layouts.js","sourceRoot":"","sources":["../../src/layouts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAiB,WAAW,EAAE,MAAM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,CAAC;IAMD,sBAAI,qCAAW;aAAf;YACE,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC3E,IAAI,CAAC,aAAa,EAAE,CAAC;aACtB;YACD,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAKD,sBAAI,oCAAU;aAAd;YACE,IAAI,CAAC,WAAW,CAAC;YACjB,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;;;OAAA;IAKD,sBAAI,6CAAmB;aAAvB;YACE,IAAI,CAAC,WAAW,CAAC;YACjB,OAAO,IAAI,CAAC,oBAAoB,CAAC;QACnC,CAAC;;;OAAA;IAjLc,oBAAO,GAAG,CAAC,CAAC;IA+M7B,mBAAC;CAAA,AAhND,IAgNC;SAhNY,YAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Cycle, CyclePosition, CycleCursor } from \"./cycle\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\n\nexport class LayoutParams {\n private static counter = 0;\n readonly uuid = LayoutParams.counter++;\n beatDuration: number;\n cycle: Cycle;\n protected _lineBreaks: number[];\n private _rowStartOffsets: Fraction[];\n private _rowEndOffsets: Fraction[];\n private _rowDurations: Fraction[];\n private _totalLayoutDuration;\n private _beatLayouts: [CyclePosition, Fraction][][];\n private _totalBeats: number;\n\n constructor(config?: any) {\n config = config || {};\n this.beatDuration = config.beatDuration || 1;\n if (\"cycle\" in config) this.cycle = config.cycle;\n if (!this.cycle || this.cycle.duration.isZero) {\n this.cycle = Cycle.DEFAULT;\n }\n\n this._rowStartOffsets = [];\n this._rowEndOffsets = [];\n this._rowDurations = [];\n this._totalLayoutDuration = ZERO;\n this._totalBeats = 0;\n this._beatLayouts = [];\n this.lineBreaks = config.lineBreaks || config.layout || [];\n }\n\n equals(another: this): boolean {\n return (\n // super.equals(another) &&\n this.beatDuration == another.beatDuration &&\n this.cycle.equals(another.cycle) &&\n this.lineBreaksEqual(another._lineBreaks)\n );\n }\n\n lineBreaksEqual(another: number[]): boolean {\n return this._lineBreaks.length == another.length && this._lineBreaks.every((x, i) => x == another[i]);\n }\n\n debugValue(): any {\n return {\n // ...super.debugValue(),\n cycle: this.cycle?.debugValue(),\n beatDuration: this.beatDuration,\n lineBreaks: this._lineBreaks,\n };\n }\n\n /**\n * Returns the \"location\" of a beat within a layout.\n *\n * Lines are broken into beats of notes (which can be changed) and those beats\n * are aligned as per the specs in the LayoutParams (breaks).\n *\n * This methods returns the triple: [layoutLine, layoutColumn, rowOffset]\n * where\n *\n * layoutLine: The particular line in the layout break spec this index falls in. Note\n * that since lines can start with negative offsets, we can even return a\n * layoutLine that is towards the end and then go back to 0, eg 4, 0, 1, 2, 3, 4 ...\n * layoutColumn: The column within the layoutLine line where this beat falls.\n * rowOffset: The note offset of the beat from the start of the row/line\n * (not from the start of the cycle).\n *\n * Note the beatIndex can also be negative so we can return a beat starting from before\n * the cycle starting point.\n *\n * To calculate the \"real\" line globally simply do:\n *\n * realLine = [Math.floor(beatIndex / this.totalBeats) + layoutLine;\n */\n getBeatLocation(beat: {\n index: number;\n barIndex: number;\n beatIndex: number;\n instance: number;\n }): [number, number, Fraction] {\n const modIndex = beat.index % this.totalBeats;\n let total = 0;\n for (let i = 0; i < this._lineBreaks.length; i++) {\n if (modIndex < total + this._lineBreaks[i]) {\n // TODO: What is the right offset here?\n let offset = ZERO;\n const startBeat = beat;\n if (modIndex > total) {\n const cursor = new CycleCursor(this.cycle, beat.barIndex, beat.beatIndex, beat.instance);\n let [pos, duration] = cursor.prev;\n for (let i = total; i < modIndex; i++) {\n [pos, duration] = cursor.prev;\n offset = offset.plus(duration.timesNum(this.beatDuration));\n }\n }\n return [i, modIndex - total, offset];\n }\n total += this._lineBreaks[i];\n }\n throw new Error(\"Invalid beat index: \" + beat.index);\n return [-1, -1, ZERO];\n }\n\n /**\n * Return the line layout - ie number of beats in each line - as a\n * repeating pattern.\n *\n * For example 4,2,4 indicates that the notes in our song should be\n * laid out 4 beats in line 1, 2 beats in line 2, 4 beats in line 3 and\n * 4 beats in line 4 and so on as long as there are more notes available\n * in this line.\n */\n get lineBreaks(): number[] {\n if (!this._lineBreaks || this._lineBreaks.length == 0) {\n // trigger a refresh\n this.lineBreaks = [this.cycle.beatCount];\n }\n return this._lineBreaks;\n }\n\n /**\n * Sets the line layout pattern.\n */\n set lineBreaks(val: number[]) {\n this._lineBreaks = val;\n this.refreshLayout();\n }\n\n refreshLayout(): void {\n const cycleIter = this.cycle.iterateBeats();\n const akb = this.beatDuration;\n this._beatLayouts = this.lineBreaks.map((numBeats, index) => {\n const beats: [CyclePosition, Fraction][] = [];\n // see what the beat lengths are here\n for (let i = 0; i < numBeats; i++) {\n const nextCP = cycleIter.next().value;\n nextCP[1] = nextCP[1].timesNum(akb);\n beats.push(nextCP);\n }\n return beats;\n });\n this._totalBeats = this.lineBreaks.reduce((a, b) => a + b, 0);\n this._rowDurations = this._beatLayouts.map((beats) => beats.reduce((x, y) => x.plus(y[1]), ZERO));\n this._rowDurations.forEach((rd, index) => {\n this._rowStartOffsets[index] = index == 0 ? ZERO : this._rowStartOffsets[index - 1].plus(rd);\n });\n this._rowEndOffsets = this._rowDurations.map((rd, index) => {\n return this._rowStartOffsets[index].plus(rd);\n });\n this._totalLayoutDuration = this._rowDurations.reduce((x, y) => x.plus(y), ZERO);\n }\n\n /**\n * Returns the number of beats in each line based on the line layout\n * after taking beatDuration into account.\n */\n get beatLayouts(): ReadonlyArray<ReadonlyArray<[CyclePosition, Fraction]>> {\n if (!this._beatLayouts || this._beatLayouts.length < this.lineBreaks.length) {\n this.refreshLayout();\n }\n return this._beatLayouts;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalBeats(): number {\n this.beatLayouts;\n return this._totalBeats;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalLayoutDuration(): Fraction {\n this.beatLayouts;\n return this._totalLayoutDuration;\n }\n\n /*\n layoutOffsetsFor(offset: Fraction, layoutLine = -1): [number, Fraction] {\n const m1 = offset.mod(this.totalLayoutDuration);\n\n // layoutLine = L such that layout[L].startOffset <= atom.offset % totalLayoutDuration < layout[L].endOffset\n // calculate layoutLine if not provided\n if (layoutLine < 0) {\n // this.beatLayouts should kick off eval of all row offsets, durations etc\n for (let i = 0; i < this.beatLayouts.length; i++) {\n let cmp = this._rowStartOffsets[i].cmp(m1);\n if (cmp >= 0) {\n cmp = m1.cmp(this._rowEndOffsets[i]);\n if (cmp < 0) {\n layoutLine = i;\n break;\n }\n }\n }\n }\n if (layoutLine < 0) {\n throw new Error(\"Atom offset falls outside beat layout range: \" + offset.toString());\n }\n\n // offset = atom.offset % totalLayoutDuration - rowOffset[layoutLine]\n const layoutOffset = m1.minus(this._rowStartOffsets[layoutLine]);\n return [layoutLine, layoutOffset];\n }\n */\n}\n"]}
|
package/lib/esm/loader.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
2
|
import * as G from "galore";
|
|
3
|
-
import { BeatLayout, Beat } from "./
|
|
3
|
+
import { BeatLayout, Beat } from "./beats";
|
|
4
4
|
import { Notation } from "./notation";
|
|
5
|
+
export declare function parse(input: string): [Notation, G.ParseError[]];
|
|
5
6
|
export declare function load(codeText: string, config?: any): [Notation, Map<number, Beat[][]>, Map<number, BeatLayout>, G.ParseError[], TSU.StringMap<number>];
|