Skip to content

Interface: SystemAudio ​

Defined in: types/desktop-engine.d.ts:4057

What other apps play on the Mac (music, videos…; never anything DesktopEngine plays: this content, other content, a video wallpaper with sound), as an analysis: how loud it is and how it spreads from low to high, never the sound itself. For music visualizers. Needs the "system-audio" permission (and "apiVersion": 6), which content can't have together with "network". DesktopEngine.systemAudio is null without it (not declared, or the user denied it in the app).

The app listens only while another app plays audio and the content reads the values or listens to activechange. It stops 2 seconds after the last read once nothing listens to activechange, and whenever the app pauses the content. Meanwhile macOS shows its recording indicator in the menu bar, and the first time macOS asks the user to allow DesktopEngine to record system audio. A user who doesn't allow that, or a Mac before macOS 14.2, gets silence: every band and level 0, active false.

Read it at your own pace, e.g. in requestAnimationFrame: the values change up to 30 times a second, so every other frame on a 60 Hz display. They're smoothed: they rise fast and fall from 1 to 0 in about half a second.

Extends ​

Properties ​

active ​

ts
readonly active: boolean;

Defined in: types/desktop-engine.d.ts:4064

Whether something audible plays (louder than -60 dB in the last second)


bandCount ​

ts
bandCount: number;

Defined in: types/desktop-engine.d.ts:4073

How many bands getBands fills: 1...maxBandCount, default 32. Numbers out of range are clamped (Infinity to maxBandCount, -Infinity to 1), fractions dropped; NaN and anything but a number are ignored. The bands always cover 30 Hz...16 kHz, spaced evenly in octaves. Fewer bands are merged from the 32, so reading with several counts tells nothing finer


level ​

ts
readonly level: number;

Defined in: types/desktop-engine.d.ts:4066

How loud it plays overall, 0...1 (-60 dB...0 dB of mean power, relative to full scale), in steps of 1/255


maxBandCount ​

ts
readonly maxBandCount: number;

Defined in: types/desktop-engine.d.ts:4075

The most bands the content may ask for: 32


onactivechange ​

ts
onactivechange: 
  | EventHandler<SystemAudio, void>
  | null
  | undefined;

Defined in: types/desktop-engine.d.ts:4084

activechange callback


supported ​

ts
readonly supported: boolean;

Defined in: types/desktop-engine.d.ts:4062

Whether the app can follow what the Mac plays on this version of macOS: false before macOS 14.2, where every value stays 0

Methods ​

addEventListener() ​

ts
addEventListener<K>(type, listener): void;

Defined in: types/desktop-engine.d.ts:143

Adds an event listener; type may be given with or without the on prefix

Type Parameters ​

Type Parameter
K extends "activechange"

Parameters ​

ParameterType
typeK | `on${K}`
listenerEventHandler<SystemAudio, SystemAudioEventMap[K]>

Returns ​

void

Inherited from ​

EventedObject.addEventListener


destroy() ​

ts
destroy(): void;

Defined in: types/desktop-engine.d.ts:147

Clears all event listeners and on callbacks so the object can be garbage-collected; components also process their children recursively

Returns ​

void

Inherited from ​

EventedObject.destroy


getBands() ​

ts
getBands(array): void;

Defined in: types/desktop-engine.d.ts:4082

Fills array's first bandCount items (fewer when it's shorter) with the latest level of each band, low to high: 0...1 for a band's power per octave from -80 dB to -12 dB (relative to a full-scale sine, tilted +3 dB per octave around 1 kHz so that music comes out about flat), in steps of 1/255. Throws a TypeError when array isn't a Float32Array

Parameters ​

ParameterType
arrayFloat32Array

Returns ​

void


offactivechange() ​

ts
offactivechange(): void;

Defined in: types/desktop-engine.d.ts:4086

Removes the onactivechange callback

Returns ​

void


removeEventListener() ​

ts
removeEventListener<K>(type, listener): void;

Defined in: types/desktop-engine.d.ts:145

Removes the given event listener

Type Parameters ​

Type Parameter
K extends "activechange"

Parameters ​

ParameterType
typeK | `on${K}`
listenerEventHandler<SystemAudio, SystemAudioEventMap[K]>

Returns ​

void

Inherited from ​

EventedObject.removeEventListener

The SDK is released under the Apache License 2.0