-
Notifications
You must be signed in to change notification settings - Fork 3
Server Info
Jan Janak edited this page Jan 27, 2021
·
9 revisions
import { PulseAudio } from '@janakj/pulseaudio.js';
const pa = new PulseAudio("Test client for @janakj/pulseaudio.js");
await pa.connect();
Use the method getServerInfo
to obtain information about the PulseAudio servers:
console.log(await pa.getServerInfo());
{
name: 'pulseaudio',
version: '13.99.2',
username: 'janakj',
hostname: 'ubuntu',
sampleSpec: { format: 3, channels: 2, rate: 44100 },
defaultSink: 'alsa_output.pci-0000_00_05.0.analog-stereo',
defaultSource: 'alsa_input.pci-0000_00_05.0.analog-stereo',
cookie: 3762914620,
defaultChannelMap: [ 1, 2 ]
}
The method getAllSources
can be used to obtain an array of all inputs (sources) currently defined on the PulseAudio server:
console.log(await pa.getAllSources());
[
{
index: 0,
name: 'alsa_output.pci-0000_00_05.0.analog-stereo.monitor',
description: 'Monitor of Built-in Audio Analog Stereo',
sampleSpec: { format: 3, channels: 2, rate: 48000 },
channelMap: [ 1, 2 ],
module: 7,
volume: { current: [Array], base: 65536, steps: 65537 },
mute: false,
monitor: { index: 0, name: 'alsa_output.pci-0000_00_05.0.analog-stereo' },
latency: { current: 5476377146921058304n, requested: 5476377146921058304n },
driver: 'module-alsa-card.c',
flags: 34,
properties: {
device: [Object],
alsa: [Object],
sysfs: [Object],
'module-udev-detect': [Object]
},
state: 2,
card: 0,
ports: [],
activePort: null,
formats: [ [Object] ]
},
{
index: 1,
name: 'alsa_input.pci-0000_00_05.0.analog-stereo',
description: 'Built-in Audio Analog Stereo',
sampleSpec: { format: 3, channels: 2, rate: 44100 },
channelMap: [ 1, 2 ],
module: 7,
volume: { current: [Array], base: 27636, steps: 65537 },
mute: false,
monitor: { index: 4294967295, name: null },
latency: { current: 5476377146921058304n, requested: 5476377146921058304n },
driver: 'module-alsa-card.c',
flags: 55,
properties: {
alsa: [Object],
device: [Object],
sysfs: [Object],
'module-udev-detect': [Object]
},
state: 2,
card: 0,
ports: [ [Object], [Object], [Object], [Object], [Object] ],
activePort: 'analog-input-mic;input-microphone-1',
formats: [ [Object] ]
}
]
Use the method getSourceInfo
to obtain information about a specific source. You can specify the source either by its name (string) or by its index (number). If you omit the argument, the method will return information about the default source.
console.log(await pa.getSourceInfo(1));
{
index: 1,
name: 'alsa_input.pci-0000_00_05.0.analog-stereo',
description: 'Built-in Audio Analog Stereo',
sampleSpec: { format: 3, channels: 2, rate: 44100 },
channelMap: [ 1, 2 ],
module: 7,
volume: { current: [ 43800, 43800 ], base: 27636, steps: 65537 },
mute: false,
monitor: { index: 4294967295, name: null },
latency: { current: 5476377146921058304n, requested: 5476377146921058304n },
driver: 'module-alsa-card.c',
flags: 55,
properties: {
alsa: {
resolution_bits: '16',
class: 'generic',
subclass: 'generic-mix',
name: 'Intel 82801AA-ICH',
id: 'Intel ICH',
subdevice: '0',
subdevice_name: 'subdevice #0',
device: '0',
card: '0',
card_name: 'Intel 82801AA-ICH',
long_card_name: 'Intel 82801AA-ICH with AD1980 at irq 21',
driver_name: 'snd_intel8x0'
},
device: {
api: 'alsa',
class: 'sound',
bus_path: 'pci-0000:00:05.0',
bus: 'pci',
vendor: [Object],
product: [Object],
form_factor: 'internal',
string: 'front:0',
buffering: [Object],
access_mode: 'mmap',
profile: [Object],
description: 'Built-in Audio Analog Stereo',
icon_name: 'audio-card-pci'
},
sysfs: { path: '/devices/pci0000:00/0000:00:05.0/sound/card0' },
'module-udev-detect': { discovered: '1' }
},
state: 2,
card: 0,
ports: [
{
name: 'analog-input-mic;input-microphone-1',
description: 'Microphone / Microphone 1',
priority: 8720,
available: 0
},
{
name: 'analog-input-mic;input-microphone-2',
description: 'Microphone / Microphone 2',
priority: 8719,
available: 0
},
{
name: 'analog-input-linein',
description: 'Line In',
priority: 8100,
available: 0
},
{
name: 'analog-input-aux',
description: 'Analog Input',
priority: 8000,
available: 0
},
{
name: 'analog-input-video',
description: 'Video',
priority: 7000,
available: 0
}
],
activePort: 'analog-input-mic;input-microphone-1',
formats: [ { encoding: 1, properties: {} } ]
}
The method lookupSource
can be used to obtain the unique index (number) of the given source, for example:
console.log(await pa.lookupSource('alsa_input.pci-0000_00_05.0.analog-stereo'));
1
Similarly, use the method getAllSinks()
to obtain an array of all outputs (sinks) defined on the PulseAudio server:
console.log(await pa.getAllSinks());
[
{
index: 0,
name: 'alsa_output.pci-0000_00_05.0.analog-stereo',
description: 'Built-in Audio Analog Stereo',
sampleSpec: { format: 3, channels: 2, rate: 48000 },
channelMap: [ 1, 2 ],
module: 7,
volume: { current: [Array], base: 65536, steps: 65537 },
mute: false,
monitor: {
index: 0,
name: 'alsa_output.pci-0000_00_05.0.analog-stereo.monitor'
},
latency: { current: 5476377146921058304n, requested: 5476377146921058304n },
driver: 'module-alsa-card.c',
flags: 55,
properties: {
alsa: [Object],
device: [Object],
sysfs: [Object],
'module-udev-detect': [Object]
},
state: 2,
card: 0,
ports: [ [Object], [Object] ],
activePort: 'analog-output;output-amplifier-on',
formats: [ [Object] ]
}
]