In this section you will learn how to get information about detected audio devices or interfaces. Results might differ on different platforms as not everything is available/detectable on each platform:
On Linux, audio devices are read from the PCI bus. If no PCI audio device is found - e.g. on ARM boards like the Raspberry Pi, which have no PCI bus - the sound cards are read from ALSA (/proc/asound) instead.
For function reference and examples we assume, that we imported systeminformation as follows:
const si = require('systeminformation');
Detected Audio Devices
All functions in this section return a promise or can be called with a callback function (parameter cb in the function reference)
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
|---|---|---|---|---|---|---|---|
| si.audio(cb) | [ { ...}] | X | X | X | X | audio informatiom | |
| [0].id | X | X | X | X | internal ID | ||
| [0].name | X | X | X | X | audio name | ||
| [0].manufacturer | X | X | X | X | manufacturer | ||
| [0].revision | X | X | revision | ||||
| [0].driver | X | X | driver | ||||
| [0].default | X | X | is default input or output device | ||||
| [0].channel | X | X | X | X | channel e.g. Build-In, HDMI, USB, ... | ||
| [0].type | X | X | X | X | type e.g. Speaker | ||
| [0].in | X | X | X | is input channel (Linux: ALSA devices only) |
|||
| [0].out | X | X | X | is output channel (Linux: ALSA devices only) |
|||
| [0].status | X | X | X | status | |||
default, in and out on WindowsWin32_SoundDevice knows neither an "is default" flag nor the direction of a device. Windows keeps both in the MMDevices registry: one key per audio endpoint below Render (playback) and Capture (recording). An adapter with an active playback endpoint is reported as out, one with an active recording endpoint as in, and per direction the endpoint that became default last is the current default. When nothing distinguishes the candidates for a direction, no device is marked for it - devices serving that direction keep default at null rather than being declared "not the default". Because audio() lists audio adapters and not endpoints, these flags describe the adapter an endpoint belongs to: an adapter serving several endpoints (e.g. speakers and headphones on the same chip) is marked as soon as one of them applies. Adapters without any active endpoint keep in / out at null rather than claiming they are neither. The registry layout is not a documented API and can differ between Windows versions; when it cannot be read, default, in and out stay null. channel is derived from the PNP device id of the adapter (USB, Bluetooth, Onboard for HD Audio, PCIe) - HDMI and DisplayPort are recognised by the device name, because those endpoints sit on an HD Audio or PCI bus like any other. Example
[
{
id: 0,
name: 'MacBook Microphone',
manufacturer: 'Apple Inc.',
revision: null,
driver: null,
default: true,
channel: 'Built-In',
type: 'Microphone',
in: true,
out: false,
status: 'online'
},
{
id: 1,
name: 'MacBook Speaker',
manufacturer: 'Apple Inc.',
revision: null,
driver: null,
default: true,
channel: 'Built-In',
type: 'Speaker',
in: false,
out: true,
status: 'online'
}
]
|
|||||||