{"id":21033134,"url":"https://github.com/josephuspaye/win-audio-outputs","last_synced_at":"2026-04-17T05:02:56.019Z","repository":{"id":57122146,"uuid":"322539701","full_name":"JosephusPaye/win-audio-outputs","owner":"JosephusPaye","description":"List and control system audio outputs from Node.js on Windows","archived":false,"fork":false,"pushed_at":"2020-12-18T09:01:28.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-21T00:03:02.979Z","etag":null,"topics":["audio","createweekly","nodejs","windows"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JosephusPaye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-18T08:49:45.000Z","updated_at":"2024-10-12T01:14:19.000Z","dependencies_parsed_at":"2022-08-24T14:59:23.855Z","dependency_job_id":null,"html_url":"https://github.com/JosephusPaye/win-audio-outputs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fwin-audio-outputs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fwin-audio-outputs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fwin-audio-outputs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fwin-audio-outputs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JosephusPaye","download_url":"https://codeload.github.com/JosephusPaye/win-audio-outputs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475358,"owners_count":20296712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","createweekly","nodejs","windows"],"created_at":"2024-11-19T12:51:58.832Z","updated_at":"2026-04-17T05:02:56.013Z","avatar_url":"https://github.com/JosephusPaye.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# win-audio-outputs\n\n\u003e List and system control audio outputs from Node.js on Windows\n\nWraps the excellent [SoundVolumeView](https://www.nirsoft.net/utils/sound_volume_view.html) for use in Node.js.\n\nThis project is part of [#CreateWeekly](https://twitter.com/JosephusPaye/status/1214853295023411200), my attempt to create something new publicly every week in 2020.\n\n## Installation\n\n```sh\nnpm install -g @josephuspaye/win-audio-outputs\n```\n\n## Examples\n\n### List audio outputs\n\nThe following program prints a list of currently active audio outputs in JSON format:\n\n```js\nimport { listOutputs } from '@josephuspaye/win-audio-outputs';\n\nasync function main() {\n  const outputs = await listOutputs();\n  console.log(JSON.stringify(outputs, null, '  '));\n}\n\nmain();\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eView sample output\u003c/summary\u003e\n\n```json\n[\n  {\n    \"id\": \"{0.0.0.00000000}.{456f665c-5c37-4a04-b894-9ea4a1717f76}\",\n    \"name\": \"LG Ultra HD\",\n    \"deviceName\": \"NVIDIA High Definition Audio\",\n    \"isDefaultForMultimedia\": false,\n    \"isDefaultForCommunications\": false,\n    \"isMuted\": false,\n    \"volume\": 60\n  },\n  {\n    \"id\": \"{0.0.0.00000000}.{938a0889-557f-4ba3-ae3e-2d6837decbe4}\",\n    \"name\": \"Realtek HD Audio 2nd output\",\n    \"deviceName\": \"Realtek(R) Audio\",\n    \"isDefaultForMultimedia\": true,\n    \"isDefaultForCommunications\": true,\n    \"isMuted\": false,\n    \"volume\": 20.5\n  }\n]\n```\n\n\u003c/details\u003e\n\n### Set the volume of an output\n\nThe following program sets the volume of the default multimedia output to 50%:\n\n```js\nimport { listOutputs, setVolume } from '@josephuspaye/win-audio-outputs';\n\nasync function main() {\n  const outputs = await listOutputs();\n  const multimediaDefault = outputs.find(\n    (output) =\u003e output.isDefaultForMultimedia\n  );\n\n  if (multimediaDefault) {\n    await setVolume(multimediaDefault, 50);\n  } else {\n    console.log('No default multimedia output found');\n  }\n}\n\nmain();\n```\n\n### Mute or unmute an output\n\nThe following program mutes or unmutes the default communications output:\n\n```js\nimport { listOutputs, mute, unmute } from '@josephuspaye/win-audio-outputs';\n\nasync function main() {\n  const outputs = await listOutputs();\n  const multimediaDefault = outputs.find(\n    (output) =\u003e output.isDefaultForCommunications\n  );\n\n  if (multimediaDefault) {\n    if (multimediaDefault.isMuted) {\n      await unmute(multimediaDefault);\n    } else {\n      await mute(multimediaDefault);\n    }\n  } else {\n    console.log('No default communications output found');\n  }\n}\n\nmain();\n```\n\n### Change default output\n\nThe following program changes the default multimedia output to the first non-default one:\n\n```js\nimport { listOutputs, setAsDefault } from '@josephuspaye/win-audio-outputs';\n\nasync function main() {\n  const outputs = await listOutputs();\n  const firstNonDefault = outputs.find(\n    (output) =\u003e output.isDefaultForMultimedia === false\n  );\n\n  if (firstNonDefault) {\n    await setAsDefault(firstNonDefault);\n  } else {\n    console.log('No non-default multimedia output found');\n  }\n}\n\nmain();\n```\n\n## API\n\n```ts\ninterface AudioOutput {\n  /**\n   * The ID of the output, used for subsequent calls that control the output\n   */\n  id: string;\n\n  /**\n   * The name of the output\n   */\n  name: string;\n\n  /**\n   * The name of the output device\n   */\n  deviceName: string;\n\n  /**\n   * Whether this output is the default for multimedia\n   */\n  isDefaultForMultimedia: boolean;\n\n  /**\n   * Whether this output is the default for communications\n   */\n  isDefaultForCommunications: boolean;\n\n  /**\n   * Whether this output is muted\n   */\n  isMuted: boolean;\n\n  /**\n   * The current volume of the output, in the range [0, 100]\n   */\n  volume: number;\n}\n\n/**\n * Get a list of currently active (connected and non-disabled) audio outputs on the system.\n */\nfunction getOutputs(): Promise\u003cAudioOutput[]\u003e;\n\n/**\n * Set the volume of the given output.\n *\n * @param output The output or id of the output\n * @param volume The volume to set, in the range [0, 100]\n * @throws       Throws when output id or volume is invalid\n */\nfunction setVolume(output: AudioOutput | string, volume: number): Promise\u003cvoid\u003e;\n\n/**\n * Mute the given output.\n *\n * @param output The output or id of the output\n * @throws       Throws when output id is invalid\n */\nfunction mute(output: AudioOutput | string): Promise\u003cvoid\u003e;\n\n/**\n * Unmute the given output.\n *\n * @param output The output or id of the output\n * @throws       Throws when output id is invalid\n */\nfunction unmute(output: AudioOutput | string): Promise\u003cvoid\u003e;\n\n/**\n * Set the give output as the default output of the given type.\n *\n * @param output The output or id of the output\n * @param type   The type of default to set: 'multimedia', 'commcommunications', or 'all'\n * @throws       Throws when output id or default type is invalid\n */\nfunction setAsDefault(\n  output: AudioOutput | string,\n  type?: 'all' | 'multimedia' | 'communications'\n): Promise\u003cvoid\u003e;\n```\n\n## Licence\n\n[MIT](LICENCE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosephuspaye%2Fwin-audio-outputs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosephuspaye%2Fwin-audio-outputs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosephuspaye%2Fwin-audio-outputs/lists"}