@avoid.quest/audio 0.1.0 → 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/README.md +30 -2
- package/dist/effects/index.d.ts +21 -72
- package/dist/effects/index.js +212 -505
- package/dist/effects/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/midi/index.d.ts +0 -24
- package/dist/midi/index.js +222 -258
- package/dist/midi/index.js.map +1 -1
- 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 +60 -114
- package/dist/playback/index.js +899 -1062
- package/dist/playback/index.js.map +1 -1
- package/dist/queue/index.d.ts +8 -19
- package/dist/queue/index.js +461 -960
- package/dist/queue/index.js.map +1 -1
- package/dist/recognize/index.d.ts +37 -74
- package/dist/recognize/index.js +172 -2715
- package/dist/recognize/index.js.map +1 -1
- package/dist/routing/index.d.ts +3 -34
- package/dist/routing/index.js +413 -536
- package/dist/routing/index.js.map +1 -1
- package/dist/shazam-gBrX1NEY.d.ts +27 -0
- package/dist/sync/index.d.ts +9 -77
- package/dist/sync/index.js +320 -542
- package/dist/sync/index.js.map +1 -1
- package/dist/{worklet-loader-BvEW0oVO.d.ts → worklet-loader-BabwPALw.d.ts} +4 -7
- package/dist/{worklet-loader-S7R8ZAmP.js → worklet-loader-f741D1tk.js} +37 -52
- package/dist/worklet-loader-f741D1tk.js.map +1 -0
- package/dist/worklets/couch-live.js +110 -192
- package/dist/worklets/couch-live.js.map +1 -1
- package/dist/worklets/meter.js +14 -20
- package/dist/worklets/meter.js.map +1 -1
- 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 +8 -3
- package/dist/worklet-loader-S7R8ZAmP.js.map +0 -1
package/README.md
CHANGED
|
@@ -19,14 +19,15 @@ bun add hls.js
|
|
|
19
19
|
| --- | --- | --- |
|
|
20
20
|
| `@avoid.quest/audio` | Browser / Universal | `AudioError` tagged errors (`AudioErrorSchema`) and worklet loader helpers (`loadAudioWorklet`, `createWorkletModuleUrl`, `createWorkletBlobUrl`, `VITE_AUDIO_WORKLET_OPTIMIZE_DEPS_EXCLUDE`) |
|
|
21
21
|
| `@avoid.quest/audio/queue` | Universal (DOM-free) | Pure queue state machine (`createAudioQueue`, `QueueService`, `makeQueueServiceLayer`, `fisherYatesShuffle`, link-expiry helpers) |
|
|
22
|
-
| `@avoid.quest/audio/playback` | Browser | `AudioContextService`, `createMediaEngine` (optional `hls.js` + stall recovery), `createSampler`, `acquireInputCapture`, `createMediaSessionController` |
|
|
22
|
+
| `@avoid.quest/audio/playback` | Browser | `AudioContextService`, `createMediaEngine` (optional `hls.js` + stall recovery), `getMediaElementSourceNode`, `acquirePcmCapture` / `loadPcmCaptureWorklet`, `createSampler`, `acquireInputCapture`, `createMediaSessionController` |
|
|
23
23
|
| `@avoid.quest/audio/routing` | Browser | `createMultiSinkRouter` (multi-output `setSinkId` + per-sink delay) and `createStereoMeter` / `loadMeterWorklet` |
|
|
24
24
|
| `@avoid.quest/audio/effects` | Browser | Native Web Audio nodes (`createGain`, `createPan`, `createBiquadFilter`, `createCrossfade`, `createCompressor`) and `createDspPluginHost` (`DspPlugin` / `AudioNode` seam) |
|
|
25
|
-
| `@avoid.quest/audio/recognize` | Universal (DOM-free) | `generateShazamSignature`, `crc32`, and M3U / PLS / HLS playlist parsers (`parsePlaylist`, `parseHlsManifest`, `parseM3u`, `parsePls`) |
|
|
25
|
+
| `@avoid.quest/audio/recognize` | Universal (DOM-free) | `generateShazamSignature`, `generateShazamSignatureFromFloat32`, `createPcmRingBuffer`, `prepareShazamPcm`, `crc32`, and M3U / PLS / HLS playlist parsers (`parsePlaylist`, `parseHlsManifest`, `parseM3u`, `parsePls`) |
|
|
26
26
|
| `@avoid.quest/audio/sync` | Browser / Universal | `CCA1` binary framing, `LiveTimeline`, adaptive live buffer & lead controllers, `createSendspinReceiver`, `createLivePlayer`, `loadCouchLiveWorklet` |
|
|
27
27
|
| `@avoid.quest/audio/midi` | Browser / Universal | Web MIDI controller (`createMidiController`, `requestMidiAccess`), message parser (`parseMidiMessage`), and binding transforms |
|
|
28
28
|
| `@avoid.quest/audio/worklets/couch-live` (+ `.js`) | AudioWorklet | Standalone zero-import ring-buffer playback worklet processor |
|
|
29
29
|
| `@avoid.quest/audio/worklets/meter` (+ `.js`) | AudioWorklet | Standalone zero-import peak/RMS stereo metering worklet processor |
|
|
30
|
+
| `@avoid.quest/audio/worklets/pcm-capture` (+ `.js`) | AudioWorklet | Standalone zero-import, allocation-free mono PCM tap used by `acquirePcmCapture` |
|
|
30
31
|
|
|
31
32
|
## Quick Usage
|
|
32
33
|
|
|
@@ -64,6 +65,33 @@ const attachGraph = (ctx: AudioContext) =>
|
|
|
64
65
|
});
|
|
65
66
|
```
|
|
66
67
|
|
|
68
|
+
### Fingerprint live playback
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import {
|
|
72
|
+
acquirePcmCapture,
|
|
73
|
+
createMediaEngine,
|
|
74
|
+
getMediaElementSourceNode,
|
|
75
|
+
} from "@avoid.quest/audio/playback";
|
|
76
|
+
import { Effect } from "effect";
|
|
77
|
+
|
|
78
|
+
const identifyNowPlaying = (ctx: AudioContext, element: HTMLAudioElement) =>
|
|
79
|
+
Effect.scoped(
|
|
80
|
+
Effect.gen(function* () {
|
|
81
|
+
const engine = yield* createMediaEngine({ element });
|
|
82
|
+
yield* engine.load("https://cdn.example.com/live.m3u8", {
|
|
83
|
+
crossOrigin: "anonymous",
|
|
84
|
+
});
|
|
85
|
+
yield* engine.play();
|
|
86
|
+
const source = yield* getMediaElementSourceNode(ctx, engine);
|
|
87
|
+
const capture = yield* acquirePcmCapture(ctx, source);
|
|
88
|
+
yield* Effect.sleep("8 seconds");
|
|
89
|
+
// Mono 16 kHz Shazam signature via @avoid.quest/audio/recognize
|
|
90
|
+
return yield* capture.fingerprint();
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
```
|
|
94
|
+
|
|
67
95
|
When using Vite, add `VITE_AUDIO_WORKLET_OPTIMIZE_DEPS_EXCLUDE` to `optimizeDeps.exclude` so `import.meta.url` worklet assets resolve cleanly.
|
|
68
96
|
|
|
69
97
|
## License & Boundaries
|
package/dist/effects/index.d.ts
CHANGED
|
@@ -46,14 +46,22 @@ export declare const COMPRESSOR_PARAMETERS: {
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
type CompressorParameter = keyof typeof COMPRESSOR_PARAMETERS;
|
|
49
|
+
/**
|
|
50
|
+
* Finite, range-checked compressor settings. Bounds mirror
|
|
51
|
+
* `COMPRESSOR_PARAMETERS` (the `@avoid.quest/ui` `CompressorControls` ranges),
|
|
52
|
+
* which sit inside the native `DynamicsCompressorNode` ranges
|
|
53
|
+
* (threshold `[-100, 0]` dB, knee `[0, 40]` dB, ratio `[1, 20]`,
|
|
54
|
+
* attack/release `[0, 1]` s) so decoded settings never get silently clamped
|
|
55
|
+
* by Web Audio. `NaN` / `±Infinity` are rejected.
|
|
56
|
+
*/
|
|
49
57
|
export declare const CompressorSettingsSchema: Schema.Struct<{
|
|
50
|
-
readonly attack: Schema.
|
|
58
|
+
readonly attack: Schema.Finite;
|
|
51
59
|
readonly enabled: Schema.Boolean;
|
|
52
|
-
readonly gain: Schema.
|
|
53
|
-
readonly knee: Schema.
|
|
54
|
-
readonly ratio: Schema.
|
|
55
|
-
readonly release: Schema.
|
|
56
|
-
readonly threshold: Schema.
|
|
60
|
+
readonly gain: Schema.Finite;
|
|
61
|
+
readonly knee: Schema.Finite;
|
|
62
|
+
readonly ratio: Schema.Finite;
|
|
63
|
+
readonly release: Schema.Finite;
|
|
64
|
+
readonly threshold: Schema.Finite;
|
|
57
65
|
}>;
|
|
58
66
|
type CompressorSettings = typeof CompressorSettingsSchema.Type;
|
|
59
67
|
export declare const DEFAULT_COMPRESSOR_SETTINGS: Readonly<CompressorSettings>;
|
|
@@ -67,10 +75,7 @@ interface CompressorPrimitive {
|
|
|
67
75
|
readonly getSettings: () => CompressorSettings;
|
|
68
76
|
readonly dispose: () => void;
|
|
69
77
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Runtime type guard validating a partial compressor settings patch against
|
|
72
|
-
* the defined parameter ranges.
|
|
73
|
-
*/
|
|
78
|
+
/** Type guard for a non-empty partial settings patch within `CompressorSettingsSchema`. */
|
|
74
79
|
export declare function isCompressorPatch(value: unknown): value is Partial<CompressorSettings>;
|
|
75
80
|
/**
|
|
76
81
|
* Converts `CompressorSettings` to Couch's exact FFmpeg / mpv `libavfilter` string.
|
|
@@ -78,15 +83,11 @@ export declare function isCompressorPatch(value: unknown): value is Partial<Comp
|
|
|
78
83
|
export declare function compressorToFfmpegFilter(settings: CompressorSettings): string;
|
|
79
84
|
/**
|
|
80
85
|
* Creates a delay-aligned Web Audio `DynamicsCompressorNode` graph:
|
|
81
|
-
* - Wet branch: `input -> DynamicsCompressorNode -> makeup
|
|
82
|
-
* - Dry branch: `input -> delay (6 ms
|
|
86
|
+
* - Wet branch: `input -> DynamicsCompressorNode -> makeup -> wet -> output`
|
|
87
|
+
* - Dry branch: `input -> delay (6 ms Web Audio lookahead) -> dry -> output`
|
|
83
88
|
* - Clickless bypass crossfade (10 ms prime + 40 ms linear ramp + unused branch disconnect).
|
|
84
89
|
*/
|
|
85
90
|
export declare function createCompressor(context: BaseAudioContext, initialSettings?: CompressorSettings): CompressorPrimitive;
|
|
86
|
-
/**
|
|
87
|
-
* Upstream `@opendaw/studio-core` `EngineWorklet` monitoring cap:
|
|
88
|
-
* 8 monitoring channels = 4 stereo sources (or 8 mono sources).
|
|
89
|
-
*/
|
|
90
91
|
export declare const DEFAULT_MAX_MONITORING_CHANNELS = 8;
|
|
91
92
|
export declare const DEFAULT_MAX_STEREO_SOURCES = 4;
|
|
92
93
|
export declare const DSP_SWITCH_SECONDS = 0.03;
|
|
@@ -110,39 +111,14 @@ interface DspPluginRequirement {
|
|
|
110
111
|
readonly maxMonitoringChannels?: number;
|
|
111
112
|
}
|
|
112
113
|
type DspWriteOutcome = "applied" | "structural" | "unavailable";
|
|
113
|
-
/**
|
|
114
|
-
* Clean MIT `AudioNode` / DSP plugin seam for external engines (such as upstream
|
|
115
|
-
* single-stereo-master `EngineWorklet` DSP engines) with zero `@opendaw/*`
|
|
116
|
-
* imports inside `@avoid.quest/audio`.
|
|
117
|
-
*
|
|
118
|
-
* A plugin may attach to:
|
|
119
|
-
* - the shared stereo master bus (`connectMasterBus` / `disconnectMasterBus`),
|
|
120
|
-
* - individual registered sources (`connectSource` / `disconnectSource`), or
|
|
121
|
-
* - both (e.g. single stereo master bus + bounded monitoring sends).
|
|
122
|
-
*/
|
|
123
114
|
interface DspPlugin {
|
|
124
115
|
readonly id: string;
|
|
125
116
|
readonly name: string;
|
|
126
117
|
readonly requirements?: DspPluginRequirement;
|
|
127
|
-
/**
|
|
128
|
-
* Optional static algorithmic / worklet round-trip latency in seconds for
|
|
129
|
-
* downstream delay compensation (e.g. aligning dry/cue/multi-sink buses).
|
|
130
|
-
*/
|
|
131
118
|
readonly latencySeconds?: number;
|
|
132
|
-
/**
|
|
133
|
-
* Optional dynamic latency reporter (takes precedence over `latencySeconds`).
|
|
134
|
-
*/
|
|
135
119
|
readonly getLatencySeconds?: () => number;
|
|
136
|
-
/**
|
|
137
|
-
* Connects a single shared stereo-master DSP insert (`input -> [plugin] -> output`),
|
|
138
|
-
* avoiding per-source worklet/engine duplication.
|
|
139
|
-
*/
|
|
140
120
|
readonly connectMasterBus?: (input: AudioNode, output: AudioNode) => Effect.Effect<void, AudioUnsupportedError | AudioWorkletError> | void;
|
|
141
121
|
readonly disconnectMasterBus?: () => Effect.Effect<void> | void;
|
|
142
|
-
/**
|
|
143
|
-
* Connects an individual registered source (`input -> [plugin] -> output`),
|
|
144
|
-
* subject to `maxMonitoringChannels` capacity enforcement.
|
|
145
|
-
*/
|
|
146
122
|
readonly connectSource?: (sourceId: string, input: AudioNode, output: AudioNode, channels: 1 | 2) => Effect.Effect<void, AudioUnsupportedError | AudioWorkletError> | void;
|
|
147
123
|
readonly disconnectSource?: (sourceId: string) => Effect.Effect<void> | void;
|
|
148
124
|
readonly updateParameter?: (sourceId: string, effectId: string, parameter: string, value: number | boolean | string) => DspWriteOutcome;
|
|
@@ -151,9 +127,6 @@ interface DspPlugin {
|
|
|
151
127
|
interface DspPluginHostOptions {
|
|
152
128
|
readonly capabilities?: DspCapabilityOverrides;
|
|
153
129
|
readonly switchSeconds?: number;
|
|
154
|
-
/**
|
|
155
|
-
* Optional destination `AudioNode` automatically wired from `masterOutput`.
|
|
156
|
-
*/
|
|
157
130
|
readonly masterDestination?: AudioNode;
|
|
158
131
|
}
|
|
159
132
|
interface RegisteredDspSource {
|
|
@@ -162,9 +135,7 @@ interface RegisteredDspSource {
|
|
|
162
135
|
readonly activeMode: "bypass" | "plugin";
|
|
163
136
|
}
|
|
164
137
|
interface DspPluginHost {
|
|
165
|
-
/** Shared stereo master bus input node (sum upstream decks/channels here). */
|
|
166
138
|
readonly masterInput: GainNode;
|
|
167
|
-
/** Shared stereo master bus output node (route to destination / multi-sink). */
|
|
168
139
|
readonly masterOutput: GainNode;
|
|
169
140
|
readonly getCapabilities: () => ExternalDspCapabilities;
|
|
170
141
|
readonly getAllocatedChannels: () => number;
|
|
@@ -181,18 +152,7 @@ interface DspPluginHost {
|
|
|
181
152
|
readonly updateParameter: (sourceId: string, effectId: string, parameter: string, value: number | boolean | string) => DspWriteOutcome;
|
|
182
153
|
readonly dispose: () => Effect.Effect<void>;
|
|
183
154
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Inspects COOP/COEP (`crossOriginIsolated`), `SharedArrayBuffer`, and `AudioWorkletNode`
|
|
186
|
-
* support plus the upstream 4-stereo-source (8-channel) monitoring budget.
|
|
187
|
-
*/
|
|
188
155
|
export declare function detectExternalDspCapabilities(overrides?: DspCapabilityOverrides): ExternalDspCapabilities;
|
|
189
|
-
/**
|
|
190
|
-
* Creates a clickless `DspPluginHost` managing:
|
|
191
|
-
* - A shared stereo-master insert shell (`masterInput -> masterBypassGain || masterPluginInput -> [DspPlugin] -> masterPluginOutput -> masterPluginGain -> masterOutput`)
|
|
192
|
-
* - Optional per-source routing slots bounded by the 4-stereo-source (8-channel) monitoring cap
|
|
193
|
-
* - 30 ms clickless crossfades (waiting for fade-out before disconnecting on detach)
|
|
194
|
-
* - COOP/COEP `SharedArrayBuffer` capability gating and latency compensation reporting.
|
|
195
|
-
*/
|
|
196
156
|
export declare function createDspPluginHost(context: BaseAudioContext, options?: DspPluginHostOptions): DspPluginHost;
|
|
197
157
|
type CrossfadeCurve = "equalPower" | "linear" | "exponential";
|
|
198
158
|
export declare const DEFAULT_CROSSFADE_STEPS = 48;
|
|
@@ -240,27 +200,16 @@ interface CrossfadePrimitive {
|
|
|
240
200
|
readonly setMix: (mix: number, durationSeconds?: number, curve?: CrossfadeCurve) => number;
|
|
241
201
|
readonly dispose: () => void;
|
|
242
202
|
}
|
|
243
|
-
/**
|
|
244
|
-
* Generates a 48-step (`Float32Array(steps + 1)`) fade-in and fade-out gain curve pair
|
|
245
|
-
* for `AudioParam.setValueCurveAtTime`.
|
|
246
|
-
*/
|
|
247
|
-
export declare function createCrossfadeCurves(steps?: number, curve?: CrossfadeCurve): {
|
|
248
|
-
readonly fadeIn: Float32Array;
|
|
249
|
-
readonly fadeOut: Float32Array;
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* Evaluates equal-power, linear, or exponential gains for a mix value in `[0, 1]`
|
|
253
|
-
* (`0` = 100% A, `1` = 100% B).
|
|
254
|
-
*/
|
|
255
203
|
export declare function computeCrossfadeGains(mix: number, curve?: CrossfadeCurve): {
|
|
256
204
|
readonly gainA: number;
|
|
257
205
|
readonly gainB: number;
|
|
258
206
|
};
|
|
207
|
+
export declare function createCrossfadeCurves(steps?: number, curve?: CrossfadeCurve): {
|
|
208
|
+
readonly fadeIn: Float32Array;
|
|
209
|
+
readonly fadeOut: Float32Array;
|
|
210
|
+
};
|
|
259
211
|
export declare function createGain(context: BaseAudioContext, initialGain?: number): GainPrimitive;
|
|
260
212
|
export declare function createPan(context: BaseAudioContext, initialPan?: number): PanPrimitive;
|
|
261
213
|
export declare function createBiquadFilter(context: BaseAudioContext, options?: BiquadFilterOptions): BiquadFilterPrimitive;
|
|
262
|
-
/**
|
|
263
|
-
* Equal-power (or linear/exponential) two-input crossfader (`inputA` + `inputB` -> `output`).
|
|
264
|
-
*/
|
|
265
214
|
export declare function createCrossfade(context: BaseAudioContext, initialMix?: number, defaultCurve?: CrossfadeCurve): CrossfadePrimitive;
|
|
266
215
|
export type { BiquadFilterOptions, BiquadFilterPrimitive, CompressorParameter, CompressorPrimitive, CompressorSettings, CrossfadeCurve, CrossfadePrimitive, DspCapabilityOverrides, DspPlugin, DspPluginHost, DspPluginHostOptions, DspPluginRequirement, DspWriteOutcome, ExternalDspCapabilities, GainPrimitive, PanPrimitive, RegisteredDspSource };
|