@libraz/libcantus 1.1.0 → 1.3.0
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 +4 -0
- package/README_ja.md +4 -0
- package/dist/analyze/index.cjs +31 -7
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +155 -9
- package/dist/analyze/index.d.ts +155 -9
- package/dist/analyze/index.js +37 -13
- package/dist/{chunk-TT6PKMPR.cjs → chunk-35NBV2FT.cjs} +16 -16
- package/dist/{chunk-TT6PKMPR.cjs.map → chunk-35NBV2FT.cjs.map} +1 -1
- package/dist/{chunk-YPB3A3EY.cjs → chunk-3R3QVKY5.cjs} +314 -285
- package/dist/chunk-3R3QVKY5.cjs.map +1 -0
- package/dist/{chunk-GDKE6RQW.cjs → chunk-4R2LWV7E.cjs} +691 -413
- package/dist/chunk-4R2LWV7E.cjs.map +1 -0
- package/dist/{chunk-RVS4G4MR.cjs → chunk-76ZBTRG2.cjs} +198 -198
- package/dist/{chunk-RVS4G4MR.cjs.map → chunk-76ZBTRG2.cjs.map} +1 -1
- package/dist/{chunk-X6RJAHII.js → chunk-7KG3RTYS.js} +2 -2
- package/dist/{chunk-PQL7E5F6.js → chunk-AGOVW7U6.js} +1 -1
- package/dist/{chunk-PQL7E5F6.js.map → chunk-AGOVW7U6.js.map} +1 -1
- package/dist/{chunk-5KW7DNCJ.cjs → chunk-B2PW6EHN.cjs} +2423 -453
- package/dist/chunk-B2PW6EHN.cjs.map +1 -0
- package/dist/{chunk-J772DL3B.cjs → chunk-CGBADIO5.cjs} +53 -53
- package/dist/{chunk-J772DL3B.cjs.map → chunk-CGBADIO5.cjs.map} +1 -1
- package/dist/{chunk-R5VUXQMP.js → chunk-CPMB7P75.js} +1978 -8
- package/dist/chunk-CPMB7P75.js.map +1 -0
- package/dist/{chunk-VLE5R7PF.js → chunk-GNVN4PPJ.js} +1874 -8
- package/dist/chunk-GNVN4PPJ.js.map +1 -0
- package/dist/{chunk-Q6R3QAZD.cjs → chunk-IFZDWIKM.cjs} +2199 -333
- package/dist/chunk-IFZDWIKM.cjs.map +1 -0
- package/dist/{chunk-DKICR7AN.js → chunk-IPEF6NWB.js} +296 -18
- package/dist/chunk-IPEF6NWB.js.map +1 -0
- package/dist/{chunk-AWEMD747.js → chunk-M5RYMAFI.js} +3 -3
- package/dist/{chunk-HSY2VQXZ.js → chunk-MLBPXA4Z.js} +330 -728
- package/dist/chunk-MLBPXA4Z.js.map +1 -0
- package/dist/{chunk-H66ARFU5.js → chunk-NB25P3EH.js} +3 -3
- package/dist/{chunk-5JJ6EHEZ.cjs → chunk-NM7UAMC3.cjs} +62 -62
- package/dist/{chunk-5JJ6EHEZ.cjs.map → chunk-NM7UAMC3.cjs.map} +1 -1
- package/dist/{chunk-R7B5N2JK.cjs → chunk-PM4XJE2Y.cjs} +47 -47
- package/dist/{chunk-R7B5N2JK.cjs.map → chunk-PM4XJE2Y.cjs.map} +1 -1
- package/dist/{chunk-7GOKQJTQ.js → chunk-PUKJP2Z5.js} +2 -2
- package/dist/{chunk-QCXYKSZS.cjs → chunk-PWC4CRWT.cjs} +19 -19
- package/dist/{chunk-QCXYKSZS.cjs.map → chunk-PWC4CRWT.cjs.map} +1 -1
- package/dist/{chunk-FPBZFNCD.js → chunk-RFIBF2RR.js} +47 -18
- package/dist/{chunk-FPBZFNCD.js.map → chunk-RFIBF2RR.js.map} +1 -1
- package/dist/{chunk-XKSO2V5I.cjs → chunk-S5BKZZGM.cjs} +1 -1
- package/dist/{chunk-XKSO2V5I.cjs.map → chunk-S5BKZZGM.cjs.map} +1 -1
- package/dist/{chunk-HOHFYGKW.js → chunk-UMWZ4ZET.js} +2 -2
- package/dist/{chunk-XVMJO3QF.cjs → chunk-YFA7X2F6.cjs} +489 -887
- package/dist/chunk-YFA7X2F6.cjs.map +1 -0
- package/dist/{chunk-57WB2EDF.js → chunk-ZBUROTJQ.js} +3 -3
- package/dist/{coerce-wwdELNYS.d.ts → coerce-DP0vYu-x.d.ts} +77 -1
- package/dist/{coerce-CJlgULrQ.d.cts → coerce-DRERzdve.d.cts} +77 -1
- package/dist/core/index.cjs +5 -5
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +4 -4
- package/dist/generate/index.cjs +20 -8
- package/dist/generate/index.cjs.map +1 -1
- package/dist/generate/index.d.cts +87 -9
- package/dist/generate/index.d.ts +87 -9
- package/dist/generate/index.js +19 -7
- package/dist/{index-BaoKVVhE.d.cts → index-B9QLziDe.d.cts} +2 -2
- package/dist/{index-CnHQgqNh.d.ts → index-BHIUyjhZ.d.ts} +2 -2
- package/dist/{index-CBCP84rv.d.cts → index-BL5N2Oyz.d.cts} +1 -1
- package/dist/{index-D_hzxD8w.d.cts → index-BMweUlm5.d.cts} +3 -0
- package/dist/{index-Ci3xyows.d.ts → index-CL4b4gUQ.d.ts} +3 -0
- package/dist/{index-BzLNkmA7.d.cts → index-CY-3NVfy.d.cts} +486 -5
- package/dist/{index-CnIdP4EZ.d.ts → index-Dw2DP7vm.d.ts} +1 -1
- package/dist/{index-DpC-mDlV.d.ts → index-zaZdmnU4.d.ts} +486 -5
- package/dist/index.cjs +49 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +55 -19
- package/dist/{masks-O73Rhj5d.d.ts → masks-Cc7-MzzY.d.ts} +1 -1
- package/dist/{masks-C8TWLFIi.d.cts → masks-pADfTOiD.d.cts} +1 -1
- package/dist/model/index.cjs +12 -12
- package/dist/model/index.d.cts +213 -16
- package/dist/model/index.d.ts +213 -16
- package/dist/model/index.js +11 -11
- package/dist/{index-DTsKaPaC.d.cts → profile-CQMEqdH9.d.cts} +88 -601
- package/dist/{index-BUtIf2go.d.ts → profile-DLdlIpS9.d.ts} +88 -601
- package/dist/theory/index.cjs +5 -5
- package/dist/theory/index.d.cts +7 -7
- package/dist/theory/index.d.ts +7 -7
- package/dist/theory/index.js +4 -4
- package/dist/{index-BpWOhkkE.d.ts → types-D-XgxGvp.d.cts} +1170 -14
- package/dist/{index-B3WCj_Hm.d.cts → types-Dh7C064C.d.ts} +1170 -14
- package/package.json +6 -5
- package/dist/chunk-5KW7DNCJ.cjs.map +0 -1
- package/dist/chunk-DKICR7AN.js.map +0 -1
- package/dist/chunk-GDKE6RQW.cjs.map +0 -1
- package/dist/chunk-HSY2VQXZ.js.map +0 -1
- package/dist/chunk-Q6R3QAZD.cjs.map +0 -1
- package/dist/chunk-R5VUXQMP.js.map +0 -1
- package/dist/chunk-VLE5R7PF.js.map +0 -1
- package/dist/chunk-XVMJO3QF.cjs.map +0 -1
- package/dist/chunk-YPB3A3EY.cjs.map +0 -1
- /package/dist/{chunk-X6RJAHII.js.map → chunk-7KG3RTYS.js.map} +0 -0
- /package/dist/{chunk-AWEMD747.js.map → chunk-M5RYMAFI.js.map} +0 -0
- /package/dist/{chunk-H66ARFU5.js.map → chunk-NB25P3EH.js.map} +0 -0
- /package/dist/{chunk-7GOKQJTQ.js.map → chunk-PUKJP2Z5.js.map} +0 -0
- /package/dist/{chunk-HOHFYGKW.js.map → chunk-UMWZ4ZET.js.map} +0 -0
- /package/dist/{chunk-57WB2EDF.js.map → chunk-ZBUROTJQ.js.map} +0 -0
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkS5BKZZGMcjs = require('./chunk-S5BKZZGM.cjs');
|
|
14
14
|
|
|
15
15
|
// src/core/instrument/profile.ts
|
|
16
16
|
var LIMBS = Object.freeze(["rightHand", "leftHand", "rightFoot", "leftFoot"]);
|
|
17
17
|
function toInstrumentProfile(value, name = "instrument") {
|
|
18
18
|
if (typeof value !== "object" || value === null) {
|
|
19
|
-
throw new (0,
|
|
19
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`${name} must be an instrument profile; received ${typeof value}`);
|
|
20
20
|
}
|
|
21
21
|
const data = "toJSON" in value && typeof value.toJSON === "function" ? value.toJSON() : value;
|
|
22
22
|
const kind = _optionalChain([data, 'optionalAccess', _2 => _2.kind]);
|
|
23
23
|
if (kind !== "stringed" && kind !== "percussion") {
|
|
24
|
-
throw new (0,
|
|
24
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
25
25
|
`${name} must be a stringed or percussion profile; received kind ${String(kind)}`
|
|
26
26
|
);
|
|
27
27
|
}
|
|
@@ -31,7 +31,7 @@ function toInstrumentProfile(value, name = "instrument") {
|
|
|
31
31
|
function toStringedProfile(value, name = "instrument") {
|
|
32
32
|
const profile = toInstrumentProfile(value, name);
|
|
33
33
|
if (profile.kind !== "stringed") {
|
|
34
|
-
throw new (0,
|
|
34
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
35
35
|
`${name} must be a stringed instrument; ${profile.name} has no strings`
|
|
36
36
|
);
|
|
37
37
|
}
|
|
@@ -41,50 +41,50 @@ var MAX_FRETS = 127;
|
|
|
41
41
|
var MAX_POLYPHONY = 128;
|
|
42
42
|
function assertProfile(profile) {
|
|
43
43
|
if (typeof profile.name !== "string" || profile.name === "") {
|
|
44
|
-
throw new (0,
|
|
45
|
-
`instrument name must be a non-empty string; received ${
|
|
44
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
45
|
+
`instrument name must be a non-empty string; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, profile.name)}`
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
if (!Array.isArray(profile.articulations)) {
|
|
49
|
-
throw new (0,
|
|
50
|
-
`${profile.name} articulations must be an array; received ${
|
|
49
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
50
|
+
`${profile.name} articulations must be an array; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, profile.articulations)}`
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
for (const [index, articulation] of profile.articulations.entries()) {
|
|
54
|
-
|
|
54
|
+
_chunkS5BKZZGMcjs.assertOneOf.call(void 0, articulation, _chunkS5BKZZGMcjs.ARTICULATIONS, `${profile.name} articulations[${index}]`);
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
_chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, profile.polyphony, `${profile.name} polyphony`, MAX_POLYPHONY);
|
|
57
57
|
if (profile.kind === "stringed") {
|
|
58
58
|
if (!Array.isArray(profile.tuning) || profile.tuning.length === 0) {
|
|
59
|
-
throw new (0,
|
|
59
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`${profile.name} must have at least one string`);
|
|
60
60
|
}
|
|
61
61
|
for (const [index, open] of profile.tuning.entries()) {
|
|
62
|
-
|
|
62
|
+
_chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, open, `${profile.name} tuning[${index}]`);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, profile.frets, `${profile.name} frets`, 0, MAX_FRETS);
|
|
65
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, profile.maxStretch, `${profile.name} maxStretch`, 0, MAX_FRETS);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (!Array.isArray(profile.limbs) || profile.limbs.length === 0) {
|
|
69
|
-
throw new (0,
|
|
69
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`${profile.name} must have at least one limb`);
|
|
70
70
|
}
|
|
71
71
|
for (const [index, limb] of profile.limbs.entries()) {
|
|
72
|
-
|
|
72
|
+
_chunkS5BKZZGMcjs.assertOneOf.call(void 0, limb, LIMBS, `${profile.name} limbs[${index}]`);
|
|
73
73
|
}
|
|
74
74
|
if (typeof profile.reach !== "object" || profile.reach === null) {
|
|
75
|
-
throw new (0,
|
|
76
|
-
`${profile.name} reach must be a table of limbs by voice; received ${
|
|
75
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
76
|
+
`${profile.name} reach must be a table of limbs by voice; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, profile.reach)}`
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
const voices = Object.keys(profile.reach);
|
|
80
80
|
for (const key of voices) {
|
|
81
|
-
|
|
81
|
+
_chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, Number(key), `${profile.name} reach pitch`);
|
|
82
82
|
}
|
|
83
83
|
if (voices.every((key) => reachOf(profile, Number(key)).length === 0)) {
|
|
84
|
-
throw new (0,
|
|
84
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`${profile.name} must have at least one voice within reach`);
|
|
85
85
|
}
|
|
86
86
|
for (const pitch of _nullishCoalesce(profile.overdub, () => ( []))) {
|
|
87
|
-
|
|
87
|
+
_chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, pitch, `${profile.name} overdub pitch`);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
function reachOf(profile, pitch) {
|
|
@@ -120,7 +120,7 @@ function rangeIn(profile) {
|
|
|
120
120
|
}
|
|
121
121
|
function canSound(profile, pitch) {
|
|
122
122
|
const resolved = toInstrumentProfile(profile, "instrument");
|
|
123
|
-
|
|
123
|
+
_chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, pitch, "pitch");
|
|
124
124
|
return soundsIn(resolved, pitch);
|
|
125
125
|
}
|
|
126
126
|
function soundsIn(profile, pitch) {
|
|
@@ -131,7 +131,7 @@ function soundsIn(profile, pitch) {
|
|
|
131
131
|
}
|
|
132
132
|
function fingeringsFor(profile, pitch) {
|
|
133
133
|
const stringed = toStringedProfile(profile, "instrument");
|
|
134
|
-
|
|
134
|
+
_chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, pitch, "pitch");
|
|
135
135
|
return fingeringsIn(stringed, pitch);
|
|
136
136
|
}
|
|
137
137
|
function fingeringsIn(stringed, pitch) {
|
|
@@ -150,7 +150,7 @@ function fingeringsIn(stringed, pitch) {
|
|
|
150
150
|
}
|
|
151
151
|
function foldIntoRange(pitch, profile) {
|
|
152
152
|
const resolved = toInstrumentProfile(profile, "instrument");
|
|
153
|
-
|
|
153
|
+
_chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, pitch, "pitch");
|
|
154
154
|
return foldIn(pitch, resolved);
|
|
155
155
|
}
|
|
156
156
|
function foldIn(pitch, resolved) {
|
|
@@ -181,9 +181,9 @@ var MAX_DIFFICULTY = 5;
|
|
|
181
181
|
var STRING_CROSSING_COST = 2;
|
|
182
182
|
var SIMULTANEITY_BEATS = 1 / 128;
|
|
183
183
|
function playability(notes, profile, bpm) {
|
|
184
|
-
|
|
184
|
+
_chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, notes, "playability notes", { allowNonPositiveDuration: true });
|
|
185
185
|
if (bpm !== void 0) {
|
|
186
|
-
|
|
186
|
+
_chunkS5BKZZGMcjs.assertRange.call(void 0, bpm, Number.MIN_VALUE, 1e3, "playability bpm");
|
|
187
187
|
}
|
|
188
188
|
const instrument = toInstrumentProfile(profile, "playability profile");
|
|
189
189
|
const order = notes.map((_, index) => index).sort((a, b) => {
|
|
@@ -246,7 +246,7 @@ function checkExistence(state, profile, sounds) {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
function isSimultaneous(anchorBeat, startBeat) {
|
|
249
|
-
return startBeat - anchorBeat <= SIMULTANEITY_BEATS +
|
|
249
|
+
return startBeat - anchorBeat <= SIMULTANEITY_BEATS + _chunkS5BKZZGMcjs.BEAT_EPS;
|
|
250
250
|
}
|
|
251
251
|
function soundingGroups(state) {
|
|
252
252
|
const groups = [];
|
|
@@ -265,7 +265,7 @@ function soundingGroups(state) {
|
|
|
265
265
|
anchor = at;
|
|
266
266
|
active = active.filter((member) => {
|
|
267
267
|
const held = state.notes[member];
|
|
268
|
-
return held !== void 0 && held.startBeat + held.durationBeat > at +
|
|
268
|
+
return held !== void 0 && held.startBeat + held.durationBeat > at + _chunkS5BKZZGMcjs.BEAT_EPS;
|
|
269
269
|
});
|
|
270
270
|
while (cursor < state.order.length) {
|
|
271
271
|
const candidateIndex = state.order[cursor];
|
|
@@ -273,7 +273,7 @@ function soundingGroups(state) {
|
|
|
273
273
|
if (!candidate || !isSimultaneous(at, candidate.startBeat)) {
|
|
274
274
|
break;
|
|
275
275
|
}
|
|
276
|
-
if (candidateIndex !== void 0 && candidate.startBeat + candidate.durationBeat > at +
|
|
276
|
+
if (candidateIndex !== void 0 && candidate.startBeat + candidate.durationBeat > at + _chunkS5BKZZGMcjs.BEAT_EPS) {
|
|
277
277
|
active.push(candidateIndex);
|
|
278
278
|
}
|
|
279
279
|
cursor += 1;
|
|
@@ -298,7 +298,7 @@ function placeOnNeck(state, profile) {
|
|
|
298
298
|
continue;
|
|
299
299
|
}
|
|
300
300
|
const free = candidates.filter(
|
|
301
|
-
(candidate) => (_nullishCoalesce(stringFreeAt[candidate.string], () => ( 0))) <= note.startBeat +
|
|
301
|
+
(candidate) => (_nullishCoalesce(stringFreeAt[candidate.string], () => ( 0))) <= note.startBeat + _chunkS5BKZZGMcjs.BEAT_EPS
|
|
302
302
|
);
|
|
303
303
|
if (free.length === 0) {
|
|
304
304
|
const blocked = candidates.map((candidate) => stringHeldBy[candidate.string]).filter((held) => held !== void 0);
|
|
@@ -349,7 +349,7 @@ function checkShiftSpeed(state, profile, fromIndex, toIndex, from, to) {
|
|
|
349
349
|
}
|
|
350
350
|
const seconds = (note.startBeat - previousNote.startBeat) * secondsPerBeat;
|
|
351
351
|
const shift = Math.abs(to.fret - from.fret);
|
|
352
|
-
if (seconds <=
|
|
352
|
+
if (seconds <= _chunkS5BKZZGMcjs.BEAT_EPS || shift === 0) {
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
355
|
if (shift / seconds > MAX_FRET_SHIFT_PER_SECOND) {
|
|
@@ -506,7 +506,7 @@ function checkStrokeSpeed(state, profile, fromIndex, toIndex, limb) {
|
|
|
506
506
|
return;
|
|
507
507
|
}
|
|
508
508
|
const seconds = (note.startBeat - previousNote.startBeat) * secondsPerBeat;
|
|
509
|
-
if (seconds <=
|
|
509
|
+
if (seconds <= _chunkS5BKZZGMcjs.BEAT_EPS || seconds >= MIN_LIMB_STROKE_SECONDS) {
|
|
510
510
|
return;
|
|
511
511
|
}
|
|
512
512
|
state.issues.push({
|
|
@@ -545,7 +545,7 @@ function difficultyOf(state, bpm) {
|
|
|
545
545
|
last = Math.max(last, note.startBeat + Math.max(0, note.durationBeat));
|
|
546
546
|
}
|
|
547
547
|
const spanBeats = last - first;
|
|
548
|
-
if (!Number.isFinite(spanBeats) || spanBeats <=
|
|
548
|
+
if (!Number.isFinite(spanBeats) || spanBeats <= _chunkS5BKZZGMcjs.BEAT_EPS) {
|
|
549
549
|
return MIN_DIFFICULTY;
|
|
550
550
|
}
|
|
551
551
|
const seconds = spanBeats * 60 / (_nullishCoalesce(bpm, () => ( REFERENCE_BPM)));
|
|
@@ -642,7 +642,7 @@ function absorbSegment(hash, segment, index) {
|
|
|
642
642
|
return next;
|
|
643
643
|
}
|
|
644
644
|
if (typeof segment === "number") {
|
|
645
|
-
|
|
645
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, segment, `seed path segment ${index}`);
|
|
646
646
|
numberBytes.setFloat64(0, segment === 0 ? 0 : segment, true);
|
|
647
647
|
let next = absorb(hash, TAG_NUMBER);
|
|
648
648
|
for (let i = 0; i < 8; i += 1) {
|
|
@@ -650,7 +650,7 @@ function absorbSegment(hash, segment, index) {
|
|
|
650
650
|
}
|
|
651
651
|
return next;
|
|
652
652
|
}
|
|
653
|
-
throw new (0,
|
|
653
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
654
654
|
`seed path segment ${index} must be a string or a number; received ${typeof segment}`
|
|
655
655
|
);
|
|
656
656
|
}
|
|
@@ -660,7 +660,7 @@ function hashPath(domain, root, path) {
|
|
|
660
660
|
for (let index = 0; index < path.length; index += 1) {
|
|
661
661
|
const segment = path[index];
|
|
662
662
|
if (segment === void 0) {
|
|
663
|
-
throw new (0,
|
|
663
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
664
664
|
`seed path segment ${index} must be a string or a number; received undefined`
|
|
665
665
|
);
|
|
666
666
|
}
|
|
@@ -671,23 +671,23 @@ function hashPath(domain, root, path) {
|
|
|
671
671
|
|
|
672
672
|
// src/core/random/positional.ts
|
|
673
673
|
function createPositionalRng(seed) {
|
|
674
|
-
|
|
674
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, seed, "seed", 0, 4294967295);
|
|
675
675
|
return {
|
|
676
676
|
at: (...path) => hashPath(DOMAIN_POSITION, seed, path) / UINT32_RANGE
|
|
677
677
|
};
|
|
678
678
|
}
|
|
679
679
|
function includeAt(rng, complexity, ...path) {
|
|
680
|
-
|
|
680
|
+
_chunkS5BKZZGMcjs.assertRange.call(void 0, complexity, 0, 1, "complexity");
|
|
681
681
|
const draw = rng.at(...path);
|
|
682
682
|
if (!(draw >= 0 && draw < 1)) {
|
|
683
|
-
throw new (0,
|
|
683
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`positional draw must be in [0, 1); received ${draw}`);
|
|
684
684
|
}
|
|
685
685
|
return draw < complexity;
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
// src/core/random/seed.ts
|
|
689
689
|
function deriveSeed(root, ...path) {
|
|
690
|
-
|
|
690
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, root, "root seed", 0, 4294967295);
|
|
691
691
|
return hashPath(DOMAIN_SEED, root, path);
|
|
692
692
|
}
|
|
693
693
|
|
|
@@ -698,9 +698,9 @@ function resolveAlgorithmVersion(requested) {
|
|
|
698
698
|
if (requested === void 0) {
|
|
699
699
|
return ALGORITHM_VERSION;
|
|
700
700
|
}
|
|
701
|
-
|
|
701
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, requested, "algorithm version");
|
|
702
702
|
if (requested < MIN_ALGORITHM_VERSION || requested > ALGORITHM_VERSION) {
|
|
703
|
-
throw new (0,
|
|
703
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
704
704
|
`algorithm version ${requested} is not produced by this build; supported versions are ${MIN_ALGORITHM_VERSION}..${ALGORITHM_VERSION}`
|
|
705
705
|
);
|
|
706
706
|
}
|
|
@@ -709,7 +709,7 @@ function resolveAlgorithmVersion(requested) {
|
|
|
709
709
|
|
|
710
710
|
// src/core/random/index.ts
|
|
711
711
|
function createRng(seed) {
|
|
712
|
-
|
|
712
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, seed, "seed", 0, 4294967295);
|
|
713
713
|
let state = seed >>> 0;
|
|
714
714
|
const next = () => {
|
|
715
715
|
state = state + 1831565813 >>> 0;
|
|
@@ -721,29 +721,29 @@ function createRng(seed) {
|
|
|
721
721
|
return {
|
|
722
722
|
next,
|
|
723
723
|
prob: (p) => {
|
|
724
|
-
|
|
724
|
+
_chunkS5BKZZGMcjs.assertRange.call(void 0, p, 0, 1, "probability");
|
|
725
725
|
return next() < p;
|
|
726
726
|
},
|
|
727
727
|
range: (lo, hi) => {
|
|
728
|
-
|
|
729
|
-
|
|
728
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, lo, "range lower bound");
|
|
729
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, hi, "range upper bound");
|
|
730
730
|
if (lo > hi) {
|
|
731
|
-
throw new (0,
|
|
731
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
732
732
|
`range lower bound must not exceed upper bound; received ${lo} > ${hi}`
|
|
733
733
|
);
|
|
734
734
|
}
|
|
735
|
-
|
|
735
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, hi - lo, "range span", 0);
|
|
736
736
|
return lo + Math.floor(next() * (hi - lo + 1));
|
|
737
737
|
},
|
|
738
738
|
float: (lo, hi) => {
|
|
739
|
-
|
|
740
|
-
|
|
739
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, lo, "float lower bound");
|
|
740
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, hi, "float upper bound");
|
|
741
741
|
if (lo > hi) {
|
|
742
|
-
throw new (0,
|
|
742
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
743
743
|
`float lower bound must not exceed upper bound; received ${lo} > ${hi}`
|
|
744
744
|
);
|
|
745
745
|
}
|
|
746
|
-
|
|
746
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, hi - lo, "float span");
|
|
747
747
|
return lo + next() * (hi - lo);
|
|
748
748
|
}
|
|
749
749
|
};
|
|
@@ -774,4 +774,4 @@ function createRng(seed) {
|
|
|
774
774
|
|
|
775
775
|
|
|
776
776
|
exports.LIMBS = LIMBS; exports.toInstrumentProfile = toInstrumentProfile; exports.toStringedProfile = toStringedProfile; exports.instrumentRange = instrumentRange; exports.rangeIn = rangeIn; exports.canSound = canSound; exports.soundsIn = soundsIn; exports.fingeringsFor = fingeringsFor; exports.fingeringsIn = fingeringsIn; exports.foldIntoRange = foldIntoRange; exports.foldIn = foldIn; exports.playability = playability; exports.BASS_4_STRING = BASS_4_STRING; exports.BASS_5_STRING = BASS_5_STRING; exports.GUITAR_STANDARD = GUITAR_STANDARD; exports.GUITAR_DROP_D = GUITAR_DROP_D; exports.createPositionalRng = createPositionalRng; exports.includeAt = includeAt; exports.deriveSeed = deriveSeed; exports.ALGORITHM_VERSION = ALGORITHM_VERSION; exports.MIN_ALGORITHM_VERSION = MIN_ALGORITHM_VERSION; exports.resolveAlgorithmVersion = resolveAlgorithmVersion; exports.createRng = createRng;
|
|
777
|
-
//# sourceMappingURL=chunk-
|
|
777
|
+
//# sourceMappingURL=chunk-CGBADIO5.cjs.map
|