Skip to content

@camera.ui/sdk / sensor / AudioDetectorSensor

Abstract Class: AudioDetectorSensor<TStorage>

Defined in: sensor/audio.ts:214

Audio detector that receives audio frames from the backend pipeline. Extend this class and implement detectAudio to classify audio events. The backend resamples and buffers audio to match modelSpec before each call.

Extends

Type Parameters

TStorage

TStorage extends object = Record<string, any>

Constructors

Constructor

new AudioDetectorSensor<TStorage>(name?): AudioDetectorSensor<TStorage>

Defined in: sensor/audio.ts:82

Parameters

name?

string = 'Audio Sensor'

Returns

AudioDetectorSensor<TStorage>

Inherited from

AudioSensor.constructor

Properties

_requiresFrames

_requiresFrames: boolean = true

Defined in: sensor/audio.ts:215

Overrides

AudioSensor._requiresFrames


category

readonly category: Sensor = SensorCategory.Sensor

Defined in: sensor/audio.ts:78

Inherited from

AudioSensor.category


id

readonly id: string

Defined in: sensor/base.ts:190

Inherited from

Sensor.id


modelSpec

abstract readonly modelSpec: AudioModelSpec

Defined in: sensor/audio.ts:218

Declares the expected audio input format. The backend resamples to match.


name

readonly name: string

Defined in: sensor/base.ts:189

Inherited from

Sensor.name


onAssignmentChanged

readonly onAssignmentChanged: Observable<boolean>

Defined in: sensor/base.ts:209

Inherited from

ClipDetectorSensor.onAssignmentChanged


onCapabilitiesChanged

readonly onCapabilitiesChanged: Observable<string[]>

Defined in: sensor/base.ts:200

Observable for capability changes. Emits the full capabilities array when capabilities change.

Inherited from

AudioSensor.onCapabilitiesChanged


onPropertyChanged

readonly onPropertyChanged: Observable<PropertyChangeOf<AudioSensorProperties>>

Defined in: sensor/base.ts:198

Observable for property changes. Emits { property, value, timestamp } when any property changes.

Inherited from

AudioSensor.onPropertyChanged


type

readonly type: Audio = SensorType.Audio

Defined in: sensor/audio.ts:77

Inherited from

AudioSensor.type

Accessors

cameraId

Get Signature

get cameraId(): string

Defined in: sensor/base.ts:257

Camera ID this sensor belongs to. Throws if sensor not yet added to a camera.

Returns

string

Inherited from

ClipDetectorSensor.cameraId


capabilities

Get Signature

get capabilities(): TCapability[]

Defined in: sensor/base.ts:277

Optional feature flags advertised by this sensor (e.g., PTZ pan/tilt/zoom)

Returns

TCapability[]

Set Signature

set capabilities(value): void

Defined in: sensor/base.ts:282

Set capabilities and notify the backend. Automatically deduplicates.

Parameters
value

TCapability[]

Returns

void

Inherited from

AudioSensor.capabilities


decibels

Get Signature

get decibels(): number

Defined in: sensor/audio.ts:103

Current audio level in decibels.

Returns

number

Inherited from

AudioSensor.decibels


detected

Get Signature

get detected(): boolean

Defined in: sensor/audio.ts:93

Whether an audio event is currently detected.

Returns

boolean

Inherited from

AudioSensor.detected


detections

Get Signature

get detections(): Detection[]

Defined in: sensor/audio.ts:98

Current detection list.

Returns

Detection[]

Inherited from

AudioSensor.detections


displayName

Get Signature

get displayName(): string

Defined in: sensor/base.ts:233

Returns

string

Inherited from

Sensor.displayName


isAssigned

Get Signature

get isAssigned(): boolean

Defined in: sensor/base.ts:252

Whether this sensor has been assigned to a camera in the backend

Returns

boolean

Inherited from

ClipDetectorSensor.isAssigned


pluginId

Get Signature

get pluginId(): string | undefined

Defined in: sensor/base.ts:264

Returns

string | undefined

Inherited from

Sensor.pluginId


props

Get Signature

get protected props(): Readonly<TProperties>

Defined in: sensor/base.ts:295

Read-only access to the internal property store. Subclasses use this to read current state when implementing semantic methods (e.g., if (this.blocked) return).

Returns

Readonly<TProperties>

Inherited from

AudioSensor.props


storage

Get Signature

get storage(): DeviceStorage<TStorage>

Defined in: sensor/base.ts:269

Per-sensor persistent storage. Throws if sensor not yet added to a camera.

Returns

DeviceStorage<TStorage>

Inherited from

AudioSensor.storage


storageSchema

Get Signature

get storageSchema(): JsonSchema[]

Defined in: sensor/base.ts:216

Override to provide a JSON schema for per-sensor storage settings UI

Returns

JsonSchema[]

Inherited from

ClipDetectorSensor.storageSchema

Methods

clearDetections()

clearDetections(): void

Defined in: sensor/audio.ts:144

Explicitly clear audio detection state (detected = false, detections = []).

Returns

void

Example

ts
sensor.clearDetections();

Inherited from

AudioSensor.clearDetections


detectAudio()

abstract detectAudio(audio): Promise<AudioResult>

Defined in: sensor/audio.ts:221

Analyze a single audio frame for events. Called by the backend at the configured cadence.

Parameters

audio

AudioFrameData

Returns

Promise<AudioResult>


getValue()

Call Signature

getValue<K>(property): AudioSensorProperties[K] | undefined

Defined in: sensor/base.ts:303

Get the current value of a sensor property. Type-safe via the generic overload — call with a property enum value to get a properly typed result.

Type Parameters
K

K extends keyof AudioSensorProperties

Parameters
property

K

Returns

AudioSensorProperties[K] | undefined

Inherited from

AudioSensor.getValue

Call Signature

getValue(property): unknown

Defined in: sensor/base.ts:304

Get the current value of a sensor property. Type-safe via the generic overload — call with a property enum value to get a properly typed result.

Parameters
property

string

Returns

unknown

Inherited from

AudioSensor.getValue


getValues()

getValues(): Readonly<TProperties>

Defined in: sensor/base.ts:320

Get a read-only snapshot of all property values.

Returns

Readonly<TProperties>

Frozen view of every property currently held by the sensor.

Example

ts
const snapshot = sensor.getValues();
console.log(snapshot);

Inherited from

AudioSensor.getValues


hasCapability()

hasCapability(capability): boolean

Defined in: sensor/base.ts:423

Parameters

capability

string

Returns

boolean

Inherited from

AudioSensor.hasCapability


onAssigned()

protected onAssigned(): void | Promise<void>

Defined in: sensor/base.ts:473

Lifecycle hook: the sensor just became assigned to a camera. Override to start background work that should only run while this sensor is live — polling loops, event subscriptions, timers, external connections.

Called AFTER cameraId, storage, and RPC channels are wired up, so the override can safely access this.cameraId, this.storage, and publish properties via the semantic helper methods.

Errors thrown here are caught and logged — they will NOT break assignment bookkeeping. If your work can fail, handle it inside the override.

Paired 1:1 with onDeassigned — for every onAssigned call there is exactly one matching onDeassigned later (on deassignment or cleanup).

Default: no-op. Most sensors don't need lifecycle hooks.

Returns

void | Promise<void>

Example

ts
protected override async onAssigned(): Promise<void> {
  this._timer = setInterval(() => this.poll(), 5_000);
}

Inherited from

AudioSensor.onAssigned


onDeassigned()

protected onDeassigned(): void | Promise<void>

Defined in: sensor/base.ts:493

Lifecycle hook: the sensor is being deassigned. Override to tear down whatever was started in onAssigned — clear timers, close subscriptions, release external resources.

Always called exactly once for each prior onAssigned. Also called from _cleanup if the sensor is being removed while still assigned, so you can rely on this as the single teardown point.

Default: no-op.

Returns

void | Promise<void>

Example

ts
protected override onDeassigned(): void {
  if (this._timer) clearInterval(this._timer);
}

Inherited from

AudioSensor.onDeassigned


reportDetections()

reportDetections(detected, detections?): void

Defined in: sensor/audio.ts:128

Report detected audio events.

  • reportDetections(true) — audio detected without specifics. The SDK synthesizes a single full-frame 'audio' detection.
  • reportDetections(true, [...]) — audio detected with explicit detections.
  • reportDetections(false) — clear.

Parameters

detected

boolean

Whether an audio event is currently detected.

detections?

Detection[]

Optional explicit detections produced for this event.

Returns

void

Example

ts
import type { Detection } from '@camera.ui/sdk';
sensor.reportDetections(true, [
  { label: 'glass_break', confidence: 0.91, box: { x: 0, y: 0, width: 1, height: 1 } } satisfies Detection,
]);
sensor.reportDetections(false);

Inherited from

AudioSensor.reportDetections


setDecibels()

setDecibels(value): void

Defined in: sensor/audio.ts:158

Update the current audio level (in decibels).

Parameters

value

number

Audio level in decibels.

Returns

void

Example

ts
sensor.setDecibels(72);

Inherited from

AudioSensor.setDecibels


setDisplayName()

setDisplayName(value): void

Defined in: sensor/base.ts:247

Set the display name (the only mutable identifier on a sensor).

Parameters

value

string

Human-readable label shown in the UI.

Returns

void

Example

ts
sensor.setDisplayName('Front Door Motion');

Inherited from

AudioSensor.setDisplayName