Streampunk / naudiodon

Node.js stream bindings for PortAudio
Apache License 2.0
295 stars 82 forks source link

Api for getting default devices #57

Open rawatnaresh opened 3 years ago

rawatnaresh commented 3 years ago

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:

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'
  }
}