npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

truehear-audio-library-node

v1.0.0

Published

Native Node.js audio device listing and default-device switching library.

Readme

truehear-audio-library-node

Native Node.js audio library for listing audio devices and setting default audio devices.

Author: @truehear team

Installation

Install the package with npm:

npm install truehear-audio-library-node

Platform support

Currently supported platform:

Windows

This package uses a native Node.js addon to access system audio devices.

Basic usage

import { listDevices } from 'truehear-audio-library-node';

const devices = listDevices('playback');

console.log(devices);

List playback devices

Playback devices are output devices such as speakers, headphones, HDMI output, or monitor audio.

import { listDevices } from 'truehear-audio-library-node';

const playbackDevices = listDevices('playback');

console.log(playbackDevices);

Example output:

[
  {
    default: true,
    defaultCommunication: false,
    type: 'playback',
    name: 'Speakers (Realtek(R) Audio)',
    id: '{0.0.0.00000000}.{37439da3-a6eb-4740-8405-6cfbae03dd57}'
  }
]

List recording devices

Recording devices are input devices such as microphones, headset microphones, or USB audio input devices.

import { listDevices } from 'truehear-audio-library-node';

const recordingDevices = listDevices('recording');

console.log(recordingDevices);

Set the default playback device

Use the device id returned from listDevices.

import {
  listDevices,
  setDefaultDevice,
} from 'truehear-audio-library-node';

const devices = listDevices('playback');

const targetDevice = devices[0];

setDefaultDevice('playback', targetDevice.id);

Set the default recording device

import {
  listDevices,
  setDefaultDevice,
} from 'truehear-audio-library-node';

const devices = listDevices('recording');

const targetDevice = devices[0];

setDefaultDevice('recording', targetDevice.id);

Set the default communication device

Communication devices are used by calling and meeting applications.

import {
  listDevices,
  setDefaultCommunicationDevice,
} from 'truehear-audio-library-node';

const devices = listDevices('playback');

const targetDevice = devices[0];

setDefaultCommunicationDevice('playback', targetDevice.id);

API

listDevices(type)

Lists audio devices.

listDevices(type: AudioDeviceType): AudioDeviceInfo[]

Example:

const playbackDevices = listDevices('playback');
const recordingDevices = listDevices('recording');

setDefaultDevice(type, deviceId)

Sets the normal default audio device.

setDefaultDevice(type: AudioDeviceType, deviceId: string): void

Example:

setDefaultDevice('playback', deviceId);

setDefaultCommunicationDevice(type, deviceId)

Sets the default communication audio device.

setDefaultCommunicationDevice(
  type: AudioDeviceType,
  deviceId: string
): void

Example:

setDefaultCommunicationDevice('playback', deviceId);

Types

AudioDeviceType

type AudioDeviceType = 'playback' | 'recording';

AudioDeviceInfo

type AudioDeviceInfo = {
  default: boolean;
  defaultCommunication: boolean;
  type: AudioDeviceType;
  name: string;
  id: string;
};

Device ID

The id field is the native operating system device identifier.

Use this value when calling:

setDefaultDevice(type, deviceId);
setDefaultCommunicationDevice(type, deviceId);

Error handling

Invalid arguments throw TypeError.

Native audio failures throw Error.

import { listDevices } from 'truehear-audio-library-node';

try {
  const devices = listDevices('playback');
  console.log(devices);
} catch (error) {
  console.error(error);
}

License

ISC