@msb235/blits 0.2.1 → 0.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/CHANGELOG.md +88 -0
- package/README.md +9 -2
- package/dist/channels.d.ts +34 -5
- package/dist/channels.js +172 -23
- package/dist/clock.d.ts +19 -0
- package/dist/clock.js +44 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/lanes.d.ts +207 -0
- package/dist/lanes.js +928 -0
- package/dist/mixer.d.ts +185 -2
- package/dist/mixer.js +1241 -139
- package/dist/motion.d.ts +169 -9
- package/dist/motion.js +564 -112
- package/dist/numbers.d.ts +22 -0
- package/dist/numbers.js +64 -0
- package/dist/patch.d.ts +13 -2
- package/dist/patch.js +44 -18
- package/dist/reading.d.ts +23 -0
- package/dist/reading.js +23 -0
- package/dist/types.d.ts +236 -11
- package/docs/schema.html +115 -23
- package/package.json +3 -6
package/dist/mixer.d.ts
CHANGED
|
@@ -1,6 +1,188 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Curve } from './easing.js';
|
|
2
|
+
import { type Built, intosOf, type Scratch } from './patch.js';
|
|
3
|
+
import { Store } from './store.js';
|
|
4
|
+
import type { Channel, Engine, FadeSpec, Kit, Mix, MixOptions, Patch, Setting, VoiceSpec } from './types.js';
|
|
5
|
+
/** Everything one voice holds for one subject, chained through the next voice that reaches it. */
|
|
6
|
+
export interface Subject<S> {
|
|
7
|
+
/** The voice's `target` answer, fixed on first sight. */
|
|
8
|
+
reaches: boolean;
|
|
9
|
+
/** The voice's `stagger` answer in voice ms, fixed on first sight. */
|
|
10
|
+
delay: number;
|
|
11
|
+
/** The mix timestamp this subject's delay ran out at, which its fade in counts from. */
|
|
12
|
+
since: number;
|
|
13
|
+
/** The weight this voice gave this subject the last frame it was probed, 0 where it gave none. */
|
|
14
|
+
weight: number;
|
|
15
|
+
/** Left at rest during a handover, so it stops contributing. */
|
|
16
|
+
rested: boolean;
|
|
17
|
+
/** Per written channel, whether a rest-less influence is on: 0 unknown, 1 on, 2 off. */
|
|
18
|
+
bands: Uint8Array;
|
|
19
|
+
state: S;
|
|
20
|
+
/** The `now` this subject last caught up to, for this voice. */
|
|
21
|
+
stepped: number;
|
|
22
|
+
/** Under `stepMs`, how many intervals have run since `since`; `stepped` is where that lands. */
|
|
23
|
+
ticks: number;
|
|
24
|
+
/** The `now` this subject was last probed at, so twelve probes in a frame step once. */
|
|
25
|
+
probed: number;
|
|
26
|
+
/** The last delta computed this frame, handed back to a repeat probe unchanged. */
|
|
27
|
+
delta: Record<string, unknown> | null;
|
|
28
|
+
/** The phase `delta` was read at, to read it again once its voice's scratch has moved on. */
|
|
29
|
+
phase: number;
|
|
30
|
+
/** The voice's `seeks` when `delta` was read, so a seek later in the frame reads it again. */
|
|
31
|
+
seeks: number;
|
|
32
|
+
/** Stop 0 for a `from: 'current'` voice, taken the first frame this subject is seen. */
|
|
33
|
+
base?: Record<string, unknown>;
|
|
34
|
+
/** The pose's velocity per channel at that moment, units per ms, so the first segment leaves at it. */
|
|
35
|
+
slope?: Record<string, unknown>;
|
|
36
|
+
/** What each stateful signal on this voice keeps for this subject, by the signal. */
|
|
37
|
+
kept: Map<object, unknown>;
|
|
38
|
+
keep: Setting['keep'];
|
|
39
|
+
/** Under `history`, copies of this record by the mix time they were taken, oldest first. */
|
|
40
|
+
snaps?: {
|
|
41
|
+
at: number;
|
|
42
|
+
held: Subject<S>;
|
|
43
|
+
}[];
|
|
44
|
+
/** In a projection: where this record started from, and whether nothing known could be. */
|
|
45
|
+
from?: number;
|
|
46
|
+
unknown?: boolean;
|
|
47
|
+
/** Under `history` with `inputs`, what an input weight signal read for this subject, when it changed. */
|
|
48
|
+
inputs?: {
|
|
49
|
+
at: number;
|
|
50
|
+
value: number;
|
|
51
|
+
}[];
|
|
52
|
+
/** In a projection reading back: that record, to read in place of the signal. */
|
|
53
|
+
replay?: {
|
|
54
|
+
at: number;
|
|
55
|
+
value: number;
|
|
56
|
+
}[];
|
|
57
|
+
/** The voice this is the record of; null on a subject's stub. */
|
|
58
|
+
voice: object | null;
|
|
59
|
+
/** The next voice's record for this subject, in voice order, among those that reach it. */
|
|
60
|
+
next: Subject<unknown> | null;
|
|
61
|
+
/**
|
|
62
|
+
* On the first record, which the mix keeps per subject so a probe makes one lookup: the `version`
|
|
63
|
+
* the chain was linked at, and per locus and channel whether a rest-less influence is on.
|
|
64
|
+
*/
|
|
65
|
+
version: number;
|
|
66
|
+
loci: Map<string, boolean> | null;
|
|
67
|
+
/** On the first record: the number lanes index this subject by, -1 without one. */
|
|
68
|
+
slot: number;
|
|
69
|
+
}
|
|
70
|
+
/** What sets a voice's clock: its rate, and where it was last anchored. */
|
|
71
|
+
interface Clock {
|
|
72
|
+
anchorNow: number;
|
|
73
|
+
anchorElapsed: number;
|
|
74
|
+
rate: number;
|
|
75
|
+
ramp: {
|
|
76
|
+
from: number;
|
|
77
|
+
to: number;
|
|
78
|
+
over: number;
|
|
79
|
+
} | null;
|
|
80
|
+
}
|
|
81
|
+
/** A voice's clock, weight and fade from one mix time on, kept under `history`. */
|
|
82
|
+
interface Controls extends Clock {
|
|
83
|
+
at: number;
|
|
84
|
+
weight: number;
|
|
85
|
+
out: Ramp | null;
|
|
86
|
+
/** Where its anchors had placed it then: start, and the start of an anchored fade out. */
|
|
87
|
+
start: number;
|
|
88
|
+
outAt: number;
|
|
89
|
+
/** Made by a sync, so it shows in that frame; a host's change between frames shows from the next. */
|
|
90
|
+
sync: boolean;
|
|
91
|
+
}
|
|
92
|
+
interface Ramp {
|
|
93
|
+
from: number;
|
|
94
|
+
at: number;
|
|
95
|
+
over: number;
|
|
96
|
+
rest: boolean;
|
|
97
|
+
deadline?: number;
|
|
98
|
+
}
|
|
99
|
+
export declare class Voice<I, O> {
|
|
100
|
+
readonly id: number;
|
|
101
|
+
readonly spec: VoiceSpec<I, O>;
|
|
102
|
+
readonly patch: Patch<I, O, unknown>;
|
|
103
|
+
readonly fade: FadeSpec;
|
|
104
|
+
start: number;
|
|
105
|
+
state: 'pending' | 'live' | 'fading' | 'done';
|
|
106
|
+
rate: number;
|
|
107
|
+
weight: number;
|
|
108
|
+
/**
|
|
109
|
+
* elapsed = anchorElapsed + the rate integrated from anchorNow, rebased on a rate change or a seek.
|
|
110
|
+
* Without a ramp the rate is constant; with one it moves linearly from `from` to `to` over `over`
|
|
111
|
+
* mix ms starting at the anchor, and holds `to` after.
|
|
112
|
+
*/
|
|
113
|
+
anchorNow: number;
|
|
114
|
+
anchorElapsed: number;
|
|
115
|
+
ramp: {
|
|
116
|
+
from: number;
|
|
117
|
+
to: number;
|
|
118
|
+
over: number;
|
|
119
|
+
} | null;
|
|
120
|
+
out: Ramp | null;
|
|
121
|
+
readonly subjects: Store<I, Subject<unknown>>;
|
|
122
|
+
/** The subjects its spec names, or null where it names none. */
|
|
123
|
+
readonly named: ReadonlySet<I> | null;
|
|
124
|
+
/** Kit slot of each channel the patch writes, in `writes` order. */
|
|
125
|
+
readonly slots: number[];
|
|
126
|
+
/** The stops built ahead of time, for a `keys` patch. */
|
|
127
|
+
readonly built: Built | null;
|
|
128
|
+
/** The kit's `lerp` for each channel the patch writes, which keyed stops interpolate through. */
|
|
129
|
+
readonly lerps: Channel<unknown>['lerp'][];
|
|
130
|
+
/** Per keyed channel, the in-place form of the lerp its stops take, where it has one. */
|
|
131
|
+
readonly intos: ReturnType<typeof intosOf> | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* The arrays keyed reads interpolate into: one set for the voice, not one per subject, since 10k
|
|
134
|
+
* subjects' worth of long-lived arrays costs more in cache misses than allocating them did.
|
|
135
|
+
*/
|
|
136
|
+
scratch: Scratch;
|
|
137
|
+
/** The record whose delta holds `scratch`'s arrays; any other's must be read again to be handed out. */
|
|
138
|
+
holder: Subject<unknown> | null;
|
|
139
|
+
/** Whether its channels run as lanes this frame, so the general fold passes it by. */
|
|
140
|
+
laned: boolean;
|
|
141
|
+
/** How many times it has been sought, so a delta read before a seek is not handed out after it. */
|
|
142
|
+
seeks: number;
|
|
143
|
+
/** Whether its patch has kept state on a record through `setting.keep`, which makes it stateful. */
|
|
144
|
+
keeping: boolean;
|
|
145
|
+
/** For a motion patch, the hook it was given to ask the mix for its subjects' voice time. */
|
|
146
|
+
frame: ((subject: I) => number) | null;
|
|
147
|
+
readonly ease: Curve | undefined;
|
|
148
|
+
/** How many passes its `loop` plays, worked out once. */
|
|
149
|
+
readonly passes: number;
|
|
150
|
+
/** Reused for every call this voice makes, so it is valid only during the call. */
|
|
151
|
+
readonly setting: Setting<unknown>;
|
|
152
|
+
/** Every subject this voice has been asked about, so a handover knows when it is finished. */
|
|
153
|
+
seen: number;
|
|
154
|
+
/** The longest stagger of any subject seen, so a finite loop waits for the last of them. */
|
|
155
|
+
latest: number;
|
|
156
|
+
restedCount: number;
|
|
157
|
+
/** The mix time it was cued at; -Infinity before the first sync. */
|
|
158
|
+
cuedAt: number;
|
|
159
|
+
/** The mix time it left at. */
|
|
160
|
+
doneAt: number;
|
|
161
|
+
/** Under `history`, its controls after each change, oldest first. */
|
|
162
|
+
log: Controls[] | null;
|
|
163
|
+
/** Where an anchored `out` or `end` puts its fade's start, mix time; Infinity until known. */
|
|
164
|
+
outAt: number;
|
|
165
|
+
/** Whether its start is still to be fixed by an anchor, so it waits pending. */
|
|
166
|
+
placing: boolean;
|
|
167
|
+
resolve: () => void;
|
|
168
|
+
readonly done: Promise<void>;
|
|
169
|
+
constructor(id: number, spec: VoiceSpec<I, O>, patch: Patch<I, O, unknown>, fade: FadeSpec, now: number, start: number, slotOf: Map<string, number>, channels: readonly Channel<unknown>[], host: unknown, send: (event: unknown) => void);
|
|
170
|
+
elapsedAt(now: number): number;
|
|
171
|
+
/** The mix time its clock reads `elapsed`, inverting `elapsedAt`; Infinity where it never will. */
|
|
172
|
+
timeAt(elapsed: number): number;
|
|
173
|
+
/** Records this voice's controls as they stand, from mix time `at`. */
|
|
174
|
+
note(at: number, sync?: boolean): void;
|
|
175
|
+
/**
|
|
176
|
+
* A copy for a projection: its own setting, which sends nothing, and its own per-subject records,
|
|
177
|
+
* filled from `fill`. With `controls` it takes those, as the voice stood at an earlier time.
|
|
178
|
+
*/
|
|
179
|
+
copy(fill: (subject: I) => Subject<unknown> | undefined, controls?: Controls): Voice<I, O>;
|
|
180
|
+
rateAt(now: number): number;
|
|
181
|
+
/** Moves the anchor to `now`, carrying what is left of a ramp. */
|
|
182
|
+
rebase(now: number): void;
|
|
183
|
+
}
|
|
2
184
|
/**
|
|
3
|
-
* The one that ships:
|
|
185
|
+
* The one that ships: every form on the CPU, probed per subject on demand.
|
|
4
186
|
*
|
|
5
187
|
* @category engine
|
|
6
188
|
*/
|
|
@@ -11,3 +193,4 @@ export declare const mixer: Engine;
|
|
|
11
193
|
* @category mix
|
|
12
194
|
*/
|
|
13
195
|
export declare function mix<I, O>(kit: Kit<O>, opts?: MixOptions): Mix<I, O>;
|
|
196
|
+
export {};
|