@avoid.quest/audio 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +70 -2
- package/dist/effects/index.d.ts +266 -0
- package/dist/effects/index.js +744 -0
- package/dist/effects/index.js.map +1 -0
- package/dist/errors-BT9HxDLn.js +74 -0
- package/dist/errors-BT9HxDLn.js.map +1 -0
- package/dist/errors-ChTQFwuZ.d.ts +53 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/midi/index.d.ts +162 -0
- package/dist/midi/index.js +338 -0
- package/dist/midi/index.js.map +1 -0
- package/dist/playback/index.d.ts +349 -0
- package/dist/playback/index.js +1372 -0
- package/dist/playback/index.js.map +1 -0
- package/dist/queue/index.d.ts +144 -0
- package/dist/queue/index.js +1062 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/recognize/index.d.ts +161 -0
- package/dist/recognize/index.js +2816 -0
- package/dist/recognize/index.js.map +1 -0
- package/dist/routing/index.d.ts +140 -0
- package/dist/routing/index.js +678 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/sync/index.d.ts +282 -0
- package/dist/sync/index.js +1103 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/worklet-loader-BvEW0oVO.d.ts +44 -0
- package/dist/worklet-loader-S7R8ZAmP.js +175 -0
- package/dist/worklet-loader-S7R8ZAmP.js.map +1 -0
- package/dist/worklets/couch-live.d.ts +1 -0
- package/dist/worklets/couch-live.js +365 -0
- package/dist/worklets/couch-live.js.map +1 -0
- package/dist/worklets/meter.d.ts +7 -0
- package/dist/worklets/meter.js +80 -0
- package/dist/worklets/meter.js.map +1 -0
- package/package.json +109 -4
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
const DEADBAND_SEC = .001;
|
|
2
|
+
const SLEW_RATE = .003;
|
|
3
|
+
const REPLACE_SEC = .2;
|
|
4
|
+
const JOIN_US = 1e3;
|
|
5
|
+
function noStats() {
|
|
6
|
+
return {
|
|
7
|
+
chunks: 0,
|
|
8
|
+
corrections: 0,
|
|
9
|
+
errorMax: Number.NEGATIVE_INFINITY,
|
|
10
|
+
errorMin: Number.POSITIVE_INFINITY,
|
|
11
|
+
filled: 0,
|
|
12
|
+
lost: 0,
|
|
13
|
+
skipped: 0,
|
|
14
|
+
slack: Number.POSITIVE_INFINITY
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function interpolateSample(samples, nextChunk, channelIndex, index, fraction) {
|
|
18
|
+
const sample = samples[index] ?? 0;
|
|
19
|
+
if (fraction === 0) return sample;
|
|
20
|
+
if (index + 1 < samples.length) return sample + ((samples[index + 1] ?? sample) - sample) * fraction;
|
|
21
|
+
const nextSamples = nextChunk?.channels[channelIndex] ?? nextChunk?.channels[0];
|
|
22
|
+
return sample + ((nextSamples && nextSamples.length > 0 ? nextSamples[0] ?? sample : sample) - sample) * fraction;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sample-accurate audio timeline used inside the `"couch-live"` AudioWorklet.
|
|
26
|
+
* Backed by a fixed-capacity ring buffer (zero `Array.prototype.shift()`, zero
|
|
27
|
+
* allocations during `render()`), dropping the oldest chunk on overflow,
|
|
28
|
+
* slewing smoothly at ±0.3% outside a 1 ms deadband, and hard re-placing beyond
|
|
29
|
+
* 200 ms error.
|
|
30
|
+
*/
|
|
31
|
+
var LiveTimeline = class {
|
|
32
|
+
capacity;
|
|
33
|
+
ring;
|
|
34
|
+
head = 0;
|
|
35
|
+
tail = 0;
|
|
36
|
+
count = 0;
|
|
37
|
+
position = 0;
|
|
38
|
+
playing = false;
|
|
39
|
+
dry = false;
|
|
40
|
+
endStampUs;
|
|
41
|
+
correcting = 0;
|
|
42
|
+
settling = false;
|
|
43
|
+
rate = 1;
|
|
44
|
+
sampleRate;
|
|
45
|
+
stats = noStats();
|
|
46
|
+
constructor(sampleRate, capacity = 256) {
|
|
47
|
+
this.sampleRate = sampleRate;
|
|
48
|
+
const normalizedCapacity = Number.isFinite(capacity) ? Math.max(2, Math.floor(capacity)) : 256;
|
|
49
|
+
this.capacity = normalizedCapacity;
|
|
50
|
+
this.ring = Array.from({ length: normalizedCapacity });
|
|
51
|
+
}
|
|
52
|
+
get length() {
|
|
53
|
+
return this.count;
|
|
54
|
+
}
|
|
55
|
+
get maxCapacity() {
|
|
56
|
+
return this.capacity;
|
|
57
|
+
}
|
|
58
|
+
reset() {
|
|
59
|
+
for (let i = 0; i < this.capacity; i += 1) this.ring[i] = void 0;
|
|
60
|
+
this.head = 0;
|
|
61
|
+
this.tail = 0;
|
|
62
|
+
this.count = 0;
|
|
63
|
+
this.position = 0;
|
|
64
|
+
this.playing = false;
|
|
65
|
+
this.dry = false;
|
|
66
|
+
this.settling = false;
|
|
67
|
+
this.correcting = 0;
|
|
68
|
+
this.rate = 1;
|
|
69
|
+
this.endStampUs = void 0;
|
|
70
|
+
this.resetStatsInPlace();
|
|
71
|
+
}
|
|
72
|
+
takeStats() {
|
|
73
|
+
const snapshot = {
|
|
74
|
+
chunks: this.stats.chunks,
|
|
75
|
+
corrections: this.stats.corrections,
|
|
76
|
+
errorMax: this.stats.errorMax,
|
|
77
|
+
errorMin: this.stats.errorMin,
|
|
78
|
+
filled: this.stats.filled,
|
|
79
|
+
lost: this.stats.lost,
|
|
80
|
+
skipped: this.stats.skipped,
|
|
81
|
+
slack: this.stats.slack
|
|
82
|
+
};
|
|
83
|
+
this.resetStatsInPlace();
|
|
84
|
+
return snapshot;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Copies accumulated stats into a preallocated target object and resets
|
|
88
|
+
* counters in place with zero heap allocation (safe for AudioWorklet use).
|
|
89
|
+
*/
|
|
90
|
+
takeStatsInto(target) {
|
|
91
|
+
target.chunks = this.stats.chunks;
|
|
92
|
+
target.corrections = this.stats.corrections;
|
|
93
|
+
target.errorMax = this.stats.errorMax;
|
|
94
|
+
target.errorMin = this.stats.errorMin;
|
|
95
|
+
target.filled = this.stats.filled;
|
|
96
|
+
target.lost = this.stats.lost;
|
|
97
|
+
target.skipped = this.stats.skipped;
|
|
98
|
+
target.slack = this.stats.slack;
|
|
99
|
+
this.resetStatsInPlace();
|
|
100
|
+
}
|
|
101
|
+
resetStatsInPlace() {
|
|
102
|
+
this.stats.chunks = 0;
|
|
103
|
+
this.stats.corrections = 0;
|
|
104
|
+
this.stats.errorMax = Number.NEGATIVE_INFINITY;
|
|
105
|
+
this.stats.errorMin = Number.POSITIVE_INFINITY;
|
|
106
|
+
this.stats.filled = 0;
|
|
107
|
+
this.stats.lost = 0;
|
|
108
|
+
this.stats.skipped = 0;
|
|
109
|
+
this.stats.slack = Number.POSITIVE_INFINITY;
|
|
110
|
+
}
|
|
111
|
+
peek(offset) {
|
|
112
|
+
if (offset < 0 || offset >= this.count) return;
|
|
113
|
+
return this.ring[(this.head + offset) % this.capacity];
|
|
114
|
+
}
|
|
115
|
+
dequeue() {
|
|
116
|
+
if (this.count === 0) return;
|
|
117
|
+
const item = this.ring[this.head];
|
|
118
|
+
this.ring[this.head] = void 0;
|
|
119
|
+
this.head = (this.head + 1) % this.capacity;
|
|
120
|
+
this.count -= 1;
|
|
121
|
+
return item;
|
|
122
|
+
}
|
|
123
|
+
enqueue(chunk) {
|
|
124
|
+
if (this.count === this.capacity) {
|
|
125
|
+
this.ring[this.head] = void 0;
|
|
126
|
+
this.head = (this.head + 1) % this.capacity;
|
|
127
|
+
this.count -= 1;
|
|
128
|
+
this.stats.lost += 1;
|
|
129
|
+
if (this.playing) {
|
|
130
|
+
this.playing = false;
|
|
131
|
+
this.position = 0;
|
|
132
|
+
this.settling = false;
|
|
133
|
+
this.correcting = 0;
|
|
134
|
+
this.rate = 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.ring[this.tail] = chunk;
|
|
138
|
+
this.tail = (this.tail + 1) % this.capacity;
|
|
139
|
+
this.count += 1;
|
|
140
|
+
}
|
|
141
|
+
push(chunk, next) {
|
|
142
|
+
if ((chunk.channels[0]?.length ?? 0) === 0) return;
|
|
143
|
+
const slack = this.playing ? this.queued() : chunk.frame - next;
|
|
144
|
+
const follows = this.endStampUs !== void 0 && Math.abs(chunk.stampUs - this.endStampUs) <= JOIN_US;
|
|
145
|
+
this.stats.chunks += 1;
|
|
146
|
+
this.stats.slack = Math.min(this.stats.slack, slack);
|
|
147
|
+
if (slack < 0 || this.dry && follows) this.stats.lost += 1;
|
|
148
|
+
this.dry = false;
|
|
149
|
+
this.enqueue(chunk);
|
|
150
|
+
}
|
|
151
|
+
render(frame, output) {
|
|
152
|
+
const frames = output[0]?.length ?? 0;
|
|
153
|
+
if (this.playing) this.steer(frame);
|
|
154
|
+
const channelCount = output.length;
|
|
155
|
+
for (let i = 0; i < frames; i += 1) {
|
|
156
|
+
if (!this.playing && !this.place(frame + i)) {
|
|
157
|
+
for (let c = 0; c < channelCount; c += 1) {
|
|
158
|
+
const outChannel = output[c];
|
|
159
|
+
if (outChannel) outChannel[i] = 0;
|
|
160
|
+
}
|
|
161
|
+
if (this.dry) this.stats.filled += 1;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
this.read(output, i, frame + i);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
queued() {
|
|
168
|
+
let frames = -this.position;
|
|
169
|
+
for (let i = 0; i < this.count; i += 1) {
|
|
170
|
+
const chunk = this.ring[(this.head + i) % this.capacity];
|
|
171
|
+
frames += chunk?.channels[0]?.length ?? 0;
|
|
172
|
+
}
|
|
173
|
+
return frames / this.rate;
|
|
174
|
+
}
|
|
175
|
+
place(frame) {
|
|
176
|
+
while (this.count > 0) {
|
|
177
|
+
const chunk = this.peek(0);
|
|
178
|
+
if (!chunk) return false;
|
|
179
|
+
const offset = Math.round(frame - chunk.frame);
|
|
180
|
+
const length = chunk.channels[0]?.length ?? 0;
|
|
181
|
+
if (offset < 0) return false;
|
|
182
|
+
if (offset < length) {
|
|
183
|
+
this.stats.skipped += offset;
|
|
184
|
+
this.position = offset;
|
|
185
|
+
this.playing = true;
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
this.stats.skipped += length;
|
|
189
|
+
this.dequeue();
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
steer(frame) {
|
|
194
|
+
const chunk = this.peek(0);
|
|
195
|
+
if (!chunk) return;
|
|
196
|
+
const error = chunk.frame + this.position - frame;
|
|
197
|
+
this.stats.errorMin = Math.min(this.stats.errorMin, error);
|
|
198
|
+
this.stats.errorMax = Math.max(this.stats.errorMax, error);
|
|
199
|
+
if (Math.abs(error) > REPLACE_SEC * this.sampleRate) {
|
|
200
|
+
this.playing = false;
|
|
201
|
+
this.settling = false;
|
|
202
|
+
this.correcting = 0;
|
|
203
|
+
this.rate = 1;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const sign = Math.sign(error);
|
|
207
|
+
if (this.correcting === 0 && Math.abs(error) > DEADBAND_SEC * this.sampleRate) {
|
|
208
|
+
this.correcting = sign;
|
|
209
|
+
this.settling = false;
|
|
210
|
+
this.rate = 1 - sign * SLEW_RATE;
|
|
211
|
+
this.stats.corrections += 1;
|
|
212
|
+
} else if (this.correcting !== 0 && sign !== this.correcting) this.settling = true;
|
|
213
|
+
}
|
|
214
|
+
advancePosition(chunk, currentFrameIndex) {
|
|
215
|
+
this.position += this.rate;
|
|
216
|
+
if (this.settling) {
|
|
217
|
+
const whole = Math.round(this.position);
|
|
218
|
+
if (Math.abs(this.position - whole) < SLEW_RATE) {
|
|
219
|
+
this.position = whole;
|
|
220
|
+
this.rate = 1;
|
|
221
|
+
this.correcting = 0;
|
|
222
|
+
this.settling = false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const length = chunk.channels[0]?.length ?? 0;
|
|
226
|
+
if (this.position < length) return;
|
|
227
|
+
this.position -= length;
|
|
228
|
+
this.endStampUs = chunk.stampUs + length / this.sampleRate * 1e6;
|
|
229
|
+
this.dequeue();
|
|
230
|
+
const nextChunk = this.peek(0);
|
|
231
|
+
if (nextChunk) {
|
|
232
|
+
const nextFrameIndex = currentFrameIndex + 1;
|
|
233
|
+
const boundaryError = nextChunk.frame + this.position - nextFrameIndex;
|
|
234
|
+
if (Math.abs(boundaryError) > REPLACE_SEC * this.sampleRate) {
|
|
235
|
+
this.playing = false;
|
|
236
|
+
this.settling = false;
|
|
237
|
+
this.correcting = 0;
|
|
238
|
+
this.rate = 1;
|
|
239
|
+
this.position = 0;
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
this.playing = false;
|
|
244
|
+
this.dry = true;
|
|
245
|
+
this.correcting = 0;
|
|
246
|
+
this.settling = false;
|
|
247
|
+
this.rate = 1;
|
|
248
|
+
}
|
|
249
|
+
read(output, i, currentFrameIndex) {
|
|
250
|
+
const chunk = this.peek(0);
|
|
251
|
+
if (!chunk) return;
|
|
252
|
+
const next = this.peek(1);
|
|
253
|
+
const index = Math.floor(this.position);
|
|
254
|
+
const fraction = this.position - index;
|
|
255
|
+
for (let c = 0; c < output.length; c += 1) {
|
|
256
|
+
const outChannel = output[c];
|
|
257
|
+
const samples = chunk.channels[c] ?? chunk.channels[0];
|
|
258
|
+
if (outChannel && samples) outChannel[i] = interpolateSample(samples, next, c, index, fraction);
|
|
259
|
+
}
|
|
260
|
+
this.advancePosition(chunk, currentFrameIndex);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
// src/worklets/couch-live.ts
|
|
264
|
+
const COUCH_LIVE_PROCESSOR_NAME = "couch-live";
|
|
265
|
+
if (typeof registerProcessor === "function") {
|
|
266
|
+
const reportFrames = sampleRate / 10;
|
|
267
|
+
registerProcessor(COUCH_LIVE_PROCESSOR_NAME, class CouchLiveProcessor extends AudioWorkletProcessor {
|
|
268
|
+
timeline = new LiveTimeline(sampleRate);
|
|
269
|
+
reportStats = {
|
|
270
|
+
chunks: 0,
|
|
271
|
+
corrections: 0,
|
|
272
|
+
errorMax: Number.NEGATIVE_INFINITY,
|
|
273
|
+
errorMin: Number.POSITIVE_INFINITY,
|
|
274
|
+
filled: 0,
|
|
275
|
+
lost: 0,
|
|
276
|
+
skipped: 0,
|
|
277
|
+
slack: Number.POSITIVE_INFINITY
|
|
278
|
+
};
|
|
279
|
+
reportPayload;
|
|
280
|
+
epoch = 0;
|
|
281
|
+
next = currentFrame;
|
|
282
|
+
reported = currentFrame;
|
|
283
|
+
feed;
|
|
284
|
+
disposed = false;
|
|
285
|
+
onFeedMessage = (msgEvent) => {
|
|
286
|
+
if (this.disposed) return;
|
|
287
|
+
const msg = msgEvent.data;
|
|
288
|
+
if (!msg || typeof msg !== "object") return;
|
|
289
|
+
if (msg.type === "dispose") {
|
|
290
|
+
this.dispose();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (msg.type === "chunk") {
|
|
294
|
+
if (msg.chunk) this.timeline.push(msg.chunk, this.next);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (msg.type === "reset") {
|
|
298
|
+
this.timeline.reset();
|
|
299
|
+
this.epoch = typeof msg.epoch === "number" ? msg.epoch : 0;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
onPortMessage = (event) => {
|
|
303
|
+
if (this.disposed) return;
|
|
304
|
+
const { data } = event;
|
|
305
|
+
if (!data || typeof data !== "object") return;
|
|
306
|
+
if (data.type === "dispose") {
|
|
307
|
+
this.dispose();
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (data.type === "poll") {
|
|
311
|
+
this.flushReport();
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (!data.port) return;
|
|
315
|
+
this.detachFeed();
|
|
316
|
+
this.feed = data.port;
|
|
317
|
+
this.feed.addEventListener("message", this.onFeedMessage);
|
|
318
|
+
if (typeof this.feed.start === "function") this.feed.start();
|
|
319
|
+
};
|
|
320
|
+
constructor() {
|
|
321
|
+
super();
|
|
322
|
+
this.reportPayload = {
|
|
323
|
+
epoch: 0,
|
|
324
|
+
stats: this.reportStats
|
|
325
|
+
};
|
|
326
|
+
this.port.addEventListener("message", this.onPortMessage);
|
|
327
|
+
if (typeof this.port.start === "function") this.port.start();
|
|
328
|
+
}
|
|
329
|
+
detachFeed() {
|
|
330
|
+
if (!this.feed) return;
|
|
331
|
+
this.feed.removeEventListener("message", this.onFeedMessage);
|
|
332
|
+
if (typeof this.feed.close === "function") this.feed.close();
|
|
333
|
+
this.feed = void 0;
|
|
334
|
+
}
|
|
335
|
+
dispose() {
|
|
336
|
+
if (this.disposed) return;
|
|
337
|
+
this.disposed = true;
|
|
338
|
+
this.detachFeed();
|
|
339
|
+
this.timeline.reset();
|
|
340
|
+
this.port.removeEventListener("message", this.onPortMessage);
|
|
341
|
+
if (typeof this.port.close === "function") this.port.close();
|
|
342
|
+
}
|
|
343
|
+
flushReport() {
|
|
344
|
+
if (this.disposed || !this.feed) return;
|
|
345
|
+
this.timeline.takeStatsInto(this.reportStats);
|
|
346
|
+
this.reportPayload.epoch = this.epoch;
|
|
347
|
+
this.feed.postMessage(this.reportPayload);
|
|
348
|
+
}
|
|
349
|
+
process(_inputs, outputs) {
|
|
350
|
+
if (this.disposed) return false;
|
|
351
|
+
const [output] = outputs;
|
|
352
|
+
if (!output) return true;
|
|
353
|
+
this.timeline.render(currentFrame, output);
|
|
354
|
+
this.next = currentFrame + (output[0]?.length ?? 0);
|
|
355
|
+
if (this.next - this.reported >= reportFrames) {
|
|
356
|
+
this.reported = this.next;
|
|
357
|
+
this.flushReport();
|
|
358
|
+
}
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
export { COUCH_LIVE_PROCESSOR_NAME };
|
|
364
|
+
|
|
365
|
+
//# sourceMappingURL=couch-live.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"couch-live.js","names":[],"sources":["../../src/sync/live-timeline.ts","../../src/worklets/couch-live.ts"],"sourcesContent":["export interface LiveChunk {\n readonly frame: number;\n readonly stampUs: number;\n readonly channels: readonly Float32Array[];\n}\n\nexport type LiveMessage =\n | { readonly type: \"chunk\"; readonly chunk: LiveChunk }\n | { readonly type: \"reset\"; readonly epoch: number }\n | { readonly type: \"dispose\" };\n\nexport interface LiveClock {\n readonly offset: number;\n readonly sampleRate: number;\n}\n\nexport interface PageClockEstimator {\n readonly saw: (pageMs: number, ownMs?: number) => void;\n readonly pageMs: (ownMs?: number) => number;\n}\n\nexport interface LiveStats {\n chunks: number;\n lost: number;\n slack: number;\n filled: number;\n skipped: number;\n errorMin: number;\n errorMax: number;\n corrections: number;\n}\n\nexport const DEFAULT_LIVE_TIMELINE_CAPACITY = 256;\n\nconst DEADBAND_SEC = 0.001;\nconst SLEW_RATE = 0.003;\nconst REPLACE_SEC = 0.2;\nconst JOIN_US = 1000;\n\n/**\n * Maps a page performance timestamp (ms) to the corresponding AudioContext frame.\n */\nexport function contextFrame(clock: LiveClock, pageMs: number): number {\n return (clock.offset + pageMs / 1000) * clock.sampleRate;\n}\n\n/**\n * Estimates Worker-vs-Page monotonic clock skew using the minimum observed offset.\n */\nexport function pageClock(): PageClockEstimator {\n let aheadMs = Number.POSITIVE_INFINITY;\n return {\n pageMs: (ownMs = performance.now()): number => ownMs - aheadMs,\n saw: (pageMs: number, ownMs = performance.now()): void => {\n aheadMs = Math.min(aheadMs, ownMs - pageMs);\n },\n };\n}\n\nexport function noStats(): LiveStats {\n return {\n chunks: 0,\n corrections: 0,\n errorMax: Number.NEGATIVE_INFINITY,\n errorMin: Number.POSITIVE_INFINITY,\n filled: 0,\n lost: 0,\n skipped: 0,\n slack: Number.POSITIVE_INFINITY,\n };\n}\n\nexport function addStats(totals: LiveStats, stats: LiveStats): void {\n totals.chunks += stats.chunks;\n totals.lost += stats.lost;\n totals.slack = Math.min(totals.slack, stats.slack);\n totals.filled += stats.filled;\n totals.skipped += stats.skipped;\n totals.errorMin = Math.min(totals.errorMin, stats.errorMin);\n totals.errorMax = Math.max(totals.errorMax, stats.errorMax);\n totals.corrections += stats.corrections;\n}\n\nfunction interpolateSample(\n samples: Float32Array,\n nextChunk: LiveChunk | undefined,\n channelIndex: number,\n index: number,\n fraction: number\n): number {\n const sample = samples[index] ?? 0;\n if (fraction === 0) {\n return sample;\n }\n if (index + 1 < samples.length) {\n const following = samples[index + 1] ?? sample;\n return sample + (following - sample) * fraction;\n }\n const nextSamples =\n nextChunk?.channels[channelIndex] ?? nextChunk?.channels[0];\n const following =\n nextSamples && nextSamples.length > 0 ? (nextSamples[0] ?? sample) : sample;\n return sample + (following - sample) * fraction;\n}\n\n/**\n * Sample-accurate audio timeline used inside the `\"couch-live\"` AudioWorklet.\n * Backed by a fixed-capacity ring buffer (zero `Array.prototype.shift()`, zero\n * allocations during `render()`), dropping the oldest chunk on overflow,\n * slewing smoothly at ±0.3% outside a 1 ms deadband, and hard re-placing beyond\n * 200 ms error.\n */\nexport class LiveTimeline {\n private readonly capacity: number;\n private readonly ring: (LiveChunk | undefined)[];\n private head = 0;\n private tail = 0;\n private count = 0;\n private position = 0;\n private playing = false;\n private dry = false;\n private endStampUs: number | undefined;\n private correcting = 0;\n private settling = false;\n private rate = 1;\n private readonly sampleRate: number;\n\n stats: LiveStats = noStats();\n\n constructor(\n sampleRate: number,\n capacity: number = DEFAULT_LIVE_TIMELINE_CAPACITY\n ) {\n this.sampleRate = sampleRate;\n const normalizedCapacity = Number.isFinite(capacity)\n ? Math.max(2, Math.floor(capacity))\n : DEFAULT_LIVE_TIMELINE_CAPACITY;\n this.capacity = normalizedCapacity;\n this.ring = Array.from<LiveChunk | undefined>({\n length: normalizedCapacity,\n });\n }\n\n get length(): number {\n return this.count;\n }\n\n get maxCapacity(): number {\n return this.capacity;\n }\n\n reset(): void {\n for (let i = 0; i < this.capacity; i += 1) {\n this.ring[i] = undefined;\n }\n this.head = 0;\n this.tail = 0;\n this.count = 0;\n this.position = 0;\n this.playing = false;\n this.dry = false;\n this.settling = false;\n this.correcting = 0;\n this.rate = 1;\n this.endStampUs = undefined;\n this.resetStatsInPlace();\n }\n\n takeStats(): LiveStats {\n const snapshot: LiveStats = {\n chunks: this.stats.chunks,\n corrections: this.stats.corrections,\n errorMax: this.stats.errorMax,\n errorMin: this.stats.errorMin,\n filled: this.stats.filled,\n lost: this.stats.lost,\n skipped: this.stats.skipped,\n slack: this.stats.slack,\n };\n this.resetStatsInPlace();\n return snapshot;\n }\n\n /**\n * Copies accumulated stats into a preallocated target object and resets\n * counters in place with zero heap allocation (safe for AudioWorklet use).\n */\n takeStatsInto(target: LiveStats): void {\n target.chunks = this.stats.chunks;\n target.corrections = this.stats.corrections;\n target.errorMax = this.stats.errorMax;\n target.errorMin = this.stats.errorMin;\n target.filled = this.stats.filled;\n target.lost = this.stats.lost;\n target.skipped = this.stats.skipped;\n target.slack = this.stats.slack;\n this.resetStatsInPlace();\n }\n\n private resetStatsInPlace(): void {\n this.stats.chunks = 0;\n this.stats.corrections = 0;\n this.stats.errorMax = Number.NEGATIVE_INFINITY;\n this.stats.errorMin = Number.POSITIVE_INFINITY;\n this.stats.filled = 0;\n this.stats.lost = 0;\n this.stats.skipped = 0;\n this.stats.slack = Number.POSITIVE_INFINITY;\n }\n\n private peek(offset: number): LiveChunk | undefined {\n if (offset < 0 || offset >= this.count) {\n return undefined;\n }\n return this.ring[(this.head + offset) % this.capacity];\n }\n\n private dequeue(): LiveChunk | undefined {\n if (this.count === 0) {\n return undefined;\n }\n const item = this.ring[this.head];\n this.ring[this.head] = undefined;\n this.head = (this.head + 1) % this.capacity;\n this.count -= 1;\n return item;\n }\n\n private enqueue(chunk: LiveChunk): void {\n if (this.count === this.capacity) {\n // Ring buffer full: drop the oldest chunk in O(1) without allocating\n this.ring[this.head] = undefined;\n this.head = (this.head + 1) % this.capacity;\n this.count -= 1;\n this.stats.lost += 1;\n if (this.playing) {\n this.playing = false;\n this.position = 0;\n this.settling = false;\n this.correcting = 0;\n this.rate = 1;\n }\n }\n this.ring[this.tail] = chunk;\n this.tail = (this.tail + 1) % this.capacity;\n this.count += 1;\n }\n\n push(chunk: LiveChunk, next: number): void {\n const length = chunk.channels[0]?.length ?? 0;\n if (length === 0) {\n return;\n }\n const slack = this.playing ? this.queued() : chunk.frame - next;\n const follows =\n this.endStampUs !== undefined &&\n Math.abs(chunk.stampUs - this.endStampUs) <= JOIN_US;\n this.stats.chunks += 1;\n this.stats.slack = Math.min(this.stats.slack, slack);\n if (slack < 0 || (this.dry && follows)) {\n this.stats.lost += 1;\n }\n this.dry = false;\n this.enqueue(chunk);\n }\n\n render(frame: number, output: Float32Array[]): void {\n const frames = output[0]?.length ?? 0;\n if (this.playing) {\n this.steer(frame);\n }\n const channelCount = output.length;\n for (let i = 0; i < frames; i += 1) {\n if (!this.playing && !this.place(frame + i)) {\n for (let c = 0; c < channelCount; c += 1) {\n const outChannel = output[c];\n if (outChannel) {\n outChannel[i] = 0;\n }\n }\n if (this.dry) {\n this.stats.filled += 1;\n }\n continue;\n }\n this.read(output, i, frame + i);\n }\n }\n\n private queued(): number {\n let frames = -this.position;\n for (let i = 0; i < this.count; i += 1) {\n const chunk = this.ring[(this.head + i) % this.capacity];\n frames += chunk?.channels[0]?.length ?? 0;\n }\n return frames / this.rate;\n }\n\n private place(frame: number): boolean {\n while (this.count > 0) {\n const chunk = this.peek(0);\n if (!chunk) {\n return false;\n }\n const offset = Math.round(frame - chunk.frame);\n const length = chunk.channels[0]?.length ?? 0;\n if (offset < 0) {\n return false;\n }\n if (offset < length) {\n this.stats.skipped += offset;\n this.position = offset;\n this.playing = true;\n return true;\n }\n this.stats.skipped += length;\n this.dequeue();\n }\n return false;\n }\n\n private steer(frame: number): void {\n const chunk = this.peek(0);\n if (!chunk) {\n return;\n }\n const error = chunk.frame + this.position - frame;\n this.stats.errorMin = Math.min(this.stats.errorMin, error);\n this.stats.errorMax = Math.max(this.stats.errorMax, error);\n if (Math.abs(error) > REPLACE_SEC * this.sampleRate) {\n this.playing = false;\n this.settling = false;\n this.correcting = 0;\n this.rate = 1;\n return;\n }\n const sign = Math.sign(error);\n if (\n this.correcting === 0 &&\n Math.abs(error) > DEADBAND_SEC * this.sampleRate\n ) {\n this.correcting = sign;\n this.settling = false;\n this.rate = 1 - sign * SLEW_RATE;\n this.stats.corrections += 1;\n } else if (this.correcting !== 0 && sign !== this.correcting) {\n this.settling = true;\n }\n }\n\n private advancePosition(chunk: LiveChunk, currentFrameIndex: number): void {\n this.position += this.rate;\n if (this.settling) {\n const whole = Math.round(this.position);\n if (Math.abs(this.position - whole) < SLEW_RATE) {\n this.position = whole;\n this.rate = 1;\n this.correcting = 0;\n this.settling = false;\n }\n }\n const length = chunk.channels[0]?.length ?? 0;\n if (this.position < length) {\n return;\n }\n this.position -= length;\n this.endStampUs = chunk.stampUs + (length / this.sampleRate) * 1e6;\n this.dequeue();\n const nextChunk = this.peek(0);\n if (nextChunk) {\n const nextFrameIndex = currentFrameIndex + 1;\n const boundaryError = nextChunk.frame + this.position - nextFrameIndex;\n if (Math.abs(boundaryError) > REPLACE_SEC * this.sampleRate) {\n this.playing = false;\n this.settling = false;\n this.correcting = 0;\n this.rate = 1;\n this.position = 0;\n }\n return;\n }\n this.playing = false;\n this.dry = true;\n this.correcting = 0;\n this.settling = false;\n this.rate = 1;\n }\n\n private read(\n output: Float32Array[],\n i: number,\n currentFrameIndex: number\n ): void {\n const chunk = this.peek(0);\n if (!chunk) {\n return;\n }\n const next = this.peek(1);\n const index = Math.floor(this.position);\n const fraction = this.position - index;\n\n for (let c = 0; c < output.length; c += 1) {\n const outChannel = output[c];\n const samples = chunk.channels[c] ?? chunk.channels[0];\n if (outChannel && samples) {\n outChannel[i] = interpolateSample(samples, next, c, index, fraction);\n }\n }\n this.advancePosition(chunk, currentFrameIndex);\n }\n}\n","// Standalone \"couch-live\" AudioWorkletProcessor.\n// LiveTimeline is inlined by tsdown so dist/worklets/couch-live.js has ZERO imports.\nimport { LiveTimeline } from \"../sync/live-timeline.ts\";\nimport type { LiveMessage, LiveStats } from \"../sync/live-timeline.ts\";\n\ndeclare const sampleRate: number;\ndeclare const currentFrame: number;\ndeclare function registerProcessor(\n name: string,\n processor: new () => object\n): void;\ndeclare class AudioWorkletProcessor {\n readonly port: MessagePort;\n}\n\nexport const COUCH_LIVE_PROCESSOR_NAME = \"couch-live\" as const;\n\nif (typeof registerProcessor === \"function\") {\n const reportFrames = sampleRate / 10;\n\n registerProcessor(\n COUCH_LIVE_PROCESSOR_NAME,\n class CouchLiveProcessor extends AudioWorkletProcessor {\n private readonly timeline = new LiveTimeline(sampleRate);\n private readonly reportStats: LiveStats = {\n chunks: 0,\n corrections: 0,\n errorMax: Number.NEGATIVE_INFINITY,\n errorMin: Number.POSITIVE_INFINITY,\n filled: 0,\n lost: 0,\n skipped: 0,\n slack: Number.POSITIVE_INFINITY,\n };\n private readonly reportPayload: { epoch: number; stats: LiveStats };\n private epoch = 0;\n private next = currentFrame;\n private reported = currentFrame;\n private feed: MessagePort | undefined;\n private disposed = false;\n\n private readonly onFeedMessage = (\n msgEvent: MessageEvent<LiveMessage | null | undefined>\n ): void => {\n if (this.disposed) {\n return;\n }\n const msg = msgEvent.data;\n if (!msg || typeof msg !== \"object\") {\n return;\n }\n if (msg.type === \"dispose\") {\n this.dispose();\n return;\n }\n if (msg.type === \"chunk\") {\n if (msg.chunk) {\n this.timeline.push(msg.chunk, this.next);\n }\n return;\n }\n if (msg.type === \"reset\") {\n this.timeline.reset();\n this.epoch = typeof msg.epoch === \"number\" ? msg.epoch : 0;\n }\n };\n\n private readonly onPortMessage = (\n event: MessageEvent<\n { port?: MessagePort; type?: string } | null | undefined\n >\n ): void => {\n if (this.disposed) {\n return;\n }\n const { data } = event;\n if (!data || typeof data !== \"object\") {\n return;\n }\n if (data.type === \"dispose\") {\n this.dispose();\n return;\n }\n if (data.type === \"poll\") {\n this.flushReport();\n return;\n }\n if (!data.port) {\n return;\n }\n this.detachFeed();\n this.feed = data.port;\n this.feed.addEventListener(\n \"message\",\n this.onFeedMessage as EventListener\n );\n if (typeof this.feed.start === \"function\") {\n this.feed.start();\n }\n };\n\n constructor() {\n super();\n this.reportPayload = { epoch: 0, stats: this.reportStats };\n this.port.addEventListener(\n \"message\",\n this.onPortMessage as EventListener\n );\n if (typeof this.port.start === \"function\") {\n this.port.start();\n }\n }\n\n private detachFeed(): void {\n if (!this.feed) {\n return;\n }\n this.feed.removeEventListener(\n \"message\",\n this.onFeedMessage as EventListener\n );\n if (typeof this.feed.close === \"function\") {\n this.feed.close();\n }\n this.feed = undefined;\n }\n\n private dispose(): void {\n if (this.disposed) {\n return;\n }\n this.disposed = true;\n this.detachFeed();\n this.timeline.reset();\n this.port.removeEventListener(\n \"message\",\n this.onPortMessage as EventListener\n );\n if (typeof this.port.close === \"function\") {\n this.port.close();\n }\n }\n\n private flushReport(): void {\n if (this.disposed || !this.feed) {\n return;\n }\n this.timeline.takeStatsInto(this.reportStats);\n this.reportPayload.epoch = this.epoch;\n // oxlint-disable-next-line unicorn/require-post-message-target-origin\n this.feed.postMessage(this.reportPayload);\n }\n\n process(_inputs: Float32Array[][], outputs: Float32Array[][]): boolean {\n if (this.disposed) {\n return false;\n }\n const [output] = outputs;\n if (!output) {\n return true;\n }\n this.timeline.render(currentFrame, output);\n this.next = currentFrame + (output[0]?.length ?? 0);\n if (this.next - this.reported >= reportFrames) {\n this.reported = this.next;\n this.flushReport();\n }\n return true;\n }\n }\n );\n}\n"],"mappings":"AAkCA,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,UAAU;AAsBhB,SAAgB,UAAqB;CACnC,OAAO;EACL,QAAQ;EACR,aAAa;EACb,UAAU,OAAO;EACjB,UAAU,OAAO;EACjB,QAAQ;EACR,MAAM;EACN,SAAS;EACT,OAAO,OAAO;CAChB;AACF;AAaA,SAAS,kBACP,SACA,WACA,cACA,OACA,UACQ;CACR,MAAM,SAAS,QAAQ,UAAU;CACjC,IAAI,aAAa,GACf,OAAO;CAET,IAAI,QAAQ,IAAI,QAAQ,QAEt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KAAK,UAAU,YAC7B,KAAK,KAAK,MAAM;GAElB,KAAK,OAAO,KAAA;EACd;EAEQ,UAAgB;GACtB,IAAI,KAAK,UACP;GAEF,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,SAAS,MAAM;GACpB,KAAK,KAAK,oBACR,WACA,KAAK,aACP;GACA,IAAI,OAAO,KAAK,KAAK,UAAU,YAC7B,KAAK,KAAK,MAAM;EAEpB;EAEQ,cAAoB;GAC1B,IAAI,KAAK,YAAY,CAAC,KAAK,MACzB;GAEF,KAAK,SAAS,cAAc,KAAK,WAAW;GAC5C,KAAK,cAAc,QAAQ,KAAK;GAEhC,KAAK,KAAK,YAAY,KAAK,aAAa;EAC1C;EAEA,QAAQ,SAA2B,SAAoC;GACrE,IAAI,KAAK,UACP,OAAO;GAET,MAAM,CAAC,UAAU;GACjB,IAAI,CAAC,QACH,OAAO;GAET,KAAK,SAAS,OAAO,cAAc,MAAM;GACzC,KAAK,OAAO,gBAAgB,OAAO,EAAE,EAAE,UAAU;GACjD,IAAI,KAAK,OAAO,KAAK,YAAY,cAAc;IAC7C,KAAK,WAAW,KAAK;IACrB,KAAK,YAAY;GACnB;GACA,OAAO;EACT;CACF,CACF;AACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/worklets/meter.ts
|
|
2
|
+
const METER_PROCESSOR_NAME = "avoid-meter";
|
|
3
|
+
const DEFAULT_QUANTUM_FRAMES = 128;
|
|
4
|
+
if (typeof registerProcessor === "function") registerProcessor(METER_PROCESSOR_NAME, class AvoidMeterProcessor extends AudioWorkletProcessor {
|
|
5
|
+
leftPeak = 0;
|
|
6
|
+
rightPeak = 0;
|
|
7
|
+
leftSumSq = 0;
|
|
8
|
+
rightSumSq = 0;
|
|
9
|
+
sampleCount = 0;
|
|
10
|
+
reportSamples;
|
|
11
|
+
payload = {
|
|
12
|
+
leftPeak: 0,
|
|
13
|
+
leftRms: 0,
|
|
14
|
+
rightPeak: 0,
|
|
15
|
+
rightRms: 0
|
|
16
|
+
};
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(options);
|
|
19
|
+
const intervalMs = options?.processorOptions?.reportIntervalMs ?? 50;
|
|
20
|
+
const clampedMs = Math.max(10, Math.min(1e3, intervalMs));
|
|
21
|
+
this.reportSamples = Math.max(DEFAULT_QUANTUM_FRAMES, Math.round(sampleRate * clampedMs / 1e3));
|
|
22
|
+
this.port.addEventListener("message", (event) => {
|
|
23
|
+
if (event.data === "poll") this.flushMeter();
|
|
24
|
+
});
|
|
25
|
+
if (typeof this.port.start === "function") this.port.start();
|
|
26
|
+
}
|
|
27
|
+
flushMeter() {
|
|
28
|
+
const count = this.sampleCount;
|
|
29
|
+
const inv = count > 0 ? 1 / count : 0;
|
|
30
|
+
this.payload.leftPeak = this.leftPeak;
|
|
31
|
+
this.payload.rightPeak = this.rightPeak;
|
|
32
|
+
this.payload.leftRms = Math.sqrt(this.leftSumSq * inv);
|
|
33
|
+
this.payload.rightRms = Math.sqrt(this.rightSumSq * inv);
|
|
34
|
+
this.port.postMessage(this.payload);
|
|
35
|
+
this.leftPeak = 0;
|
|
36
|
+
this.rightPeak = 0;
|
|
37
|
+
this.leftSumSq = 0;
|
|
38
|
+
this.rightSumSq = 0;
|
|
39
|
+
this.sampleCount = 0;
|
|
40
|
+
}
|
|
41
|
+
recordSilence(outputs) {
|
|
42
|
+
const outputLen = (outputs?.[0])?.[0]?.length ?? 0;
|
|
43
|
+
this.sampleCount += outputLen > 0 ? outputLen : DEFAULT_QUANTUM_FRAMES;
|
|
44
|
+
if (this.sampleCount >= this.reportSamples) this.flushMeter();
|
|
45
|
+
}
|
|
46
|
+
process(inputs, outputs) {
|
|
47
|
+
const [input] = inputs;
|
|
48
|
+
const left = input && input.length > 0 ? input[0] : void 0;
|
|
49
|
+
if (!left || left.length === 0) {
|
|
50
|
+
this.recordSilence(outputs);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const right = input && input.length > 1 && input[1] ? input[1] : left;
|
|
54
|
+
const frames = left.length;
|
|
55
|
+
let lPeak = this.leftPeak;
|
|
56
|
+
let rPeak = this.rightPeak;
|
|
57
|
+
let lSumSq = this.leftSumSq;
|
|
58
|
+
let rSumSq = this.rightSumSq;
|
|
59
|
+
for (let i = 0; i < frames; i += 1) {
|
|
60
|
+
const lSample = left[i] ?? 0;
|
|
61
|
+
const rSample = right[i] ?? 0;
|
|
62
|
+
const lAbs = lSample < 0 ? -lSample : lSample;
|
|
63
|
+
const rAbs = rSample < 0 ? -rSample : rSample;
|
|
64
|
+
if (lAbs > lPeak) lPeak = lAbs;
|
|
65
|
+
if (rAbs > rPeak) rPeak = rAbs;
|
|
66
|
+
lSumSq += lSample * lSample;
|
|
67
|
+
rSumSq += rSample * rSample;
|
|
68
|
+
}
|
|
69
|
+
this.leftPeak = lPeak;
|
|
70
|
+
this.rightPeak = rPeak;
|
|
71
|
+
this.leftSumSq = lSumSq;
|
|
72
|
+
this.rightSumSq = rSumSq;
|
|
73
|
+
this.sampleCount += frames;
|
|
74
|
+
if (this.sampleCount >= this.reportSamples) this.flushMeter();
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
export { METER_PROCESSOR_NAME };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=meter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meter.js","names":[],"sources":["../../src/worklets/meter.ts"],"sourcesContent":["// Standalone AudioWorkletProcessor for stereo peak & RMS metering.\n// Zero imports: compiles to a self-contained zero-import ESM file.\n\ndeclare const sampleRate: number;\ndeclare function registerProcessor(\n name: string,\n processor: new (options?: {\n processorOptions?: { reportIntervalMs?: number };\n }) => object\n): void;\ndeclare class AudioWorkletProcessor {\n readonly port: MessagePort;\n constructor(options?: { processorOptions?: { reportIntervalMs?: number } });\n}\n\nexport const METER_PROCESSOR_NAME = \"avoid-meter\" as const;\n\nexport interface MeterWorkletFrame {\n readonly leftPeak: number;\n readonly rightPeak: number;\n readonly leftRms: number;\n readonly rightRms: number;\n}\n\nconst DEFAULT_QUANTUM_FRAMES = 128;\n\nif (typeof registerProcessor === \"function\") {\n registerProcessor(\n METER_PROCESSOR_NAME,\n class AvoidMeterProcessor extends AudioWorkletProcessor {\n private leftPeak = 0;\n private rightPeak = 0;\n private leftSumSq = 0;\n private rightSumSq = 0;\n private sampleCount = 0;\n private readonly reportSamples: number;\n private readonly payload = {\n leftPeak: 0,\n leftRms: 0,\n rightPeak: 0,\n rightRms: 0,\n };\n\n constructor(options?: {\n processorOptions?: { reportIntervalMs?: number };\n }) {\n super(options);\n const intervalMs = options?.processorOptions?.reportIntervalMs ?? 50;\n const clampedMs = Math.max(10, Math.min(1000, intervalMs));\n this.reportSamples = Math.max(\n DEFAULT_QUANTUM_FRAMES,\n Math.round((sampleRate * clampedMs) / 1000)\n );\n this.port.addEventListener(\"message\", (event: MessageEvent) => {\n if (event.data === \"poll\") {\n this.flushMeter();\n }\n });\n if (typeof this.port.start === \"function\") {\n this.port.start();\n }\n }\n\n private flushMeter(): void {\n const count = this.sampleCount;\n const inv = count > 0 ? 1 / count : 0;\n this.payload.leftPeak = this.leftPeak;\n this.payload.rightPeak = this.rightPeak;\n this.payload.leftRms = Math.sqrt(this.leftSumSq * inv);\n this.payload.rightRms = Math.sqrt(this.rightSumSq * inv);\n // oxlint-disable-next-line unicorn/require-post-message-target-origin\n this.port.postMessage(this.payload);\n this.leftPeak = 0;\n this.rightPeak = 0;\n this.leftSumSq = 0;\n this.rightSumSq = 0;\n this.sampleCount = 0;\n }\n\n private recordSilence(outputs?: Float32Array[][]): void {\n const output = outputs?.[0];\n const outputLen = output?.[0]?.length ?? 0;\n this.sampleCount += outputLen > 0 ? outputLen : DEFAULT_QUANTUM_FRAMES;\n if (this.sampleCount >= this.reportSamples) {\n this.flushMeter();\n }\n }\n\n process(inputs: Float32Array[][], outputs?: Float32Array[][]): boolean {\n const [input] = inputs;\n const left = input && input.length > 0 ? input[0] : undefined;\n\n if (!left || left.length === 0) {\n // Inactive/disconnected input still represents silence: advance\n // sampleCount and flush zeros instead of freezing the last peak.\n this.recordSilence(outputs);\n return true;\n }\n\n const right = input && input.length > 1 && input[1] ? input[1] : left;\n const frames = left.length;\n\n let lPeak = this.leftPeak;\n let rPeak = this.rightPeak;\n let lSumSq = this.leftSumSq;\n let rSumSq = this.rightSumSq;\n\n for (let i = 0; i < frames; i += 1) {\n const lSample = left[i] ?? 0;\n const rSample = right[i] ?? 0;\n const lAbs = lSample < 0 ? -lSample : lSample;\n const rAbs = rSample < 0 ? -rSample : rSample;\n if (lAbs > lPeak) {\n lPeak = lAbs;\n }\n if (rAbs > rPeak) {\n rPeak = rAbs;\n }\n lSumSq += lSample * lSample;\n rSumSq += rSample * rSample;\n }\n\n this.leftPeak = lPeak;\n this.rightPeak = rPeak;\n this.leftSumSq = lSumSq;\n this.rightSumSq = rSumSq;\n this.sampleCount += frames;\n\n if (this.sampleCount >= this.reportSamples) {\n this.flushMeter();\n }\n\n return true;\n }\n }\n );\n}\n"],"mappings":";AAeA,MAAa,uBAAuB;AASpC,MAAM,yBAAyB;AAE/B,IAAI,OAAO,sBAAsB,YAC/B,kBACE,sBACA,MAAM,4BAA4B,sBAAsB;CAC9C,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,cAAc;CACL;CACA,UAAU;EACzB,UAAU;EACV,SAAS;EACT,WAAW;EACX,UAAU;CACZ;CAEA,YAAY,SAET;EACD,MAAM,OAAO;EACb,MAAM,aAAa,SAAS,kBAAkB,oBAAoB;EAClE,MAAM,YAAY,KAAK,IAAI,IAAI,KAAK,IAAI,KAAM,UAAU,CAAC;EACzD,KAAK,gBAAgB,KAAK,IACxB,wBACA,KAAK,MAAO,aAAa,YAAa,GAAI,CAC5C;EACA,KAAK,KAAK,iBAAiB,YAAY,UAAwB;GAC7D,IAAI,MAAM,SAAS,QACjB,KAAK,WAAW;EAEpB,CAAC;EACD,IAAI,OAAO,KAAK,KAAK,UAAU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O,OACT,QAAQ;GAEV,UAAU,UAAU;GACpB,UAAU,UAAU;EACtB;EAEA,KAAK,WAAW;EAChB,KAAK,YAAY;EACjB,KAAK,YAAY;EACjB,KAAK,aAAa;EAClB,KAAK,eAAe;EAEpB,IAAI,KAAK,eAAe,KAAK,eAC3B,KAAK,WAAW;EAGlB,OAAO;CACT;AACF,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,111 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avoid.quest/audio",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Modular Web Audio, DSP plugin seam, queue state machine, live sync, audio recognition, MIDI, and standalone AudioWorklet primitives built on Effect v4.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"audio-queue",
|
|
7
|
+
"audio-recognition",
|
|
8
|
+
"audio-sync",
|
|
9
|
+
"audioworklet",
|
|
10
|
+
"dsp",
|
|
11
|
+
"effect",
|
|
12
|
+
"hls",
|
|
13
|
+
"midi",
|
|
14
|
+
"web-audio"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/avoid-quest/kit/tree/main/packages/audio#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/avoid-quest/kit/issues"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/avoid-quest/kit.git",
|
|
24
|
+
"directory": "packages/audio"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"sideEffects": [
|
|
33
|
+
"./dist/worklets/*.js"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./queue": {
|
|
41
|
+
"types": "./dist/queue/index.d.ts",
|
|
42
|
+
"import": "./dist/queue/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./playback": {
|
|
45
|
+
"types": "./dist/playback/index.d.ts",
|
|
46
|
+
"import": "./dist/playback/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./routing": {
|
|
49
|
+
"types": "./dist/routing/index.d.ts",
|
|
50
|
+
"import": "./dist/routing/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./effects": {
|
|
53
|
+
"types": "./dist/effects/index.d.ts",
|
|
54
|
+
"import": "./dist/effects/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./recognize": {
|
|
57
|
+
"types": "./dist/recognize/index.d.ts",
|
|
58
|
+
"import": "./dist/recognize/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./sync": {
|
|
61
|
+
"types": "./dist/sync/index.d.ts",
|
|
62
|
+
"import": "./dist/sync/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./midi": {
|
|
65
|
+
"types": "./dist/midi/index.d.ts",
|
|
66
|
+
"import": "./dist/midi/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./worklets/couch-live": {
|
|
69
|
+
"types": "./dist/worklets/couch-live.d.ts",
|
|
70
|
+
"import": "./dist/worklets/couch-live.js"
|
|
71
|
+
},
|
|
72
|
+
"./worklets/couch-live.js": "./dist/worklets/couch-live.js",
|
|
73
|
+
"./worklets/meter": {
|
|
74
|
+
"types": "./dist/worklets/meter.d.ts",
|
|
75
|
+
"import": "./dist/worklets/meter.js"
|
|
76
|
+
},
|
|
77
|
+
"./worklets/meter.js": "./dist/worklets/meter.js"
|
|
78
|
+
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "tsdown",
|
|
84
|
+
"dev": "tsdown --watch",
|
|
85
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
86
|
+
"test": "bun test",
|
|
87
|
+
"verify": "bun ../../scripts/verify-pack.ts --exclude-entrypoints ./worklets/couch-live.js ./worklets/meter.js"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"fft.js": "^4.0.4"
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@types/bun": "^1.4.5",
|
|
94
|
+
"effect": "^4.1.7",
|
|
95
|
+
"hls.js": "^1.7.4",
|
|
96
|
+
"tsdown": "^0.23.7",
|
|
97
|
+
"typescript": "^7.0.2"
|
|
98
|
+
},
|
|
99
|
+
"peerDependencies": {
|
|
100
|
+
"effect": "^4.1.0",
|
|
101
|
+
"hls.js": "^1.7.0"
|
|
102
|
+
},
|
|
103
|
+
"peerDependenciesMeta": {
|
|
104
|
+
"hls.js": {
|
|
105
|
+
"optional": true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"engines": {
|
|
109
|
+
"node": ">=22"
|
|
110
|
+
}
|
|
111
|
+
}
|