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