Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api for getting default devices #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rawatnaresh
Copy link

@rawatnaresh rawatnaresh commented Jan 2, 2021

I can initialize the default device by passing deviceId: -1 but there is no way to know which of the devices are defaults.

Use case:

  • To initialize the app UI with default devices.
  • if the channelCount of some of the defaultDevice is 1, then the app will crash because by default channelCount is being set as 2

image

but my External Microphone has channel count 1

[
  {
    id: 0,
    name: 'External Microphone',
    maxInputChannels: 1,
    maxOutputChannels: 0,
    defaultSampleRate: 48000,
    defaultLowInputLatency: 0,
    defaultLowOutputLatency: 0,
    defaultHighInputLatency: 0,
    defaultHighOutputLatency: 0,
    hostAPIName: 'Core Audio'
  },
 ...

with this, I can know the channelCount before initializing the instance

Eg:

var portAudio = require('naudiodon');

console.log(portAudio.getDefaultDevices());

An example of the output is:

{
  defaultInputDevice: {
    id: 0,
    name: 'Built-in Microphone',
    maxInputChannels: 2,
    maxOutputChannels: 0,
    defaultSampleRate: 44100,
    defaultLowInputLatency: 0,
    defaultLowOutputLatency: 0,
    defaultHighInputLatency: 0,
    defaultHighOutputLatency: 0,
    hostAPIName: 'Core Audio'
  },
  defaultOutputDevice: {
    id: 1,
    name: 'Built-in Output',
    maxInputChannels: 0,
    maxOutputChannels: 2,
    defaultSampleRate: 44100,
    defaultLowInputLatency: 0,
    defaultLowOutputLatency: 0,
    defaultHighInputLatency: 0,
    defaultHighOutputLatency: 0,
    hostAPIName: 'Core Audio'
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant