@msb235/blits 0.13.0 → 0.15.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/CHANGELOG.md +183 -0
- package/README.md +20 -3
- package/dist/ahead.d.ts +26 -0
- package/dist/ahead.js +264 -0
- package/dist/around.d.ts +11 -0
- package/dist/around.js +32 -0
- package/dist/bare.js +15 -7
- package/dist/blank.d.ts +10 -0
- package/dist/blank.js +26 -0
- package/dist/blend.d.ts +2 -1
- package/dist/blend.js +1 -6
- package/dist/bound.d.ts +70 -0
- package/dist/bound.js +351 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.js +7 -5
- package/dist/changes.d.ts +24 -0
- package/dist/changes.js +189 -0
- package/dist/channels.d.ts +39 -13
- package/dist/channels.js +14 -5
- package/dist/closed.d.ts +1 -0
- package/dist/closed.js +45 -1
- package/dist/color.d.ts +12 -10
- package/dist/color.js +25 -25
- package/dist/columns.js +7 -3
- package/dist/contribution.d.ts +30 -0
- package/dist/contribution.js +374 -0
- package/dist/copyout.d.ts +10 -0
- package/dist/copyout.js +69 -24
- package/dist/crowd.d.ts +8 -2
- package/dist/crowd.js +4 -5
- package/dist/cue.d.ts +8 -1
- package/dist/cue.js +47 -14
- package/dist/cut.d.ts +8 -0
- package/dist/cut.js +4 -0
- package/dist/drop.d.ts +9 -0
- package/dist/drop.js +84 -0
- package/dist/due.d.ts +24 -5
- package/dist/due.js +113 -33
- package/dist/easing.d.ts +4 -4
- package/dist/easing.js +3 -3
- package/dist/everyone.d.ts +3 -2
- package/dist/everyone.js +3 -3
- package/dist/fade.d.ts +2 -1
- package/dist/fade.js +2 -1
- package/dist/fill.d.ts +3 -2
- package/dist/fill.js +51 -19
- package/dist/fit.d.ts +44 -26
- package/dist/fit.js +10 -9
- package/dist/fling.d.ts +66 -0
- package/dist/fling.js +162 -0
- package/dist/fold.d.ts +4 -37
- package/dist/fold.js +5 -512
- package/dist/gather.d.ts +12 -7
- package/dist/gather.js +179 -44
- package/dist/gone.js +2 -2
- package/dist/grid.d.ts +47 -0
- package/dist/grid.js +247 -0
- package/dist/handle.d.ts +3 -0
- package/dist/handle.js +19 -8
- package/dist/held.d.ts +2 -1
- package/dist/history.d.ts +6 -5
- package/dist/history.js +9 -9
- package/dist/hosts.js +9 -15
- package/dist/index.d.ts +5 -4
- package/dist/keyfill.d.ts +1 -1
- package/dist/keyfill.js +5 -3
- package/dist/keyrows.d.ts +12 -0
- package/dist/keyrows.js +99 -12
- package/dist/lane.d.ts +36 -6
- package/dist/lane.js +32 -1
- package/dist/lanes.d.ts +23 -8
- package/dist/lanes.js +29 -8
- package/dist/leavings.d.ts +2 -2
- package/dist/leavings.js +1 -1
- package/dist/lives.d.ts +47 -0
- package/dist/lives.js +180 -0
- package/dist/meet.d.ts +2 -2
- package/dist/meet.js +90 -4
- package/dist/mixer.d.ts +61 -35
- package/dist/mixer.js +64 -169
- package/dist/motion.d.ts +19 -106
- package/dist/motion.js +60 -13
- package/dist/motions.d.ts +62 -150
- package/dist/motions.js +57 -369
- package/dist/move.js +24 -1
- package/dist/moved.d.ts +1 -1
- package/dist/moved.js +16 -7
- package/dist/named.d.ts +0 -1
- package/dist/named.js +20 -2
- package/dist/numbers.d.ts +2 -0
- package/dist/numbers.js +4 -0
- package/dist/owed.d.ts +2 -0
- package/dist/owed.js +4 -0
- package/dist/pack.d.ts +3 -1
- package/dist/pack.js +4 -3
- package/dist/patch.d.ts +7 -3
- package/dist/patch.js +6 -2
- package/dist/places.d.ts +53 -0
- package/dist/places.js +171 -0
- package/dist/plot.d.ts +12 -0
- package/dist/plot.js +52 -0
- package/dist/project.d.ts +4 -4
- package/dist/project.js +9 -211
- package/dist/pull.js +11 -8
- package/dist/qualify.js +84 -21
- package/dist/reading.d.ts +6 -0
- package/dist/reading.js +5 -0
- package/dist/record.d.ts +5 -1
- package/dist/record.js +4 -2
- package/dist/relink.d.ts +1 -1
- package/dist/restored.d.ts +2 -2
- package/dist/restored.js +1 -1
- package/dist/rests.d.ts +9 -0
- package/dist/rests.js +76 -0
- package/dist/revive.d.ts +3 -2
- package/dist/revive.js +2 -2
- package/dist/{locus.d.ts → role.d.ts} +10 -9
- package/dist/{locus.js → role.js} +3 -3
- package/dist/roles.d.ts +10 -0
- package/dist/roles.js +158 -0
- package/dist/roster.js +3 -3
- package/dist/rotation.d.ts +1 -1
- package/dist/rotation.js +1 -1
- package/dist/rows.js +1 -1
- package/dist/sample.d.ts +2 -2
- package/dist/sample.js +33 -7
- package/dist/seek.js +13 -5
- package/dist/setting.d.ts +27 -0
- package/dist/setting.js +55 -0
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/signals.d.ts +64 -32
- package/dist/signals.js +20 -18
- package/dist/stack.d.ts +5 -5
- package/dist/stack.js +5 -5
- package/dist/standing.d.ts +2 -1
- package/dist/standing.js +3 -2
- package/dist/store.d.ts +9 -0
- package/dist/store.js +24 -0
- package/dist/strays.d.ts +2 -1
- package/dist/strays.js +21 -14
- package/dist/stretch.d.ts +112 -0
- package/dist/stretch.js +9 -0
- package/dist/subject.d.ts +142 -0
- package/dist/subject.js +1 -0
- package/dist/tape.d.ts +9 -5
- package/dist/tape.js +5 -1
- package/dist/then.d.ts +9 -0
- package/dist/then.js +57 -0
- package/dist/ticker.d.ts +4 -4
- package/dist/transport.d.ts +0 -8
- package/dist/transport.js +0 -4
- package/dist/turns.d.ts +4 -3
- package/dist/turns.js +4 -3
- package/dist/types/arc.d.ts +12 -11
- package/dist/types/channel.d.ts +12 -8
- package/dist/types/history.d.ts +35 -19
- package/dist/types/mix.d.ts +222 -161
- package/dist/types/motion.d.ts +151 -0
- package/dist/types/motion.js +1 -0
- package/dist/types/patch.d.ts +69 -34
- package/dist/types/place.d.ts +51 -36
- package/dist/types/transport.d.ts +20 -18
- package/dist/types/voice.d.ts +145 -72
- package/dist/types/watch.d.ts +88 -40
- package/dist/types.d.ts +1 -0
- package/dist/voice.d.ts +9 -141
- package/dist/voice.js +30 -79
- package/dist/warn.d.ts +2 -0
- package/dist/warn.js +1 -1
- package/dist/watch.d.ts +2 -2
- package/dist/watch.js +5 -3
- package/dist/wave.d.ts +4 -3
- package/dist/wave.js +3 -2
- package/dist/weigh.d.ts +7 -1
- package/dist/weigh.js +27 -0
- package/docs/schema.html +223 -37
- package/package.json +6 -2
package/dist/cue.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { blendOf } from './blend.js';
|
|
2
2
|
import { checkHits } from './book.js';
|
|
3
|
+
import { bind, checkWithin } from './bound.js';
|
|
3
4
|
import { changed } from './chain.js';
|
|
4
5
|
import { copyable } from './clone.js';
|
|
5
6
|
import { schedule } from './due.js';
|
|
@@ -15,10 +16,11 @@ import { enlist } from './roster.js';
|
|
|
15
16
|
import { scoredAdd } from './scored.js';
|
|
16
17
|
import { checkChild, refit } from './spans.js';
|
|
17
18
|
import { cuedById, motionOwner } from './strays.js';
|
|
18
|
-
import { record, unplayable } from './tape.js';
|
|
19
|
+
import { record, taping, unplayable } from './tape.js';
|
|
19
20
|
import { Voice } from './voice.js';
|
|
21
|
+
import { warnOnce } from './warn.js';
|
|
20
22
|
export function cue(mix, given) {
|
|
21
|
-
const spec =
|
|
23
|
+
const spec = roleOf(mix, given);
|
|
22
24
|
const patch = spec.patch;
|
|
23
25
|
playable(mix, spec);
|
|
24
26
|
if (spec.from === 'current' && patch.form !== 'keys')
|
|
@@ -33,6 +35,7 @@ export function cue(mix, given) {
|
|
|
33
35
|
checkHits(spec.hits, patch.duration);
|
|
34
36
|
if (spec.marks !== undefined)
|
|
35
37
|
checkMarks(spec.marks, patch.duration);
|
|
38
|
+
checkWithin(mix, spec);
|
|
36
39
|
const anchored = anchor !== undefined && (anchor.start !== undefined || anchor.in !== undefined);
|
|
37
40
|
// A voice an owner holds is placed on the owner's clock: ms from when it starts.
|
|
38
41
|
const local = owner === null ? mix.now : ownerReading(owner, mix.now);
|
|
@@ -44,7 +47,10 @@ export function cue(mix, given) {
|
|
|
44
47
|
? mixAt(mix, spec.start - mix.offset)
|
|
45
48
|
: Number.isNaN(mix.now)
|
|
46
49
|
? 0
|
|
47
|
-
: mix.
|
|
50
|
+
: // A loop asleep on an inert mix syncs next when it wakes, which is the cue's "now".
|
|
51
|
+
mix.asleep
|
|
52
|
+
? Number.POSITIVE_INFINITY
|
|
53
|
+
: mix.now;
|
|
48
54
|
const voice = new Voice(mix.nextId++, spec, patch, spec.fade ?? noFade, local, start, mix.slotOf, mix.channels, mix.opts.host, mix.send, owner);
|
|
49
55
|
if (patch === ownerPatch && mix.fitting !== null)
|
|
50
56
|
voice.fitting = mix.fitting;
|
|
@@ -56,10 +62,16 @@ export function cue(mix, given) {
|
|
|
56
62
|
checkChild(spec, voice);
|
|
57
63
|
if (mix.pace !== null && owner === null && spec.start !== undefined && voice.state === 'pending')
|
|
58
64
|
voice.pinned = spec.start - mix.offset;
|
|
65
|
+
if (start === Number.POSITIVE_INFINITY && !anchored && !owner?.fitting) {
|
|
66
|
+
voice.waking = true;
|
|
67
|
+
mix.waking = true;
|
|
68
|
+
}
|
|
69
|
+
bind(mix, voice);
|
|
59
70
|
enter(mix, voice);
|
|
60
71
|
const h = handle(mix, voice);
|
|
61
72
|
voice.handle = h;
|
|
62
|
-
|
|
73
|
+
if (taping(mix))
|
|
74
|
+
recordCue(mix, h);
|
|
63
75
|
return h;
|
|
64
76
|
}
|
|
65
77
|
const noFade = Object.freeze({});
|
|
@@ -89,21 +101,42 @@ export function fitsKit(patch, kit) {
|
|
|
89
101
|
throw new Error(`blits: channel ${String(channel)} is ${here.kind ?? 'a custom channel'} in this kit, but the patch was written for ${wanted.kind ?? 'a custom channel'}`);
|
|
90
102
|
}
|
|
91
103
|
}
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
/**
|
|
105
|
+
* The spec with its `role` set from `locus`, the name `role` had before, or from a tag the mix
|
|
106
|
+
* declares a role, where it carries one.
|
|
107
|
+
*/
|
|
108
|
+
export function roleOf(mix, given) {
|
|
109
|
+
let spec = given;
|
|
110
|
+
if (spec.locus !== undefined) {
|
|
111
|
+
if (spec.role !== undefined && spec.role !== spec.locus)
|
|
112
|
+
throw new Error(`blits: a voice plays one role, not both role ${spec.role} and locus ${spec.locus}; locus is role's old name`);
|
|
113
|
+
warnOnce(mix, 'locus is renamed role; cue the voice with role');
|
|
114
|
+
const { locus, ...rest } = spec;
|
|
115
|
+
spec = { ...rest, role: locus };
|
|
116
|
+
}
|
|
117
|
+
const roles = mix.roleTags;
|
|
95
118
|
const tags = spec.tags;
|
|
96
|
-
if (
|
|
119
|
+
if (roles === undefined || tags === undefined)
|
|
97
120
|
return spec;
|
|
98
|
-
let
|
|
121
|
+
let role = spec.role;
|
|
99
122
|
for (const tag of tags) {
|
|
100
|
-
if (!
|
|
123
|
+
if (!roles.includes(tag) || tag === role)
|
|
101
124
|
continue;
|
|
102
|
-
if (
|
|
103
|
-
throw new Error(`blits: a voice
|
|
104
|
-
|
|
125
|
+
if (role !== undefined)
|
|
126
|
+
throw new Error(`blits: a voice plays one role, not both ${role} and ${tag}`);
|
|
127
|
+
role = tag;
|
|
105
128
|
}
|
|
106
|
-
return
|
|
129
|
+
return role === spec.role ? spec : { ...spec, role };
|
|
130
|
+
}
|
|
131
|
+
/** The tags `opts` declares roles, from `roles` or `loci`, the name `roles` had before. */
|
|
132
|
+
export function roleTags(opts) {
|
|
133
|
+
const { roles, loci } = opts;
|
|
134
|
+
if (loci === undefined)
|
|
135
|
+
return roles;
|
|
136
|
+
if (roles !== undefined && (roles.length !== loci.length || roles.some((r, i) => r !== loci[i])))
|
|
137
|
+
throw new Error("blits: a mix takes roles or loci, not both; loci is roles' old name");
|
|
138
|
+
warnOnce(opts, 'the mix option loci is renamed roles; make the mix with roles');
|
|
139
|
+
return loci;
|
|
107
140
|
}
|
|
108
141
|
/** Refuses a spec whose patch the mix cannot play, or whose state its history cannot keep. */
|
|
109
142
|
export function playable(mix, spec) {
|
package/dist/cut.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Where history is cut for a seek or read: what frame `seq` made, and before it, is kept. */
|
|
2
|
+
export interface Cut {
|
|
3
|
+
seq: number;
|
|
4
|
+
/** For a read of what a frame showed: of that frame's own changes, only those made before it was read. */
|
|
5
|
+
strict: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Whether a change made in frame `seq` falls inside `cut`; `early` for one made before the frame was read. */
|
|
8
|
+
export declare function within(cut: Cut, seq: number, early?: boolean): boolean;
|
package/dist/cut.js
ADDED
package/dist/drop.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { releasing } from './history.js';
|
|
2
|
+
import type { Mixer } from './mixer.js';
|
|
3
|
+
import type { Motions } from './motions.js';
|
|
4
|
+
import type { Voice } from './voice.js';
|
|
5
|
+
export declare function drop<I, O>(this: Mixer<I, O>, subject: I): void;
|
|
6
|
+
/** Lets `voice` go of a dropped subject. Methods rather than closures, so a drop makes neither. */
|
|
7
|
+
export declare function forgetIn<I, O>(this: Mixer<I, O>, voice: Voice<I, O>, subject: I, kept: ReturnType<typeof releasing>): void;
|
|
8
|
+
export declare function releaseIn<I, O>(this: Mixer<I, O>, motion: Motions<I>, subject: I, kept: ReturnType<typeof releasing>): void;
|
|
9
|
+
export declare function recordDrop<I, O>(this: Mixer<I, O>, subject: I): void;
|
package/dist/drop.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { headOf, unlink } from './chain.js';
|
|
2
|
+
import { leaveVoice } from './fade.js';
|
|
3
|
+
import { goneIndex } from './gone.js';
|
|
4
|
+
import { releasing } from './history.js';
|
|
5
|
+
import { nextFrame } from './move.js';
|
|
6
|
+
import { Masked } from './store.js';
|
|
7
|
+
import { record, taping, unplayable } from './tape.js';
|
|
8
|
+
export function drop(subject) {
|
|
9
|
+
this.frame = nextFrame();
|
|
10
|
+
const head = headOf(this, subject);
|
|
11
|
+
// Nothing that kept this head, such as `pull`'s remembered list, may take it as current again.
|
|
12
|
+
if (head !== undefined)
|
|
13
|
+
unlink(this, head);
|
|
14
|
+
// A number a seek carried over is released even where its chain is not linked since.
|
|
15
|
+
const slot = this.chains.get(subject)?.slot ?? -1;
|
|
16
|
+
if (slot >= 0 && this.lanes !== null)
|
|
17
|
+
this.lanes.release(slot);
|
|
18
|
+
// A read ahead's copy reads the live mix's poses, and so hides one where the mix deletes it.
|
|
19
|
+
if (this.projecting && !(this.lastPoses instanceof Masked))
|
|
20
|
+
this.lastPoses = new Masked(this.lastPoses);
|
|
21
|
+
if (!this.projecting)
|
|
22
|
+
this.places?.drop(subject);
|
|
23
|
+
this.lastPoses.delete(subject);
|
|
24
|
+
this.restStamps?.delete(subject);
|
|
25
|
+
this.chains.delete(subject);
|
|
26
|
+
this.stir();
|
|
27
|
+
// A record of it is only in a voice over every subject, one naming it, or one gone; a ramp out
|
|
28
|
+
// of a voice that does not name it is in `parters`, and a patch's own state in `motions`.
|
|
29
|
+
const kept = releasing(this);
|
|
30
|
+
for (const voice of this.general)
|
|
31
|
+
this.forgetIn(voice, subject, kept);
|
|
32
|
+
const named = this.named.get(subject);
|
|
33
|
+
if (named !== undefined)
|
|
34
|
+
for (const voice of [...named])
|
|
35
|
+
this.forgetIn(voice, subject, kept);
|
|
36
|
+
const gone = goneIndex(this);
|
|
37
|
+
for (const voice of gone.general)
|
|
38
|
+
this.forgetIn(voice, subject, kept);
|
|
39
|
+
const goneNaming = gone.named.get(subject);
|
|
40
|
+
if (goneNaming !== undefined)
|
|
41
|
+
for (const voice of goneNaming)
|
|
42
|
+
this.forgetIn(voice, subject, kept);
|
|
43
|
+
if (this.owners !== null)
|
|
44
|
+
for (const voice of this.owners)
|
|
45
|
+
this.forgetIn(voice, subject, kept);
|
|
46
|
+
for (const voice of this.parters) {
|
|
47
|
+
this.forgetIn(voice, subject, kept);
|
|
48
|
+
if (voice.parts?.size === 0)
|
|
49
|
+
voice.parts = null;
|
|
50
|
+
if (voice.parted?.size === 0)
|
|
51
|
+
voice.parted = null;
|
|
52
|
+
if (voice.parts === null && voice.parted === null)
|
|
53
|
+
this.parters.delete(voice);
|
|
54
|
+
}
|
|
55
|
+
const strays = this.strays.get(subject);
|
|
56
|
+
if (strays !== undefined)
|
|
57
|
+
for (const motion of strays)
|
|
58
|
+
this.releaseIn(motion, subject, kept);
|
|
59
|
+
this.strays.delete(subject);
|
|
60
|
+
for (const motion of this.strayAll)
|
|
61
|
+
this.releaseIn(motion, subject, kept);
|
|
62
|
+
if (taping(this))
|
|
63
|
+
this.recordDrop(subject);
|
|
64
|
+
}
|
|
65
|
+
/** Lets `voice` go of a dropped subject. Methods rather than closures, so a drop makes neither. */
|
|
66
|
+
export function forgetIn(voice, subject, kept) {
|
|
67
|
+
leaveVoice(this, voice, subject);
|
|
68
|
+
voice.subjects.delete(subject);
|
|
69
|
+
if (voice.motion !== undefined)
|
|
70
|
+
this.releaseIn(voice.motion, subject, kept);
|
|
71
|
+
voice.parts?.delete(subject);
|
|
72
|
+
voice.parted?.delete(subject);
|
|
73
|
+
voice.blend?.of.reads.delete(subject);
|
|
74
|
+
}
|
|
75
|
+
// A motion patch's state is the live mix's alone: a read ahead cannot start a subject afresh in it.
|
|
76
|
+
export function releaseIn(motion, subject, kept) {
|
|
77
|
+
if (!this.projecting)
|
|
78
|
+
motion.release(subject, kept[0], kept[1], kept[2], kept[3]);
|
|
79
|
+
else if (motion.holds(subject))
|
|
80
|
+
unplayable('a drop of a subject a motion patch holds');
|
|
81
|
+
}
|
|
82
|
+
export function recordDrop(subject) {
|
|
83
|
+
record(this, 'drop', (stage) => stage.mix(this)?.drop(subject));
|
|
84
|
+
}
|
package/dist/due.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import type { Mixer } from './mixer.js';
|
|
2
2
|
import type { Voice } from './voice.js';
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Live voices by the earliest mix time `moveTo` would change each, a binary heap. The times sit in
|
|
5
|
+
* one flat array, so a sift reads no voice: at 40,000 voices a stop's sift to the top missed the
|
|
6
|
+
* cache at each of its levels. An entry is stale once its voice has been scheduled again.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DueQueue<I, O> {
|
|
9
|
+
size: number;
|
|
10
|
+
private at;
|
|
11
|
+
private tokens;
|
|
12
|
+
private voices;
|
|
13
|
+
/** The size past which stale entries are pruned, so a voice rescheduled often cannot grow it. */
|
|
14
|
+
private limit;
|
|
15
|
+
push(at: number, voice: Voice<I, O>, token: number): void;
|
|
16
|
+
/** The earliest entry's time, Infinity while empty. */
|
|
17
|
+
first(): number;
|
|
18
|
+
/** Takes off the earliest entry, giving its voice where it is current and undefined where stale. */
|
|
19
|
+
pop(): Voice<I, O> | undefined;
|
|
20
|
+
clear(): void;
|
|
21
|
+
private move;
|
|
22
|
+
/** Puts an entry in the hole at `i` and sifts it down to where it belongs. */
|
|
23
|
+
private sink;
|
|
24
|
+
private grow;
|
|
25
|
+
/** Drops the entries made stale by a later one and heapifies what is left. */
|
|
26
|
+
private prune;
|
|
8
27
|
}
|
|
9
28
|
/** Files a voice in the due queue at its current due, replacing any entry it had. */
|
|
10
29
|
export declare function schedule<I, O>(mix: Mixer<I, O>, voice: Voice<I, O>): void;
|
package/dist/due.js
CHANGED
|
@@ -1,3 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live voices by the earliest mix time `moveTo` would change each, a binary heap. The times sit in
|
|
3
|
+
* one flat array, so a sift reads no voice: at 40,000 voices a stop's sift to the top missed the
|
|
4
|
+
* cache at each of its levels. An entry is stale once its voice has been scheduled again.
|
|
5
|
+
*/
|
|
6
|
+
export class DueQueue {
|
|
7
|
+
size = 0;
|
|
8
|
+
at = new Float64Array(64);
|
|
9
|
+
tokens = new Float64Array(64);
|
|
10
|
+
voices = [];
|
|
11
|
+
/** The size past which stale entries are pruned, so a voice rescheduled often cannot grow it. */
|
|
12
|
+
limit = 64;
|
|
13
|
+
push(at, voice, token) {
|
|
14
|
+
if (this.size >= this.limit)
|
|
15
|
+
this.prune();
|
|
16
|
+
if (this.size === this.at.length)
|
|
17
|
+
this.grow();
|
|
18
|
+
const ats = this.at;
|
|
19
|
+
let i = this.size++;
|
|
20
|
+
while (i > 0) {
|
|
21
|
+
const up = (i - 1) >> 1;
|
|
22
|
+
if (ats[up] <= at)
|
|
23
|
+
break;
|
|
24
|
+
this.move(up, i);
|
|
25
|
+
i = up;
|
|
26
|
+
}
|
|
27
|
+
ats[i] = at;
|
|
28
|
+
this.tokens[i] = token;
|
|
29
|
+
this.voices[i] = voice;
|
|
30
|
+
}
|
|
31
|
+
/** The earliest entry's time, Infinity while empty. */
|
|
32
|
+
first() {
|
|
33
|
+
return this.size > 0 ? this.at[0] : Number.POSITIVE_INFINITY;
|
|
34
|
+
}
|
|
35
|
+
/** Takes off the earliest entry, giving its voice where it is current and undefined where stale. */
|
|
36
|
+
pop() {
|
|
37
|
+
const voice = this.voices[0];
|
|
38
|
+
const token = this.tokens[0];
|
|
39
|
+
const last = --this.size;
|
|
40
|
+
if (last > 0)
|
|
41
|
+
this.sink(0, this.at[last], this.tokens[last], this.voices[last]);
|
|
42
|
+
this.voices[last] = undefined;
|
|
43
|
+
return token === voice.dueToken && voice.state !== 'done' ? voice : undefined;
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.size = 0;
|
|
47
|
+
this.voices = [];
|
|
48
|
+
this.limit = 64;
|
|
49
|
+
}
|
|
50
|
+
move(from, to) {
|
|
51
|
+
this.at[to] = this.at[from];
|
|
52
|
+
this.tokens[to] = this.tokens[from];
|
|
53
|
+
this.voices[to] = this.voices[from];
|
|
54
|
+
}
|
|
55
|
+
/** Puts an entry in the hole at `i` and sifts it down to where it belongs. */
|
|
56
|
+
sink(i, at, token, voice) {
|
|
57
|
+
const ats = this.at;
|
|
58
|
+
const n = this.size;
|
|
59
|
+
for (;;) {
|
|
60
|
+
const l = 2 * i + 1;
|
|
61
|
+
const r = l + 1;
|
|
62
|
+
let m = i;
|
|
63
|
+
let least = at;
|
|
64
|
+
if (l < n && ats[l] < least) {
|
|
65
|
+
m = l;
|
|
66
|
+
least = ats[l];
|
|
67
|
+
}
|
|
68
|
+
if (r < n && ats[r] < least)
|
|
69
|
+
m = r;
|
|
70
|
+
if (m === i)
|
|
71
|
+
break;
|
|
72
|
+
this.move(m, i);
|
|
73
|
+
i = m;
|
|
74
|
+
}
|
|
75
|
+
ats[i] = at;
|
|
76
|
+
this.tokens[i] = token;
|
|
77
|
+
this.voices[i] = voice;
|
|
78
|
+
}
|
|
79
|
+
grow() {
|
|
80
|
+
const at = new Float64Array(this.at.length * 2);
|
|
81
|
+
at.set(this.at);
|
|
82
|
+
this.at = at;
|
|
83
|
+
const tokens = new Float64Array(this.tokens.length * 2);
|
|
84
|
+
tokens.set(this.tokens);
|
|
85
|
+
this.tokens = tokens;
|
|
86
|
+
}
|
|
87
|
+
/** Drops the entries made stale by a later one and heapifies what is left. */
|
|
88
|
+
prune() {
|
|
89
|
+
let n = 0;
|
|
90
|
+
for (let k = 0; k < this.size; k++) {
|
|
91
|
+
const voice = this.voices[k];
|
|
92
|
+
if (this.tokens[k] !== voice.dueToken)
|
|
93
|
+
continue;
|
|
94
|
+
if (n !== k)
|
|
95
|
+
this.move(k, n);
|
|
96
|
+
n++;
|
|
97
|
+
}
|
|
98
|
+
for (let k = n; k < this.size; k++)
|
|
99
|
+
this.voices[k] = undefined;
|
|
100
|
+
this.size = n;
|
|
101
|
+
for (let k = (n >> 1) - 1; k >= 0; k--)
|
|
102
|
+
this.sink(k, this.at[k], this.tokens[k], this.voices[k]);
|
|
103
|
+
this.limit = Math.max(64, 2 * n);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
1
106
|
/**
|
|
2
107
|
* The earliest mix time `moveTo` would change a voice: its start, its anchored out, the end of
|
|
3
108
|
* its last pass, the end of its fade or of a subject's ramp out; -Infinity where it must be
|
|
@@ -59,43 +164,18 @@ export function schedule(mix, voice) {
|
|
|
59
164
|
const due = dueOf(mix, voice);
|
|
60
165
|
if (due === Number.POSITIVE_INFINITY)
|
|
61
166
|
return;
|
|
62
|
-
|
|
63
|
-
heap.push({ at: Number.isNaN(due) ? Number.NEGATIVE_INFINITY : due, voice, token });
|
|
64
|
-
let i = heap.length - 1;
|
|
65
|
-
while (i > 0) {
|
|
66
|
-
const up = (i - 1) >> 1;
|
|
67
|
-
if (heap[up].at <= heap[i].at)
|
|
68
|
-
break;
|
|
69
|
-
[heap[up], heap[i]] = [heap[i], heap[up]];
|
|
70
|
-
i = up;
|
|
71
|
-
}
|
|
167
|
+
mix.due.push(Number.isNaN(due) ? Number.NEGATIVE_INFINITY : due, voice, token);
|
|
72
168
|
}
|
|
73
169
|
/** Takes every current entry due by `now` off the queue, in cue order. */
|
|
74
170
|
export function popDue(mix, now) {
|
|
75
|
-
const
|
|
76
|
-
const at = (k) => k < heap.length ? heap[k].at : Number.POSITIVE_INFINITY;
|
|
171
|
+
const queue = mix.due;
|
|
77
172
|
const out = [];
|
|
78
|
-
while (
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
for (;;) {
|
|
85
|
-
const l = 2 * i + 1;
|
|
86
|
-
const r = l + 1;
|
|
87
|
-
const m0 = at(l) < at(i) ? l : i;
|
|
88
|
-
const m = at(r) < at(m0) ? r : m0;
|
|
89
|
-
if (m === i)
|
|
90
|
-
break;
|
|
91
|
-
[heap[m], heap[i]] = [heap[i], heap[m]];
|
|
92
|
-
i = m;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (top.token === top.voice.dueToken && top.voice.state !== 'done') {
|
|
96
|
-
top.voice.dueToken++;
|
|
97
|
-
out.push(top.voice);
|
|
98
|
-
}
|
|
173
|
+
while (queue.first() <= now) {
|
|
174
|
+
const voice = queue.pop();
|
|
175
|
+
if (voice === undefined)
|
|
176
|
+
continue;
|
|
177
|
+
voice.dueToken++;
|
|
178
|
+
out.push(voice);
|
|
99
179
|
}
|
|
100
180
|
return byId(out);
|
|
101
181
|
}
|
package/dist/easing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Easing } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The function an easing stands for, a curve on 0..1.
|
|
4
4
|
*
|
|
5
5
|
* @category patch
|
|
6
6
|
*/
|
|
@@ -11,9 +11,9 @@ export type Curve = (u: number) => number;
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function startSlope(c: Curve): number;
|
|
13
13
|
/**
|
|
14
|
-
* The function an easing names
|
|
15
|
-
* as it is. Call it once where a curve is built, not per frame; the same name or
|
|
16
|
-
* gives the same function each time.
|
|
14
|
+
* The function an easing names. The easing is a CSS name, a `bezier` or `steps`, or a function,
|
|
15
|
+
* which comes back as it is. Call it once where a curve is built, not per frame; the same name or
|
|
16
|
+
* easing object gives the same function each time.
|
|
17
17
|
*
|
|
18
18
|
* @category patch
|
|
19
19
|
*/
|
package/dist/easing.js
CHANGED
|
@@ -72,9 +72,9 @@ export function startSlope(c) {
|
|
|
72
72
|
return v > 1e-3 ? Number.POSITIVE_INFINITY : v / h;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* The function an easing names
|
|
76
|
-
* as it is. Call it once where a curve is built, not per frame; the same name or
|
|
77
|
-
* gives the same function each time.
|
|
75
|
+
* The function an easing names. The easing is a CSS name, a `bezier` or `steps`, or a function,
|
|
76
|
+
* which comes back as it is. Call it once where a curve is built, not per frame; the same name or
|
|
77
|
+
* easing object gives the same function each time.
|
|
78
78
|
*
|
|
79
79
|
* @category patch
|
|
80
80
|
*/
|
package/dist/everyone.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Mixer } from './mixer.js';
|
|
2
|
-
import type { Subject
|
|
2
|
+
import type { Subject } from './subject.js';
|
|
3
|
+
import type { Voice } from './voice.js';
|
|
3
4
|
/**
|
|
4
5
|
* Whether a voice can keep one record for every subject, decided when it is cued. A record holds
|
|
5
6
|
* what a voice knows of one subject; where the voice is over every subject with no stagger, keeps
|
|
@@ -60,7 +61,7 @@ export declare function unsight<I, O>(voice: Voice<I, O>, slot: number): void;
|
|
|
60
61
|
*/
|
|
61
62
|
export declare function unshare<I, O>(mix: Mixer<I, O>, voice: Voice<I, O>, kept?: boolean, keeper?: I): void;
|
|
62
63
|
/**
|
|
63
|
-
* Counts what makes a mix's fold more than a walk of each chain: a
|
|
64
|
+
* Counts what makes a mix's fold more than a walk of each chain: a role, a voice sharing one
|
|
64
65
|
* record, a voice that stopped sharing this frame. Called wherever one of the three changes, so
|
|
65
66
|
* `foldWith` asks one number.
|
|
66
67
|
*/
|
package/dist/everyone.js
CHANGED
|
@@ -22,7 +22,7 @@ export function shares(mix, voice) {
|
|
|
22
22
|
voice.named === null &&
|
|
23
23
|
spec.target === undefined &&
|
|
24
24
|
spec.stagger === undefined &&
|
|
25
|
-
spec.
|
|
25
|
+
spec.role === undefined &&
|
|
26
26
|
spec.anchor === undefined &&
|
|
27
27
|
spec.from !== 'current' &&
|
|
28
28
|
typeof spec.weight !== 'function' &&
|
|
@@ -234,12 +234,12 @@ export function unshare(mix, voice, kept = false, keeper) {
|
|
|
234
234
|
mix.lanes?.refill();
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
237
|
-
* Counts what makes a mix's fold more than a walk of each chain: a
|
|
237
|
+
* Counts what makes a mix's fold more than a walk of each chain: a role, a voice sharing one
|
|
238
238
|
* record, a voice that stopped sharing this frame. Called wherever one of the three changes, so
|
|
239
239
|
* `foldWith` asks one number.
|
|
240
240
|
*/
|
|
241
241
|
export function detour(mix) {
|
|
242
|
-
mix.detours = mix.
|
|
242
|
+
mix.detours = mix.roleVoices + mix.sharers.length + (mix.unshared ? 1 : 0);
|
|
243
243
|
}
|
|
244
244
|
/** Gives a record just made for a subject a sharing voice had seen what the voice kept for it. */
|
|
245
245
|
export function inherit(voice, held, slot) {
|
package/dist/fade.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Mixer } from './mixer.js';
|
|
2
|
-
import type { Left, Parted, Parting
|
|
2
|
+
import type { Left, Parted, Parting } from './subject.js';
|
|
3
|
+
import type { Voice } from './voice.js';
|
|
3
4
|
/** Starts one subject's ramp out of a voice, or takes it out at once for a ramp of 0. */
|
|
4
5
|
export declare function fadeSubject<I, O>(mix: Mixer<I, O>, voice: Voice<I, O>, subject: I, over?: number): void;
|
|
5
6
|
/** What a subject's own ramp out of a voice leaves of its weight this frame, 0..1. */
|
package/dist/fade.js
CHANGED
|
@@ -6,6 +6,7 @@ import { leave, noted, releasing } from './history.js';
|
|
|
6
6
|
import { markOf } from './marks.js';
|
|
7
7
|
import { orphan, ownerReading } from './owner.js';
|
|
8
8
|
import { startOf } from './place.js';
|
|
9
|
+
import { isRested } from './record.js';
|
|
9
10
|
import { scoreTouched } from './scored.js';
|
|
10
11
|
import { lingers, refit } from './spans.js';
|
|
11
12
|
import { unreach } from './unreached.js';
|
|
@@ -111,7 +112,7 @@ function forgetIn(mix, voice, subject) {
|
|
|
111
112
|
voice.subjects.delete(subject);
|
|
112
113
|
if (held.reaches)
|
|
113
114
|
voice.seen--;
|
|
114
|
-
if (held
|
|
115
|
+
if (isRested(held))
|
|
115
116
|
voice.restedCount--;
|
|
116
117
|
if (voice.holder === held)
|
|
117
118
|
voice.holder = null;
|
package/dist/fill.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { type Lane, type Laned, type Paced } from './lane.js';
|
|
|
2
2
|
import type { Lanes } from './lanes.js';
|
|
3
3
|
import { absent } from './numbers.js';
|
|
4
4
|
import { type Scratch } from './patch.js';
|
|
5
|
-
import type { Subject
|
|
5
|
+
import type { Subject } from './subject.js';
|
|
6
|
+
import type { Voice } from './voice.js';
|
|
6
7
|
export declare function fillAll<I, O>(lanes: Lanes<I, O>, now: number, version: number): void;
|
|
7
8
|
/** Leaves a lane's subjects to the general path until it wakes, keeping what `weightOf` reports. */
|
|
8
9
|
export declare function rest<I, O>(lanes: Lanes<I, O>, lane: Paced): void;
|
|
@@ -31,7 +32,7 @@ export declare function runEveryone<I, O>(this: Lanes<I, O>, lane: Lane<I, O>):
|
|
|
31
32
|
/**
|
|
32
33
|
* One subject's contribution from a lane's voice. True where the voice gave the subject a delta,
|
|
33
34
|
* as the general path's `contribution` does where it returns one, which is what makes a voice in a
|
|
34
|
-
*
|
|
35
|
+
* role one of its members for the subject.
|
|
35
36
|
*/
|
|
36
37
|
export declare function one<I, O>(this: Lanes<I, O>, lane: Lane<I, O>, p: number, slot: number): boolean;
|
|
37
38
|
/**
|