@camstack/addon-provider-rademacher 0.2.94 → 0.2.95
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/dist/addon.js +216 -3
- package/dist/addon.mjs +216 -3
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -6330,6 +6330,86 @@ var ZodIssueCode = {
|
|
|
6330
6330
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
6331
6331
|
var ZodFirstPartyTypeKind;
|
|
6332
6332
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6333
|
+
//#endregion
|
|
6334
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
6335
|
+
/**
|
|
6336
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6337
|
+
* window to float samples (D455).
|
|
6338
|
+
*
|
|
6339
|
+
* ## Why a format at all
|
|
6340
|
+
*
|
|
6341
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
6342
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
6343
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
6344
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
6345
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
6346
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
6347
|
+
*
|
|
6348
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
6349
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
6350
|
+
* one step further along the same wire.
|
|
6351
|
+
*
|
|
6352
|
+
* ## Why the expansion lives here
|
|
6353
|
+
*
|
|
6354
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
6355
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
6356
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
6357
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
6358
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
6359
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
6360
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
6361
|
+
* `camstack deploy` and needs no published server.
|
|
6362
|
+
*
|
|
6363
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
6364
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
6365
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
6366
|
+
*
|
|
6367
|
+
* ## Absent means f32le
|
|
6368
|
+
*
|
|
6369
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
6370
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
6371
|
+
* has always been served, because the broker only emits a coded window to a
|
|
6372
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
6373
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
6374
|
+
* deployable one addon at a time across three nodes.
|
|
6375
|
+
*/
|
|
6376
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
6377
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
6378
|
+
"f32le",
|
|
6379
|
+
"pcmu",
|
|
6380
|
+
"pcma"
|
|
6381
|
+
];
|
|
6382
|
+
/**
|
|
6383
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
6384
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
6385
|
+
*
|
|
6386
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
6387
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
6388
|
+
*/
|
|
6389
|
+
function buildUlawTable() {
|
|
6390
|
+
const table = new Float32Array(256);
|
|
6391
|
+
for (let i = 0; i < 256; i++) {
|
|
6392
|
+
const complemented = ~i & 255;
|
|
6393
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
6394
|
+
const exponent = complemented >> 4 & 7;
|
|
6395
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
6396
|
+
}
|
|
6397
|
+
return table;
|
|
6398
|
+
}
|
|
6399
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
6400
|
+
function buildAlawTable() {
|
|
6401
|
+
const table = new Float32Array(256);
|
|
6402
|
+
for (let i = 0; i < 256; i++) {
|
|
6403
|
+
const xored = i ^ 85;
|
|
6404
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
6405
|
+
const exponent = xored >> 4 & 7;
|
|
6406
|
+
const mantissa = xored & 15;
|
|
6407
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
6408
|
+
}
|
|
6409
|
+
return table;
|
|
6410
|
+
}
|
|
6411
|
+
buildUlawTable();
|
|
6412
|
+
buildAlawTable();
|
|
6333
6413
|
Object.fromEntries([
|
|
6334
6414
|
{
|
|
6335
6415
|
id: "overview",
|
|
@@ -7622,11 +7702,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
7622
7702
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
7623
7703
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
7624
7704
|
*/
|
|
7705
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
7625
7706
|
var DecodedAudioChunkSchema = object({
|
|
7626
7707
|
data: _instanceof(Uint8Array),
|
|
7627
7708
|
sampleRate: number().int().positive(),
|
|
7628
7709
|
channels: number().int().positive(),
|
|
7629
|
-
timestamp: number()
|
|
7710
|
+
timestamp: number(),
|
|
7711
|
+
/**
|
|
7712
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
7713
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
7714
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
7715
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
7716
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
7717
|
+
*/
|
|
7718
|
+
format: AudioChunkFormatSchema.optional()
|
|
7630
7719
|
});
|
|
7631
7720
|
/**
|
|
7632
7721
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -7638,7 +7727,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
7638
7727
|
var SubscribeAudioChunksInputSchema = object({
|
|
7639
7728
|
brokerId: string(),
|
|
7640
7729
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
7641
|
-
tag: string().optional()
|
|
7730
|
+
tag: string().optional(),
|
|
7731
|
+
/**
|
|
7732
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
7733
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
7734
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
7735
|
+
*
|
|
7736
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
7737
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
7738
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
7739
|
+
* deploy one at a time across three nodes.
|
|
7740
|
+
*/
|
|
7741
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
7642
7742
|
});
|
|
7643
7743
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
7644
7744
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11626,6 +11726,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11626
11726
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11627
11727
|
allowedClasses: array(string()).default([])
|
|
11628
11728
|
});
|
|
11729
|
+
/**
|
|
11730
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11731
|
+
*
|
|
11732
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11733
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11734
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11735
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11736
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11737
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11738
|
+
* way to the one expansion that feeds the model.
|
|
11739
|
+
*
|
|
11740
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11741
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11742
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11743
|
+
*/
|
|
11744
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11745
|
+
deviceId: number(),
|
|
11746
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11747
|
+
brokerId: string(),
|
|
11748
|
+
/**
|
|
11749
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11750
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11751
|
+
* the orchestrator's poller pinned them before the move.
|
|
11752
|
+
*/
|
|
11753
|
+
ingestNodeId: string(),
|
|
11754
|
+
/**
|
|
11755
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11756
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11757
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11758
|
+
*/
|
|
11759
|
+
settings: AudioAnalysisSettingsSchema
|
|
11760
|
+
});
|
|
11761
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11762
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11763
|
+
attached: boolean(),
|
|
11764
|
+
/**
|
|
11765
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11766
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11767
|
+
* double the broker's fanout and neither would know about the other.
|
|
11768
|
+
*/
|
|
11769
|
+
replaced: boolean()
|
|
11770
|
+
});
|
|
11771
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11772
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11773
|
+
detached: boolean() });
|
|
11629
11774
|
var AudioClassificationResultSchema = object({
|
|
11630
11775
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11631
11776
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11634,7 +11779,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11634
11779
|
method(object({
|
|
11635
11780
|
chunk: AudioChunkInputSchema,
|
|
11636
11781
|
settings: AudioAnalysisSettingsSchema
|
|
11637
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11782
|
+
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11638
11783
|
kind: "mutation",
|
|
11639
11784
|
auth: "admin"
|
|
11640
11785
|
});
|
|
@@ -35893,12 +36038,24 @@ Object.freeze({
|
|
|
35893
36038
|
addonId: null,
|
|
35894
36039
|
access: "create"
|
|
35895
36040
|
},
|
|
36041
|
+
"audioAnalyzer.attachDevice": {
|
|
36042
|
+
capName: "audio-analyzer",
|
|
36043
|
+
capScope: "system",
|
|
36044
|
+
addonId: null,
|
|
36045
|
+
access: "create"
|
|
36046
|
+
},
|
|
35896
36047
|
"audioAnalyzer.classify": {
|
|
35897
36048
|
capName: "audio-analyzer",
|
|
35898
36049
|
capScope: "system",
|
|
35899
36050
|
addonId: null,
|
|
35900
36051
|
access: "view"
|
|
35901
36052
|
},
|
|
36053
|
+
"audioAnalyzer.detachDevice": {
|
|
36054
|
+
capName: "audio-analyzer",
|
|
36055
|
+
capScope: "system",
|
|
36056
|
+
addonId: null,
|
|
36057
|
+
access: "create"
|
|
36058
|
+
},
|
|
35902
36059
|
"audioAnalyzer.dispose": {
|
|
35903
36060
|
capName: "audio-analyzer",
|
|
35904
36061
|
capScope: "system",
|
|
@@ -41742,11 +41899,21 @@ Object.freeze({
|
|
|
41742
41899
|
form: "single",
|
|
41743
41900
|
optional: false
|
|
41744
41901
|
}],
|
|
41902
|
+
"audioAnalyzer.attachDevice": [{
|
|
41903
|
+
name: "deviceId",
|
|
41904
|
+
form: "single",
|
|
41905
|
+
optional: false
|
|
41906
|
+
}],
|
|
41745
41907
|
"audioAnalyzer.classify": [{
|
|
41746
41908
|
name: "deviceId",
|
|
41747
41909
|
form: "single",
|
|
41748
41910
|
optional: true
|
|
41749
41911
|
}],
|
|
41912
|
+
"audioAnalyzer.detachDevice": [{
|
|
41913
|
+
name: "deviceId",
|
|
41914
|
+
form: "single",
|
|
41915
|
+
optional: false
|
|
41916
|
+
}],
|
|
41750
41917
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41751
41918
|
name: "deviceId",
|
|
41752
41919
|
form: "single",
|
|
@@ -43598,6 +43765,52 @@ Object.freeze({
|
|
|
43598
43765
|
"network-access": "ingress",
|
|
43599
43766
|
"smtp-provider": "email"
|
|
43600
43767
|
});
|
|
43768
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43769
|
+
PCMU: 20 * Math.log10(4),
|
|
43770
|
+
PCMA: 20 * Math.log10(8)
|
|
43771
|
+
};
|
|
43772
|
+
/**
|
|
43773
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43774
|
+
* same intent on the ITU-T scale (D460).
|
|
43775
|
+
*
|
|
43776
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43777
|
+
*
|
|
43778
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43779
|
+
* them converts:
|
|
43780
|
+
*
|
|
43781
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43782
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43783
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43784
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43785
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43786
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43787
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43788
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43789
|
+
* louder. That is what this function is for.
|
|
43790
|
+
*
|
|
43791
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43792
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43793
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43794
|
+
* mandatory.
|
|
43795
|
+
*
|
|
43796
|
+
* ## Why a function and not a typed-in number
|
|
43797
|
+
*
|
|
43798
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43799
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43800
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43801
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43802
|
+
* having to reverse-engineer the sum.
|
|
43803
|
+
*
|
|
43804
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43805
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43806
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43807
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43808
|
+
* an extra place to argue with (D459).
|
|
43809
|
+
*/
|
|
43810
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43811
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43812
|
+
}
|
|
43813
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43601
43814
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43602
43815
|
var NC_AUDIO_DEFAULTS = {
|
|
43603
43816
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -6329,6 +6329,86 @@ var ZodIssueCode = {
|
|
|
6329
6329
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
6330
6330
|
var ZodFirstPartyTypeKind;
|
|
6331
6331
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6332
|
+
//#endregion
|
|
6333
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
6334
|
+
/**
|
|
6335
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6336
|
+
* window to float samples (D455).
|
|
6337
|
+
*
|
|
6338
|
+
* ## Why a format at all
|
|
6339
|
+
*
|
|
6340
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
6341
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
6342
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
6343
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
6344
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
6345
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
6346
|
+
*
|
|
6347
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
6348
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
6349
|
+
* one step further along the same wire.
|
|
6350
|
+
*
|
|
6351
|
+
* ## Why the expansion lives here
|
|
6352
|
+
*
|
|
6353
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
6354
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
6355
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
6356
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
6357
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
6358
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
6359
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
6360
|
+
* `camstack deploy` and needs no published server.
|
|
6361
|
+
*
|
|
6362
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
6363
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
6364
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
6365
|
+
*
|
|
6366
|
+
* ## Absent means f32le
|
|
6367
|
+
*
|
|
6368
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
6369
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
6370
|
+
* has always been served, because the broker only emits a coded window to a
|
|
6371
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
6372
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
6373
|
+
* deployable one addon at a time across three nodes.
|
|
6374
|
+
*/
|
|
6375
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
6376
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
6377
|
+
"f32le",
|
|
6378
|
+
"pcmu",
|
|
6379
|
+
"pcma"
|
|
6380
|
+
];
|
|
6381
|
+
/**
|
|
6382
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
6383
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
6384
|
+
*
|
|
6385
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
6386
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
6387
|
+
*/
|
|
6388
|
+
function buildUlawTable() {
|
|
6389
|
+
const table = new Float32Array(256);
|
|
6390
|
+
for (let i = 0; i < 256; i++) {
|
|
6391
|
+
const complemented = ~i & 255;
|
|
6392
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
6393
|
+
const exponent = complemented >> 4 & 7;
|
|
6394
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
6395
|
+
}
|
|
6396
|
+
return table;
|
|
6397
|
+
}
|
|
6398
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
6399
|
+
function buildAlawTable() {
|
|
6400
|
+
const table = new Float32Array(256);
|
|
6401
|
+
for (let i = 0; i < 256; i++) {
|
|
6402
|
+
const xored = i ^ 85;
|
|
6403
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
6404
|
+
const exponent = xored >> 4 & 7;
|
|
6405
|
+
const mantissa = xored & 15;
|
|
6406
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
6407
|
+
}
|
|
6408
|
+
return table;
|
|
6409
|
+
}
|
|
6410
|
+
buildUlawTable();
|
|
6411
|
+
buildAlawTable();
|
|
6332
6412
|
Object.fromEntries([
|
|
6333
6413
|
{
|
|
6334
6414
|
id: "overview",
|
|
@@ -7621,11 +7701,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
7621
7701
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
7622
7702
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
7623
7703
|
*/
|
|
7704
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
7624
7705
|
var DecodedAudioChunkSchema = object({
|
|
7625
7706
|
data: _instanceof(Uint8Array),
|
|
7626
7707
|
sampleRate: number().int().positive(),
|
|
7627
7708
|
channels: number().int().positive(),
|
|
7628
|
-
timestamp: number()
|
|
7709
|
+
timestamp: number(),
|
|
7710
|
+
/**
|
|
7711
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
7712
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
7713
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
7714
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
7715
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
7716
|
+
*/
|
|
7717
|
+
format: AudioChunkFormatSchema.optional()
|
|
7629
7718
|
});
|
|
7630
7719
|
/**
|
|
7631
7720
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -7637,7 +7726,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
7637
7726
|
var SubscribeAudioChunksInputSchema = object({
|
|
7638
7727
|
brokerId: string(),
|
|
7639
7728
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
7640
|
-
tag: string().optional()
|
|
7729
|
+
tag: string().optional(),
|
|
7730
|
+
/**
|
|
7731
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
7732
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
7733
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
7734
|
+
*
|
|
7735
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
7736
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
7737
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
7738
|
+
* deploy one at a time across three nodes.
|
|
7739
|
+
*/
|
|
7740
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
7641
7741
|
});
|
|
7642
7742
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
7643
7743
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11625,6 +11725,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11625
11725
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11626
11726
|
allowedClasses: array(string()).default([])
|
|
11627
11727
|
});
|
|
11728
|
+
/**
|
|
11729
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11730
|
+
*
|
|
11731
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11732
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11733
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11734
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11735
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11736
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11737
|
+
* way to the one expansion that feeds the model.
|
|
11738
|
+
*
|
|
11739
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11740
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11741
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11742
|
+
*/
|
|
11743
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11744
|
+
deviceId: number(),
|
|
11745
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11746
|
+
brokerId: string(),
|
|
11747
|
+
/**
|
|
11748
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11749
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11750
|
+
* the orchestrator's poller pinned them before the move.
|
|
11751
|
+
*/
|
|
11752
|
+
ingestNodeId: string(),
|
|
11753
|
+
/**
|
|
11754
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11755
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11756
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11757
|
+
*/
|
|
11758
|
+
settings: AudioAnalysisSettingsSchema
|
|
11759
|
+
});
|
|
11760
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11761
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11762
|
+
attached: boolean(),
|
|
11763
|
+
/**
|
|
11764
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11765
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11766
|
+
* double the broker's fanout and neither would know about the other.
|
|
11767
|
+
*/
|
|
11768
|
+
replaced: boolean()
|
|
11769
|
+
});
|
|
11770
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11771
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11772
|
+
detached: boolean() });
|
|
11628
11773
|
var AudioClassificationResultSchema = object({
|
|
11629
11774
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11630
11775
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11633,7 +11778,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11633
11778
|
method(object({
|
|
11634
11779
|
chunk: AudioChunkInputSchema,
|
|
11635
11780
|
settings: AudioAnalysisSettingsSchema
|
|
11636
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11781
|
+
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11637
11782
|
kind: "mutation",
|
|
11638
11783
|
auth: "admin"
|
|
11639
11784
|
});
|
|
@@ -35892,12 +36037,24 @@ Object.freeze({
|
|
|
35892
36037
|
addonId: null,
|
|
35893
36038
|
access: "create"
|
|
35894
36039
|
},
|
|
36040
|
+
"audioAnalyzer.attachDevice": {
|
|
36041
|
+
capName: "audio-analyzer",
|
|
36042
|
+
capScope: "system",
|
|
36043
|
+
addonId: null,
|
|
36044
|
+
access: "create"
|
|
36045
|
+
},
|
|
35895
36046
|
"audioAnalyzer.classify": {
|
|
35896
36047
|
capName: "audio-analyzer",
|
|
35897
36048
|
capScope: "system",
|
|
35898
36049
|
addonId: null,
|
|
35899
36050
|
access: "view"
|
|
35900
36051
|
},
|
|
36052
|
+
"audioAnalyzer.detachDevice": {
|
|
36053
|
+
capName: "audio-analyzer",
|
|
36054
|
+
capScope: "system",
|
|
36055
|
+
addonId: null,
|
|
36056
|
+
access: "create"
|
|
36057
|
+
},
|
|
35901
36058
|
"audioAnalyzer.dispose": {
|
|
35902
36059
|
capName: "audio-analyzer",
|
|
35903
36060
|
capScope: "system",
|
|
@@ -41741,11 +41898,21 @@ Object.freeze({
|
|
|
41741
41898
|
form: "single",
|
|
41742
41899
|
optional: false
|
|
41743
41900
|
}],
|
|
41901
|
+
"audioAnalyzer.attachDevice": [{
|
|
41902
|
+
name: "deviceId",
|
|
41903
|
+
form: "single",
|
|
41904
|
+
optional: false
|
|
41905
|
+
}],
|
|
41744
41906
|
"audioAnalyzer.classify": [{
|
|
41745
41907
|
name: "deviceId",
|
|
41746
41908
|
form: "single",
|
|
41747
41909
|
optional: true
|
|
41748
41910
|
}],
|
|
41911
|
+
"audioAnalyzer.detachDevice": [{
|
|
41912
|
+
name: "deviceId",
|
|
41913
|
+
form: "single",
|
|
41914
|
+
optional: false
|
|
41915
|
+
}],
|
|
41749
41916
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41750
41917
|
name: "deviceId",
|
|
41751
41918
|
form: "single",
|
|
@@ -43597,6 +43764,52 @@ Object.freeze({
|
|
|
43597
43764
|
"network-access": "ingress",
|
|
43598
43765
|
"smtp-provider": "email"
|
|
43599
43766
|
});
|
|
43767
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43768
|
+
PCMU: 20 * Math.log10(4),
|
|
43769
|
+
PCMA: 20 * Math.log10(8)
|
|
43770
|
+
};
|
|
43771
|
+
/**
|
|
43772
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43773
|
+
* same intent on the ITU-T scale (D460).
|
|
43774
|
+
*
|
|
43775
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43776
|
+
*
|
|
43777
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43778
|
+
* them converts:
|
|
43779
|
+
*
|
|
43780
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43781
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43782
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43783
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43784
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43785
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43786
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43787
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43788
|
+
* louder. That is what this function is for.
|
|
43789
|
+
*
|
|
43790
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43791
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43792
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43793
|
+
* mandatory.
|
|
43794
|
+
*
|
|
43795
|
+
* ## Why a function and not a typed-in number
|
|
43796
|
+
*
|
|
43797
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43798
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43799
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43800
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43801
|
+
* having to reverse-engineer the sum.
|
|
43802
|
+
*
|
|
43803
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43804
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43805
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43806
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43807
|
+
* an extra place to argue with (D459).
|
|
43808
|
+
*/
|
|
43809
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43810
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43811
|
+
}
|
|
43812
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43600
43813
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43601
43814
|
var NC_AUDIO_DEFAULTS = {
|
|
43602
43815
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-rademacher",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.95",
|
|
4
4
|
"description": "Rademacher HomePilot device-provider addon for CamStack — wraps the @apocaliss92/noderademacher local-hub client (roller shutters over the cover cap)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|