@avoid.quest/audio 0.0.0-stage → 0.1.1-beta.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 +98 -2
- package/dist/effects/index.d.ts +215 -0
- package/dist/effects/index.js +451 -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 +138 -0
- package/dist/midi/index.js +302 -0
- package/dist/midi/index.js.map +1 -0
- package/dist/native-Bern4_PB.js +172 -0
- package/dist/native-Bern4_PB.js.map +1 -0
- package/dist/pcm-buffer-DSzGHbon.js +436 -0
- package/dist/pcm-buffer-DSzGHbon.js.map +1 -0
- package/dist/playback/index.d.ts +295 -0
- package/dist/playback/index.js +1209 -0
- package/dist/playback/index.js.map +1 -0
- package/dist/queue/index.d.ts +133 -0
- package/dist/queue/index.js +563 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/recognize/index.d.ts +124 -0
- package/dist/recognize/index.js +273 -0
- package/dist/recognize/index.js.map +1 -0
- package/dist/routing/index.d.ts +109 -0
- package/dist/routing/index.js +555 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/shazam-gBrX1NEY.d.ts +27 -0
- package/dist/sync/index.d.ts +214 -0
- package/dist/sync/index.js +881 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/worklet-loader-BabwPALw.d.ts +41 -0
- package/dist/worklet-loader-f741D1tk.js +160 -0
- package/dist/worklet-loader-f741D1tk.js.map +1 -0
- package/dist/worklets/couch-live.d.ts +1 -0
- package/dist/worklets/couch-live.js +283 -0
- package/dist/worklets/couch-live.js.map +1 -0
- package/dist/worklets/meter.d.ts +7 -0
- package/dist/worklets/meter.js +74 -0
- package/dist/worklets/meter.js.map +1 -0
- package/dist/worklets/pcm-capture.d.ts +6 -0
- package/dist/worklets/pcm-capture.js +52 -0
- package/dist/worklets/pcm-capture.js.map +1 -0
- package/package.json +114 -4
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { a as createWorkletBlobUrl, i as WorkletModuleHandle, n as VITE_AUDIO_WORKLET_OPTIMIZE_DEPS_EXCLUDE, o as createWorkletModuleUrl, r as WorkletId, s as loadAudioWorklet, t as LoadAudioWorkletOptions } from "../worklet-loader-BabwPALw.js";
|
|
2
|
+
import { Effect, Scope } from "effect";
|
|
3
|
+
import { d as AudioWorkletError, l as AudioSyncError, u as AudioUnsupportedError } from "../errors-ChTQFwuZ.js";
|
|
4
|
+
export declare const CCA1_MAGIC = 826360643;
|
|
5
|
+
export declare const CCA1_HEADER_BYTES = 40;
|
|
6
|
+
export declare const CCA1_FORMAT_F32_INTERLEAVED = 1;
|
|
7
|
+
export declare const CCA1_MAX_FRAMES = 4096;
|
|
8
|
+
export declare const CCA1_MAX_PACKET_BYTES: number;
|
|
9
|
+
export declare const CCA1_ALLOWED_SAMPLE_RATES: readonly [44100, 48000, 96000];
|
|
10
|
+
export declare const CCA1_MAX_CLOCK_RTT_US = 100000;
|
|
11
|
+
type Cca1SampleRate = (typeof CCA1_ALLOWED_SAMPLE_RATES)[number];
|
|
12
|
+
interface Cca1Packet {
|
|
13
|
+
readonly generation?: string;
|
|
14
|
+
readonly channels: 1 | 2;
|
|
15
|
+
readonly sampleRate: Cca1SampleRate;
|
|
16
|
+
readonly sequence: number;
|
|
17
|
+
readonly samplePosition: number;
|
|
18
|
+
readonly capturedAtUs: number;
|
|
19
|
+
readonly pcm: Float32Array;
|
|
20
|
+
}
|
|
21
|
+
interface ClockPingSample {
|
|
22
|
+
readonly clientSentUs: number;
|
|
23
|
+
readonly serverUs: number;
|
|
24
|
+
readonly clientReceivedUs: number;
|
|
25
|
+
}
|
|
26
|
+
interface ClockHandshakeResult {
|
|
27
|
+
readonly rttUs: number;
|
|
28
|
+
readonly offsetUs: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function validateCca1Packet(packet: Cca1Packet): Effect.Effect<Cca1Packet, AudioSyncError>;
|
|
31
|
+
export declare function encodeCca1Frame(packet: Cca1Packet): Effect.Effect<Uint8Array, AudioSyncError>;
|
|
32
|
+
export declare function decodeCca1Frame(data: Uint8Array | ArrayBuffer, options?: {
|
|
33
|
+
readonly generation?: string;
|
|
34
|
+
readonly clockOffsetUs?: number;
|
|
35
|
+
}): Effect.Effect<Cca1Packet, AudioSyncError>;
|
|
36
|
+
export declare function computeClockHandshake(samples: readonly ClockPingSample[], maxRttUs?: number): Effect.Effect<ClockHandshakeResult, AudioSyncError>;
|
|
37
|
+
export declare const SDK_BATCH_MS = 15;
|
|
38
|
+
interface LossSecond {
|
|
39
|
+
readonly chunks: number;
|
|
40
|
+
readonly lost: number;
|
|
41
|
+
readonly sendAheadMs?: number;
|
|
42
|
+
readonly lateMs?: number;
|
|
43
|
+
readonly syncErrorMs?: number;
|
|
44
|
+
}
|
|
45
|
+
interface Recurring {
|
|
46
|
+
readonly measure: "running" | "chunks" | "spells";
|
|
47
|
+
readonly count: number;
|
|
48
|
+
readonly stepMs: number;
|
|
49
|
+
}
|
|
50
|
+
interface MovingPhase {
|
|
51
|
+
readonly kind: "moving";
|
|
52
|
+
readonly caused: Recurring;
|
|
53
|
+
readonly sendAheadMs?: number;
|
|
54
|
+
readonly askedMs: number;
|
|
55
|
+
readonly landedMs: number;
|
|
56
|
+
readonly waited: number;
|
|
57
|
+
}
|
|
58
|
+
type Phase = {
|
|
59
|
+
readonly kind: "watching";
|
|
60
|
+
} | MovingPhase | {
|
|
61
|
+
readonly kind: "pausing";
|
|
62
|
+
readonly left: number;
|
|
63
|
+
};
|
|
64
|
+
interface LateSteps {
|
|
65
|
+
readonly lateMs: number;
|
|
66
|
+
readonly partMs?: number;
|
|
67
|
+
readonly unhelpful: number;
|
|
68
|
+
readonly caused?: Recurring;
|
|
69
|
+
readonly clean: number;
|
|
70
|
+
readonly counted: number;
|
|
71
|
+
readonly taken: readonly {
|
|
72
|
+
readonly at: number;
|
|
73
|
+
readonly ms: number;
|
|
74
|
+
}[];
|
|
75
|
+
readonly seconds: readonly LossSecond[];
|
|
76
|
+
readonly phase: Phase;
|
|
77
|
+
}
|
|
78
|
+
export declare const NO_LATE_STEPS: LateSteps;
|
|
79
|
+
export declare const SDK_LATE_STEPS: LateSteps;
|
|
80
|
+
export declare const FIRST_HOUR_MAX_LATE_MS: number;
|
|
81
|
+
export declare const SUBSEQUENT_HOUR_MAX_LATE_MS: number;
|
|
82
|
+
export declare const arrivalLateMs: (sendAheadMs: number, stampUs: number, nowUs: number) => number;
|
|
83
|
+
export declare function measuredLateMs(seconds: readonly number[]): number | undefined;
|
|
84
|
+
export declare const declareLiveBuffer: (declaredMs: number | undefined, latencyMs?: readonly number[], allowanceMs?: number) => number | undefined;
|
|
85
|
+
export declare const withLateSteps: (needMs: number, lateMs: number) => number;
|
|
86
|
+
export declare function nextLateSteps(before: LateSteps, second: LossSecond): LateSteps;
|
|
87
|
+
type LiveWire = "opus" | "pcm";
|
|
88
|
+
interface LiveLeadController {
|
|
89
|
+
readonly arrived: (wire: LiveWire, capturedAtUs: number, nowUs: number) => void;
|
|
90
|
+
readonly leadMs: (clientId: string, wire: LiveWire, declaredMs: number | undefined, name?: string) => number;
|
|
91
|
+
readonly measureMs: (wire: LiveWire) => number | undefined;
|
|
92
|
+
readonly restart: () => void;
|
|
93
|
+
readonly left: (clientId: string) => void;
|
|
94
|
+
}
|
|
95
|
+
export declare function createLiveLead(log?: (line: string) => void, nowMs?: () => number): LiveLeadController;
|
|
96
|
+
export declare const LIVE_STEP_MS = 5;
|
|
97
|
+
export declare const LIVE_LATE_STEP_MS = 10;
|
|
98
|
+
export declare const LIVE_READINGS = 5;
|
|
99
|
+
export declare function liveStep(needMs: number): number;
|
|
100
|
+
/**
|
|
101
|
+
* Computes a monotonically rising buffered need from recent once-a-second readings.
|
|
102
|
+
* Sets immediately on the first reading; subsequently raises only when the median
|
|
103
|
+
* of the last `window` readings exceeds `currentMs + LIVE_STEP_MS`.
|
|
104
|
+
*/
|
|
105
|
+
export declare function risenNeed(currentMs: number | undefined, readingsMs: readonly number[], allowanceMs?: number, window?: number): number | undefined;
|
|
106
|
+
interface LiveChunk {
|
|
107
|
+
readonly frame: number;
|
|
108
|
+
readonly stampUs: number;
|
|
109
|
+
readonly channels: readonly Float32Array[];
|
|
110
|
+
}
|
|
111
|
+
type LiveMessage = {
|
|
112
|
+
readonly type: "chunk";
|
|
113
|
+
readonly chunk: LiveChunk;
|
|
114
|
+
} | {
|
|
115
|
+
readonly type: "reset";
|
|
116
|
+
readonly epoch: number;
|
|
117
|
+
} | {
|
|
118
|
+
readonly type: "dispose";
|
|
119
|
+
};
|
|
120
|
+
interface LiveClock {
|
|
121
|
+
readonly offset: number;
|
|
122
|
+
readonly sampleRate: number;
|
|
123
|
+
}
|
|
124
|
+
interface PageClockEstimator {
|
|
125
|
+
readonly saw: (pageMs: number, ownMs?: number) => void;
|
|
126
|
+
readonly pageMs: (ownMs?: number) => number;
|
|
127
|
+
}
|
|
128
|
+
interface LiveStats {
|
|
129
|
+
chunks: number;
|
|
130
|
+
lost: number;
|
|
131
|
+
slack: number;
|
|
132
|
+
filled: number;
|
|
133
|
+
skipped: number;
|
|
134
|
+
errorMin: number;
|
|
135
|
+
errorMax: number;
|
|
136
|
+
corrections: number;
|
|
137
|
+
}
|
|
138
|
+
export declare const DEFAULT_LIVE_TIMELINE_CAPACITY = 256;
|
|
139
|
+
export declare const contextFrame: (clock: LiveClock, pageMs: number) => number;
|
|
140
|
+
export declare function pageClock(): PageClockEstimator;
|
|
141
|
+
export declare const noStats: () => LiveStats;
|
|
142
|
+
export declare function addStats(totals: LiveStats, stats: LiveStats): void;
|
|
143
|
+
export declare class LiveTimeline {
|
|
144
|
+
private readonly capacity;
|
|
145
|
+
private readonly ring;
|
|
146
|
+
private head;
|
|
147
|
+
private tail;
|
|
148
|
+
private count;
|
|
149
|
+
private position;
|
|
150
|
+
private playing;
|
|
151
|
+
private dry;
|
|
152
|
+
private endStampUs;
|
|
153
|
+
private correcting;
|
|
154
|
+
private settling;
|
|
155
|
+
private rate;
|
|
156
|
+
private readonly sampleRate;
|
|
157
|
+
stats: LiveStats;
|
|
158
|
+
constructor(sampleRate: number, capacity?: number);
|
|
159
|
+
get length(): number;
|
|
160
|
+
get maxCapacity(): number;
|
|
161
|
+
reset(): void;
|
|
162
|
+
takeStats(): LiveStats;
|
|
163
|
+
takeStatsInto(target: LiveStats): void;
|
|
164
|
+
private stopSlew;
|
|
165
|
+
private at;
|
|
166
|
+
private dropHead;
|
|
167
|
+
push(chunk: LiveChunk, next: number): void;
|
|
168
|
+
render(frame: number, output: Float32Array[]): void;
|
|
169
|
+
private queued;
|
|
170
|
+
private place;
|
|
171
|
+
private steer;
|
|
172
|
+
private read;
|
|
173
|
+
}
|
|
174
|
+
export declare const COUCH_LIVE_PROCESSOR_NAME: "couch-live";
|
|
175
|
+
export declare const SENDSPIN_BINARY_AUDIO_TYPE = 4;
|
|
176
|
+
export declare const SENDSPIN_VOLUME_RAMP_TIME_CONSTANT_S = 0.015;
|
|
177
|
+
interface SendspinAudioHeader {
|
|
178
|
+
readonly messageType: 4;
|
|
179
|
+
readonly stampUs: number;
|
|
180
|
+
readonly sendAheadUs: number;
|
|
181
|
+
}
|
|
182
|
+
interface LoadCouchLiveWorkletOptions {
|
|
183
|
+
readonly moduleUrl?: string;
|
|
184
|
+
readonly inlineSource?: string;
|
|
185
|
+
readonly fallbackToBlob?: boolean;
|
|
186
|
+
readonly fetchImpl?: typeof fetch;
|
|
187
|
+
}
|
|
188
|
+
interface SendspinReceiverOptions {
|
|
189
|
+
readonly outputNode?: AudioNode;
|
|
190
|
+
readonly initialVolume?: number;
|
|
191
|
+
readonly initialMuted?: boolean;
|
|
192
|
+
readonly workletOptions?: LoadCouchLiveWorkletOptions;
|
|
193
|
+
readonly onStats?: (epoch: number, stats: LiveStats) => void;
|
|
194
|
+
}
|
|
195
|
+
interface SendspinReceiver {
|
|
196
|
+
readonly outputGain: GainNode;
|
|
197
|
+
readonly targetNode: AudioNode;
|
|
198
|
+
readonly workletNode: AudioWorkletNode;
|
|
199
|
+
readonly feedPort: MessagePort;
|
|
200
|
+
readonly pushChunk: (chunk: LiveChunk) => void;
|
|
201
|
+
readonly resetTimeline: (epoch?: number) => number;
|
|
202
|
+
readonly setVolume: (volumePercent: number) => number;
|
|
203
|
+
readonly setMuted: (muted: boolean) => boolean;
|
|
204
|
+
readonly reconnectOutput: (nextOutputNode: AudioNode) => void;
|
|
205
|
+
readonly dispose: () => void;
|
|
206
|
+
}
|
|
207
|
+
export declare function computeLiveVolumeGain(volumePercent: number, muted: boolean): number;
|
|
208
|
+
export declare function sniffSendspinAudioHeader(data: Uint8Array | ArrayBuffer): SendspinAudioHeader | undefined;
|
|
209
|
+
export declare function loadCouchLiveWorklet(context: BaseAudioContext, options?: LoadCouchLiveWorkletOptions): Effect.Effect<void, AudioUnsupportedError | AudioWorkletError>;
|
|
210
|
+
export declare function createSendspinReceiver(context: BaseAudioContext, options?: SendspinReceiverOptions): Effect.Effect<SendspinReceiver, AudioUnsupportedError | AudioWorkletError, Scope.Scope>;
|
|
211
|
+
export declare function createLivePlayer(context: BaseAudioContext, options?: LivePlayerOptions): Effect.Effect<LivePlayer, AudioUnsupportedError | AudioWorkletError, Scope.Scope>;
|
|
212
|
+
type LivePlayer = SendspinReceiver;
|
|
213
|
+
type LivePlayerOptions = SendspinReceiverOptions;
|
|
214
|
+
export { type Cca1Packet, type Cca1SampleRate, type ClockHandshakeResult, type ClockPingSample, type LateSteps, type LiveChunk, type LiveClock, type LiveLeadController, type LiveMessage, type LivePlayer, type LivePlayerOptions, type LiveStats, type LiveWire, type LoadAudioWorkletOptions, type LoadCouchLiveWorkletOptions, type LossSecond, type PageClockEstimator, type SendspinAudioHeader, type SendspinReceiver, type SendspinReceiverOptions, VITE_AUDIO_WORKLET_OPTIMIZE_DEPS_EXCLUDE, type WorkletId, type WorkletModuleHandle, createWorkletBlobUrl, createWorkletModuleUrl, loadAudioWorklet };
|