Giter Site home page Giter Site logo

streampunk / naudiodon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joeferner/node-portaudio

294.0 294.0 80.0 1.54 MB

Node.js stream bindings for PortAudio

License: Apache License 2.0

Python 2.85% JavaScript 8.08% C++ 46.91% C 42.12% Batchfile 0.05%

naudiodon's People

Contributors

eol-account avatar joeferner avatar julusian avatar lucas-alencar avatar pabiagioli avatar rpahle avatar scriptorian avatar simonrankine avatar sparkpunkd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

naudiodon's Issues

Problem installing on Windows 10

When installing naudiodon, node-gyp throws errors and warnings and it exists. This is the output of the terminal:

npm install naudiodon

> [email protected] install C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler
> node-gyp rebuild


C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Los proyectos de esta solución se van a compilar de uno en uno. Para habilitar la compilación en paralelo, agregue el modificador "-m".
  segfault-handler.cpp
  StackWalker.cpp       
  win_delay_load_hook.cc
C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\includes\StackWalker.h(120): warning C4091: 'typedef ': se ha omitido a la izquierda de 'StackWalker::CallstackEntryTy
pe' cuando no hay ninguna variable declarada (compilando archivo de origen ..\src\StackWalker.cpp) [C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\build\segfault-han
dler.vcxproj]
C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\src\StackWalker.cpp(356): warning C4091: 'typedef ': se ha omitido a la izquierda de 'StackWalkerInternal::IMAGEHLP_MO
DULE64_V2' cuando no hay ninguna variable declarada [C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\build\segfault-handler.vcxproj]
C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\includes\StackWalker.h(120): warning C4091: 'typedef ': se ha omitido a la izquierda de 'StackWalker::CallstackEntryTy
pe' cuando no hay ninguna variable declarada (compilando archivo de origen ..\src\segfault-handler.cpp) [C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\build\segfaul
t-handler.vcxproj]
C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\src\segfault-handler.cpp(210,69): warning C4311: 'conversión de tipo': truncamiento de puntero de 'PVOID' a 'long' [C:
\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\build\segfault-handler.vcxproj]
C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\src\segfault-handler.cpp(210,69): warning C4302: 'conversión de tipo': truncamiento de 'PVOID' a 'long' [C:\Users\Usua 
rio\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\build\segfault-handler.vcxproj]
C:\\Users\\Usuario\\AppData\\Local\\node-gyp\\Cache\\12.16.3\\x64\\node.lib : fatal error LNK1127: la biblioteca está dañada [C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault- 
handler\build\segfault-handler.vcxproj]
gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN [email protected] requires a peer of [email protected] - 3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\glob-watcher\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\src\segfault-handler.cpp(210,69): warning C4302: 'conversión de tipo': truncamiento de 'PVOID' a 'long' [C:\Users\Usua 
rio\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler\build\segfault-handler.vcxproj]
C:\\Users\\Usuario\\AppData\\Local\\node-gyp\\Cache\\12.16.3\\x64\\node.lib : fatal error LNK1127: la biblioteca está dañada [C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault- 
handler\build\segfault-handler.vcxproj]
gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Usuario\Desktop\Eze\Proyectos\timekode\node_modules\segfault-handler
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN [email protected] requires a peer of [email protected] - 3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\glob-watcher\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Usuario\AppData\Roaming\npm-cache\_logs\2020-05-18T16_35_54_230Z-debug.log

Program crashes when using AudioInput

I am running the example file inputToFile.js. However, when I run node inputToFile.js, it simply outputs the following:
Input audio options: default device, sample rate 44100, channels 2, bits per sample 16, max queue 2
And exits with no indication of what happened.

Using the following command forever --spinSleepTime 1 inputToFile.js,
I get the following message:
Forever detected script exited with code: 3221225477 (0xC0000005)

Apparently this is a windows error similar to SEGFAULT.
Any one know how to fix this?

Segfault Handler dependency causes issues with Electron 8

I am using naudiodon with an electron app, and when running an Electron app, it complains that the NODE_MODULES_VERSION is mismatched. Electron has a NMV of 76. Node 0.12 is 72, and Node 0.13 is 79. This prevents naudiodon from being loaded in electron.

I fixed this locally but just commenting out the 2 segfault handler lines in index.js. Looking at Segfault handler, it hasn't been updated for a while and doesn't support the N-API system.

Not sure what the right path forward for this library is, that's your call, and I understand needing to handle segfaults, but you might need to find another library, or another solution.

Doesn't block me, but thought I would report it anyway.

Repro steps:

  1. Get the electron quick start
  2. Add naudiodon as a dependency
  3. npm install (for things to build)
  4. Do a simple getDevices call using naudiodon in the main.js.
  5. Run NPM Start
  6. You will get a NVM version mismatch error related to Segfaulthandler.

Undefined symbol: Pa_GetVersionInfo on RPi3

Environment:
[email protected]
Raspberry Pi 3b (Linux Kernel 4.14.79-v7+ armv7l)
Node v13.14.0

Naudiodon build log:

  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  AR(target) Release/obj.target/../node-addon-api/src/nothing.a
  COPY Release/nothing.a
  COPY ../build/Release/libportaudio.so.2
  CXX(target) Release/obj.target/naudiodon/src/naudiodon.o
  CXX(target) Release/obj.target/naudiodon/src/GetDevices.o
  CXX(target) Release/obj.target/naudiodon/src/GetHostAPIs.o
  CXX(target) Release/obj.target/naudiodon/src/AudioIO.o
  CXX(target) Release/obj.target/naudiodon/src/PaContext.o
../src/PaContext.cc: In function ‘int streampunk::PaCallback(const void*, void*, long unsigned int, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void*)’:
../src/PaContext.cc:30:10: warning: unused variable ‘outTimestamp’ [-Wunused-variable]
   double outTimestamp = timeInfo->outputBufferDacTime;
          ^~~~~~~~~~~~
  SOLINK_MODULE(target) Release/obj.target/naudiodon.node
  COPY Release/naudiodon.node

Audio devices:

[
  {
    id: 0,
    name: 'USB Audio Device: - (hw:1,0)',
    maxInputChannels: 1,
    maxOutputChannels: 2,
    defaultSampleRate: 44100,
    defaultLowInputLatency: 0.008684807256235827,
    defaultLowOutputLatency: 0.008684807256235827,
    defaultHighInputLatency: 0.034829931972789115,
    defaultHighOutputLatency: 0.034829931972789115,
    hostAPIName: 'ALSA'
  },
  {
    id: 1,
    name: 'default',
    maxInputChannels: 32,
    maxOutputChannels: 32,
    defaultSampleRate: 44100,
    defaultLowInputLatency: 0.008707482993197279,
    defaultLowOutputLatency: 0.008707482993197279,
    defaultHighInputLatency: 0.034829931972789115,
    defaultHighOutputLatency: 0.034829931972789115,
    hostAPIName: 'ALSA'
  }
]

Code:

  const audioOutput = portAudio.AudioIO({
    outOptions: {
      channelCount: 1,
      sampleFormat: 16,
      sampleRate: 44100,
      deviceId: 0
    },
  });
  audioOutput.on('error', console.error);
  audioOutput.on('end', () => console.log('Freeing up audio output stream'));

  audioStream.pipe(audioOutput); //audioStream is type nodeJS.Stream.Readable
  audioOutput.start();

Output:

ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM dmix
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM dmix
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
/home/pi/.nvm/versions/node/v13.14.0/bin/node: symbol lookup error: /home/pi/dev/myCoolProject/node_modules/naudiodon/build/Release/naudiodon.node: undefined symbol: Pa_GetVersionInfo

Process finished with exit code 127

Buffer underflow on Raspberry Pi

Receiving a buffer underflow error when trying to play audio on a Raspberry Pi via USB audio device.

Also, lots of distortion when playing via the headphone jack.

Suggestion from @scriptorian

There is a MaxQueue parameter in AudioOut.cc, currently set to 2. You could try upping that. Next you would need to check the pa callback size - if it is only asking for a small amount of data each time that is going to hurt on the RPi. There is a parameter in the paOpenStream call that can affect this if so.

Duplex audio issue on MacOS

Hello! I'm using MacOS Catalina, Node v12.19.0 and if I run output or input it works properly, but if I use duplex(input and output together) It crashes and log the following:

step 1step 2step 3step 4.2NAPI error in file ../src/AudioIO.cc on line 109. Error 10: An exception is pending
NAPI pending exception. Engine error code: 0
NAPI error in file ../src/naudiodon.cc on line 31. Error 9: Unknown failure
Assertion failed: (throwStatus == napi_ok), function checkStatus, file ../src/naudiodonUtil.cc, line 54.

Can anyone help me?

Update:

When I pass nothing on outOptions it emit my input sound with glitches

Ubuntu: getting a string instead of samples in data event.

My app works perfectly on my mac. When I run it on my ubuntu machine (my actual target) the 'data' event returns strings instead of samples.

I've tried it with a couple of different USB microphones. Here's an example of a message that is coming through the 'data' callback:

re/alsa/alsa.confommon:CARD=0,DEVICE=3,CTLINDEX=0,AES0=4,AES1=130,AES2=0,AES3=2m

What's causing this? I am able to record on this PC using arecord, so it appears ALSA is working in the system.

Support for ASIO?

Hey there,

Just wondering if there are plans in the project's roadmap to implement ASIO compatibility? I know that there is a fork that has implemented this successfully. I have tried and tested and it indeed works.

Otherwise, if no one is planning on doing it I'm thinking I could dive into it using the mentioned fork as a start off. Would need to check exactly what the differences are. As far as I can tell, @gschmottlach-xse has used NAN, so I guess the first thing would be to switch it over to NAPI. Then try figure out a way of getting the correct driver to start according to the ASIO host API when an ASIO driver is specified.

I particularly think ASIO support is important when wanting to stream multichannel audio that is higher than the 8 channel limitation put on by windows drivers. I have an application that is required to stream 24 channels to my interface which I can't currently do with the 8 channel limitations.

Crashing with error: "PID received SIGSEGV for address: 0x0" on reinitializing instances

Initially, I'm creating two instances one for input and another for an output with these configs

{
  channelCount: 2,
  sampleFormat: portAudio.SampleFormat16Bit,
  sampleRate: 44100,
  deviceId: -1, // user can change the device using a dropdown menu
  closeOnError: false,
  framesPerBuffer: 1024,
}

and then piping the input stream to the output and starting the stream. This works fine. Now, let's say I want to use a different deviceId for input or output. To do that:

  • first, I'm quitting both instances using instance.quit()
  • then, reinitializing the instances with different deviceId's
  • and finally, starting the stream.

when I do that I get an error saying

PID 60079 received SIGSEGV for address: 0x8
0   segfault-handler.node               0x0000000103a00fe0 _ZL16segfault_handleriP9__siginfoPv + 304
1   libsystem_platform.dylib            0x00007fff6b3565fd _sigtramp + 29
2   ???                                 0x0000700005dc8b67 0x0 + 123145400650599
3   libportaudio.dylib                  0x0000000102df0002 CloseStream + 402
4   naudiodon.node                      0x0000000102dc6358 _ZN10streampunk9PaContext4stopENS0_9eStopFlagE + 40
5   naudiodon.node                      0x0000000102dc3a66 _ZN10streampunk11quitExecuteEP10napi_env__Pv + 22
6   node                                0x000000010093fbfa worker + 394
7   libsystem_pthread.dylib             0x00007fff6b362109 _pthread_start + 148
8   libsystem_pthread.dylib             0x00007fff6b35db8b thread_start + 15
[1]    60079 segmentation fault  

I'm trying to implement this in Electron app but it can also be reproduced using the following code:

index.js

const portAudio = require('naudiodon');

let inputInstance = null;
let outputInstance = null;

/* Default configs */
const defaultAudioConfigs = {
  channelCount: 2,
  sampleFormat: portAudio.SampleFormat16Bit,
  sampleRate: 44100,
  deviceId: -1,
  closeOnError: false,
  framesPerBuffer: 1024,
};

/* To start the stream */
const startStream = () => {
  if (!inputInstance || !outputInstance) {
    throw new Error(
      'Enable "inputInstance" and "outputInstance" before starting input stream',
    );
  }
  try {
    inputInstance.pipe(outputInstance);
    outputInstance.start();
    inputInstance.start();
    console.log('stream started');
  } catch (e) {
    console.error('error while starting input stream', e);
  }
};

/* To restart stream */
const restartStream = () => {
  if (inputInstance && outputInstance) {
    outputInstance.quit();
    inputInstance.quit();
    inputInstance = null;
    outputInstance = null;
    console.log('stream stopped');
    init();
  } else {
    init();
  }
};


const createInstance = (type) => {
if(type === 'in' || type === 'out')
    return new portAudio.AudioIO({
        [`${type}Options`]: {
          ...defaultAudioConfigs,
        },
      });
throw new Error('Invalid type');
};

/* This will run when the app is initialized */
const init = () => {
    inputInstance = createInstance('in');
    outputInstance = createInstance('out');
    startStream();
};

init();

/* 
To replicate the device change behaviour. 
Imagine user is changing the device using dropdown menu. 
Currently I'm reinitializing with same deviceId but the error is same
*/
setInterval(() => {
    restartStream();
}, 3000);

package.json

{
  "name": "naudio",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "naudiodon": "^2.3.0"
  }
}
# install dependencies and then run using
node .

Node version: 12.18.4

naudiodon version: 2.3.0

Any help would be appreciated thanks. 🙏 🙇

Record sound from speakers

Cannot record sound from speakers on mac os.

var speakers = new portAudio.AudioIO({
    inOptions: {
        channelCount: 1,
        sampleFormat: portAudio.SampleFormat16Bit,
        sampleRate: 44100,
        deviceId: 1, // Use -1 or omit the deviceId to select the default device
        closeOnError: true // Close the stream if an audio error is detected, if set false then just log the error
    }
})


var ws = fs.createWriteStream('speakerz.raw');
speakers.pipe(ws);
speakers.start();

Output is:

Input audio options: device 1, sample rate 44100, channels 1, bits per sample 16, max queue 2, frames per buffer 0, close on error true
Input device name is Динамики «MacBook Pro»
/Users/alexandererygin/projects/sound_node/node_modules/naudiodon/index.js:32
  const audioIOAdon = new portAudioBindings.AudioIO(options);
                      ^

Error: Channel count exceeds maximum number of channels for device
    at new AudioIO (/Users/alexandererygin/projects/sound_node/node_modules/naudiodon/index.js:32:23)
    at Object.<anonymous> (/Users/alexandererygin/projects/sound_node/app.js:17:16)

Segfault once mainthread becomes blocked

Hey iam trying to implement the lib in an electron app. Sadly when i require the module on the main thread and then open a system dialogbox i end up getting my console spamed with segfaults

PID 19756 received SIGSEGV for address: 0xeb37a839
SymInit: Symbol-SearchPath: '.;E:\my-new;E:\my-new\node_modules\electron\dist;C:\WINDOWS;C:\WINDOWS\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'ruohki'
OS-Version: 10.0.18362 () 0x100-0x1
E:\my-new\node_modules\segfault-handler\src\StackWalker.cpp (941): StackWalker::ShowCallstack
E:\my-new\node_modules\segfault-handler\src\segfault-handler.cpp (242): segfault_handler
00007FFAED958636 (ntdll): (filename not available): RtlIsGenericTableEmpty
00007FFAED94A0D6 (ntdll): (filename not available): RtlRaiseException
00007FFAED94A043 (ntdll): (filename not available): RtlRaiseException
00007FFAEB37A839 (KERNELBASE): (filename not available): RaiseException
00007FFAC131E372 (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC12D5800 (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC12D518C (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC134CA15 (Boxcryptor.Ext): (filename not available): DllGetClassObject
00007FFAC1351402 (Boxcryptor.Ext): (filename not available): DllGetClassObject
00007FFAC12CCB83 (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC12CC948 (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC12CB59A (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC12CB07A (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC12CB008 (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC12B4CFD (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAC1323C59 (Boxcryptor.Ext): (filename not available): (function-name not available)
00007FFAECC57BD4 (KERNEL32): (filename not available): BaseThreadInitThunk
00007FFAED94CED1 (ntdll): (filename not available): RtlUserThreadStart

Audio gets cut at the end

Hello all,

I'm facing this issue where the audio gets cut (~1 sec) at the end and can't figure out why it's happening. I hope someone can help me out here please!

Here's the code snippet (it's really just the sample code):

var ao = new portAudio.AudioIO({
  outOptions: {
    channelCount: 2,
    sampleFormat: portAudio.SampleFormat16Bit,
    sampleRate: 22000,
    maxQueue: 1,
    closeOnError: true
  }
});

var rs = fs.createReadStream('./audio/output.wav');
rs.pipe(ao);
ao.start();

Troubleshooting 1:
I've tried to debug and step through the code, however during debugging, the full audio gets played fine and I don't see anything amiss throughout code stepping.

Troubleshooting 2:
I've also played the same file via VLC media player and the audio file was complete (no cut at the end).
Using a different audio file also results in audio getting cut at the end too.

Troubleshooting 3:
To narrow down the issue more, I did the following:

var rs = fs.createReadStream('./audio/output.wav');
var ws = fs.createWriteStream('./audio/output-write.wav');

rs.on('data', (chunk) => {
  console.log(chunk);
  ws.write(chunk);
});

and the file write out complete without audio cut when played via VLC media player.

However when I change it to:
ao.write(chunk);
the output audio gets trimmed at the end.

Troubleshooting 4:
I realized that changing the outOptions.maxQueue affects how much audio is being cut at the end. Setting to 1 and I get the longest audio play, setting it to 2 and it gets shortened more, 3 even more and so on. Setting it to 0 and no audio was played.

Troubleshooting 5:
I've also logged out the close event from the readstream and finish event from ao write stream,
it seems that the close event gets called, then the finish event and that's when the audio gets cut. It does not seem to wait for the audio to finish playing.

I hope someone can help me out with this! Thanks for your time!

Segfault Issues

Hi, similar to a few other users on here I am getting repeated Segfault errors causing node js to crash. I am playing a short audio clip on loop (2s long). The error occurs after ~5-20seconds, but always occurs pretty early on. It only occurs when outputting audio through naudiodon (I have tested piping to a file and error does not occur).

Unlike a most others I do not use electron, It is a custom audio application, with other dependencies, but this error only occurs when the pipe to naudiodon. I recieve a slightly different (and often earlier) segfault error when piping to an audio device which exists, but is not connected to any speakers, which directly references naudiodon, but get a very similar error even if I avoid this use case.

Error when sending to audio device not attached to speakers:

PID 1420 received SIGSEGV for address: 0x9b95a799
SymInit: Symbol-SearchPath: '.;C:\Users\emina\OneDrive\Room\Subsystems\Host\node_server;C:\Program Files\nodejs;C:\WINDOWS;C:\WINDOWS\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'emina'
OS-Version: 10.0.18363 () 0x100-0x1
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\segfault-handler\src\stackwalker.cpp (924): StackWalker::ShowCallstack
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\segfault-handler\src\segfault-handler.cpp (242): segfault_handler
00007FFF9E1785B6 (ntdll): (filename not available): RtlIsGenericTableEmpty
00007FFF9E16A056 (ntdll): (filename not available): RtlRaiseException
00007FFF9E169FC3 (ntdll): (filename not available): RtlRaiseException
00007FFF9B95A799 (KERNELBASE): (filename not available): RaiseException
d:\agent\_work\2\s\src\vctools\crt\vcruntime\src\eh\throw.cpp (133): _CxxThrowException
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\naudiodon\node_modules\node-addon-api\napi-inl.h (2572): Napi::FunctionReference::Call
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\naudiodon\src\audioio.cc (85): streampunk::WriteWorker::OnOK
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\naudiodon\node_modules\node-addon-api\napi-inl.h (73): Napi::details::WrapCallback<<lambda_f85feabe9509ada3892561e506fcfa4d> >
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\naudiodon\node_modules\node-addon-api\napi-inl.h (3838): Napi::AsyncWorker::OnWorkComplete
00007FF76CF3314C (node): (filename not available): node_module_register
00007FF76CFB7B40 (node): (filename not available): uv_timer_stop
00007FF76CFB7C17 (node): (filename not available): uv_timer_stop
00007FF76CFB463B (node): (filename not available): uv_async_send
00007FF76CFB3DDC (node): (filename not available): uv_loop_init
00007FF76CFB3FA4 (node): (filename not available): uv_run
00007FF76CEC63A1 (node): (filename not available): v8::internal::AsmJsScanner::GetIdentifierString
00007FF76CF390E3 (node): (filename not available): node::Start
00007FF76CDA6A9C (node): (filename not available): RC4_options
00007FF76DC2F8C8 (node): (filename not available): v8::internal::SetupIsolateDelegate::SetupHeap
00007FFF9D767BD4 (KERNEL32): (filename not available): BaseThreadInitThunk
00007FFF9E16CE51 (ntdll): (filename not available): RtlUserThreadStart
Error: Invalid argument
EXIT FUNCTION FIRING

Error when sending to devices which are only attached to speakers:

PID 15292 received SIGSEGV for address: 0x6d4770e7
SymInit: Symbol-SearchPath: '.;C:\Users\emina\OneDrive\Room\Subsystems\Host\node_server;C:\Program Files\nodejs;C:\WINDOWS;C:\WINDOWS\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'emina'
OS-Version: 10.0.18363 () 0x100-0x1
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\segfault-handler\src\stackwalker.cpp (924): StackWalker::ShowCallstack
c:\users\emina\onedrive\room\subsystems\host\node_server\node_modules\segfault-handler\src\segfault-handler.cpp (242): segfault_handler
00007FFF9E1785B6 (ntdll): (filename not available): RtlIsGenericTableEmpty
00007FFF9E16A056 (ntdll): (filename not available): RtlRaiseException
00007FFF9E19FE3E (ntdll): (filename not available): KiUserExceptionDispatcher
00007FF76D4770E7 (node): (filename not available): v8::internal::JSObject::AddDataElement
00007FF76D43539F (node): (filename not available): v8::internal::PrototypeUsers::Add
00007FF76D4501FD (node): (filename not available): v8::internal::Object::SetProperty
00007FF76D72577A (node): (filename not available): v8::Object::Set
00007FF76CF84E39 (node): (filename not available): node::CallbackScope::CallbackScope
00007FF76CF84BB7 (node): (filename not available): node::CallbackScope::CallbackScope
00007FF76CF85CC4 (node): (filename not available): node::AsyncResource::CallbackScope::CallbackScope
00007FF76CF330FE (node): (filename not available): node_module_register
00007FF76CFB7B40 (node): (filename not available): uv_timer_stop
00007FF76CFB7C17 (node): (filename not available): uv_timer_stop
00007FF76CFB463B (node): (filename not available): uv_async_send
00007FF76CFB3DDC (node): (filename not available): uv_loop_init
00007FF76CFB3FA4 (node): (filename not available): uv_run
00007FF76CEC63A1 (node): (filename not available): v8::internal::AsmJsScanner::GetIdentifierString
00007FF76CF390E3 (node): (filename not available): node::Start
00007FF76CDA6A9C (node): (filename not available): RC4_options
00007FF76DC2F8C8 (node): (filename not available): v8::internal::SetupIsolateDelegate::SetupHeap
00007FFF9D767BD4 (KERNEL32): (filename not available): BaseThreadInitThunk
00007FFF9E16CE51 (ntdll): (filename not available): RtlUserThreadStart```

How would I record system audio.

Forgive my ignorance if this is obvious but how would you record system audio?

I tried creating an instance of AudioOutput but I could spot anything on the stream.

Can't enumerate supported hosts

There doesn't appear to be any wrapping of Pa_GetHostApiCount and Pa_GetHostApiInfo, which would allow me to get a list of the supported host apis and the default devices.

How does naudiodon feed PCM data to portaudio? Interleaved or non-interleaved?

Hey there!

Hoping someone can clear this up for me, I've only just got into naudiodon and portaudio. Reading the portaudio c documentation, it says that it reads in multichannel pcm as interleaved or non-interleaved samples and 'automatically performs conversion where necessary'. I'm a bit confused how this concept applies within naudiodon.

Are we required to feed our multichannel files as interleaved or non-interleaved samples? I.e [chan1sampl0,chan2sampl0,chan3sampl0, chan1sampl1,chan2sampl1, chan3sampl1] or [chan1sampl0,chan1sampl1,chan2sampl0,chan2sampl1, chan3sampl0, chan3sampl1]?

Doing some tests, I see interleaving 8 bit samples seems to do the trick.

Now, when streaming more than 8 bit samples, how do we fill a buffer with the correct bytes for each sample? For instance, a 16 bit word, do we fill the buffer [upper16chan1sampl0,lower16chan1sampl0,upper16chan2sampl0,lower16chan1sampl0,... Etc ] or some other way?

Would appreciate any guidance with this!

Trying to understand number of processed buffers per second

Hi

I'm really trying to understand why the following happens.
Any insight would be super useful. 🤪

I have set the following settings from an audio-in readable stream:

sampleRate: 44100
sampleFormat: 16   // 2 bytes per sample per channel
channelCount: 12   // sound card with 12 inputs (6x Left/Right)
highwaterMark = 12 * 2 * 512 // (12 open channels) * (2 bytes per frame) * (512 frames per buffer) = 12288 bytes

I'd think that the buffer-callback gets called +- 86 times per second:
44100 samples per second / 512 samples = 86.1328125

Yet, when I manually count the amount of buffer-callbacks, I get 172, which is exactly the double.
Here's the code how I count the buffer-callback:

let prevTimestamp = 0
let processedBuffersInSecond = 0
this.stream.on(`data`, (buffer) => {
  processedBuffersInSecond++

  if(buffer.timestamp - prevTimestamp > 1) {
    console.log(`Buffers processed in 1 sec: ${processedBuffersInSecond}, ${this.sampleRate} / ${this.framesPerBuffer} = ${this.sampleRate / this.framesPerBuffer}`)
    processedBuffersInSecond = 0
    prevTimestamp = buffer.timestamp
  }
})
# Output
Buffers processed in 1 sec: 172, 44100 / 512 = 86.1328125
Buffers processed in 1 sec: 172, 44100 / 512 = 86.1328125
Buffers processed in 1 sec: 172, 44100 / 512 = 86.1328125
Buffers processed in 1 sec: 173, 44100 / 512 = 86.1328125
Buffers processed in 1 sec: 172, 44100 / 512 = 86.1328125
Buffers processed in 1 sec: 172, 44100 / 512 = 86.1328125
Buffers processed in 1 sec: 172, 44100 / 512 = 86.1328125

Why is this? Am I missing something?

Select input channel

Hi, I'm using a multi input sound card (16 input channels). How can I select the channel I want to record? I mean, how can I set the input source of a stream?

Thanks

A dynamic link library (DLL) initialization routine failed.

I am trying to use naudiodon to stream audio in an Electron.js application. When I attempt to use naudiodon, I get a series of errors related to a dll not being able to be initialized.

Here is my calling code:

const portAudio = require('naudiodon');

// get a list of devices
module.exports.getDeviceList = () => {
  let deviceNames = {};
  for(var x of portAudio.getDevices()) {
    if (x.maxOutputChannels > 0) {
      deviceNames[x] = x.id;
    }
  }
  return deviceNames;
}

The code in my Electron.js html page:

let deviceList = Object.keys(api.getDeviceList());
let optionsHtml = '';
for(var x of deviceList) {
     optionsHtml += `<option>${x}</option>`;
 }
 $('#device').html(optionsHtml);

With api being a reference to the first bit of code.

The traceback:

Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\--\node_modules\naudiodon\build\Release\naudiodon.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at bindings (C:\--\node_modules\bindings\bindings.js:81:44)
    at Object.<anonymous> 
(C:\--\node_modules\naudiodon\index.js:19:46)
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at bindings (C:\--\node_modules\bindings\bindings.js:81:44)
    at Object.<anonymous> (C:\--\node_modules\naudiodon\index.js:19:46)
    at Object.exception
...

Part following the ellipsis appear to be irrelevant. (the error echoing up through my code)

I installed naudiodon with npm install naudiodon --save.
I am using the following version of npm and nodejs:
Nodejs: v8.10.0
npm: v5.6.0

And the module (naudiodon) version is: 0.4.6

I am on Windows 10 (64 bit OS)

Please reply as soon as possible. Thanks!

Can't install on node 14

I get this with node v14.15.3 . I downgraded to node 10 and it was fine. Just saying as the README says its developed with LTS (which is node 14)

 npm i naudiodon

> [email protected] install /Users/jonahfox/dev/node_modules/ref
> node-gyp rebuild

  CXX(target) Release/obj.target/binding/src/binding.o
../src/binding.cc:222:43: error: too few arguments to function call, single argument 'isolate' was not specified
  bool persistent = info[3]->BooleanValue();
                    ~~~~~~~~~~~~~~~~~~~~~ ^
/Users/jonahfox/Library/Caches/node-gyp/14.15.3/include/node/v8.h:2858:3: note: 'BooleanValue' declared here
  bool BooleanValue(Isolate* isolate) const;
  ^
../src/binding.cc:253:38: error: too few arguments to function call, single argument 'context' was not specified
  size_t size = info[2]->Uint32Value();

Output silent

Running using the latest stable version of Node on Mac OS X Mojave. I'm routing my audio with Soundflower. I can record my soundcard output with Quicktime with no problem using this routing configuration. Any output from the module whether sourced from mic or Soundflower outputs an empty raw file with no sound.

Getting Audio Decibal Level?

Hello, i hope this is the right library to be using.

I am trying to get the current audio level to detect if sound is currently being played from the speaker (like when a youtube video is opened, i can detect that)

I am not sure if this library has an example for that scenario so I wanted to ask.

Record error when using Soundflower(2ch)

Hello,

When I use Soundflower(2ch) to record audio, sometimes it works well, but sometimes it prints an error and cannot receive any audio data:

||PaMacCore (AUHAL)|| Error on line 2490: err='-10863', msg=Audio Unit: cannot do in current context

What's causing this? Or is there any way to capture this error? I listened error event, but it was not triggered.

Thanks

Big delay when using bluetooth microphone (airpods)

I'm using this library to record the user's audio input stream. With a built-in microphone it's perfect. However when I use my airpods microphone, there's such an initial buffer/delay that the first 1/2 seconds of talking are cut off. Any ideas on how to improve this?

I've tried using ai.on('data', buf => console.log(buf.timestamp)); to determine when the audio input actually starts collecting data, but this seems to first get called way after the audio begins to be captured.

Code for reference:

  ai = new portAudio.AudioIO({
    inOptions: {
      channelCount: inputDevice.maxInputChannels,
      sampleFormat: portAudio.SampleFormat16Bit,
      sampleRate: 44100,
      deviceId: inputDevice.id,
      closeOnError: false 
    }
  });

  // Create a write stream to write out to a raw audio file
  const ws = require('fs').createWriteStream(`tmp/${title}.raw`)

  //Start streaming
  ai.pipe(ws);
  ai.start();

Allow setting framesPerBuffer through js api

Currently the framesPerBuffer is hardcoded in PaContext.cc (it defaults to paFramesPerBufferUnspecified, but is hardcoded to 256 on arm).

Could framesPerBuffer by exposed on the js api in/outOptions part?

This would allow experiments without needing to recompile the C++ module each time.

Problems when installing on Windows

Did a fresh install of windows yesterday(2018-12-06) and were having some issues installing this module.
System info:
Windows 10 Pro 64-bit
Version 10.0.17134 Build 17134 (1803)

I installed nodejs, python2, vscode, git and github desktop on the fresh install. Albeit that i did get other errors before i reinstalled.
There seems to be some unmentioned prerequesites for this module, and im not sure if you are aware of this?
First i had issues because i had python3 and not python2 installed(this was before i reinstalled windows!)
You can see the first error i got here:
`C:\Github\hue-controller>npm install --save naudiodon

[email protected] install C:\Github\hue-controller\node_modules\naudiodon
node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Program Files (x86)\Python37-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:276:12)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\knerl\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"gyp ERR! cwd C:\Github\hue-controller\node_modules\naudiodon
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] No description
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\knerl\AppData\Roaming\npm-cache_logs\2018-12-06T17_36_43_427Z-debug.log`

This should be fixed by installing python2 and having it in your PATH. I am not sure if you need to remove python3 from PATH before this will work.

The second error goes something like this:
MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".
The solution for this seems to be that you either have to install a redist that supports the mentioned version. Or you can download and install Visual Studio Community 2017 and add atleast one of or both these Workloads: .NET Desktop Development and Desktop Development with C++.
I added both.

After that the installation worked perfectly with no issues.

Playback on osx is high-pitched

Tried with several files, samplerate is set fine .. but playback is pitched very high, so samples play fast.
No errors or messages of any kind ...

Anyone met something like this?

npm install fails on Armbian

Node: v10.15.3

error:

 node-gyp rebuild

make: Entering directory '/home/sgarza/Projects/linux/naudiodon/build'
  CC(target) Release/obj.target/nothing/node_modules/node-addon-api/src/nothing.o
  AR(target) Release/obj.target/node_modules/node-addon-api/src/nothing.a
  COPY Release/nothing.a
  COPY ../build/Release/libportaudio.so.2
  CXX(target) Release/obj.target/naudiodon/src/naudiodon.o
  CXX(target) Release/obj.target/naudiodon/src/GetDevices.o
  CXX(target) Release/obj.target/naudiodon/src/GetHostAPIs.o
  CXX(target) Release/obj.target/naudiodon/src/AudioIO.o
  CXX(target) Release/obj.target/naudiodon/src/PaContext.o
../src/PaContext.cc: In member function ‘void streampunk::PaContext::setParams(Napi::Env, bool, std::shared_ptr<streampunk::AudioOptions>, PaStreamParameters&, double&)’:
../src/PaContext.cc:237:3: error: ‘framesPerBuffer’ was not declared in this scope
   framesPerBuffer = 256;
   ^~~~~~~~~~~~~~~
../src/PaContext.cc:237:3: note: suggested alternative: ‘readPaBuffer’
   framesPerBuffer = 256;
   ^~~~~~~~~~~~~~~
   readPaBuffer
naudiodon.target.mk:119: recipe for target 'Release/obj.target/naudiodon/src/PaContext.o' failed

I commented the line PaContext.cc:237 and it compiled. I still have to test if it works

Installation of naudiodon fails on Fedora 30

I'm trying to install naudiodon on a fedora 30 distro with nodejs 12.x and I get the messages below. It appears the there is a mismatch in the libraries and function names: '../src/binding.cc:30:38: error: no matching function for call to ‘v8::Value::Int32Value()’
30 | ao->channels = info[1]->Int32Value(); /* channels */''. However I cant figure out what to change so as to get it to compile. Some pointers would be appreciated.

=======================================
npm install naudiodon --save

[email protected] install /home/user/myapp/node_modules/speaker
node-gyp rebuild

make: Entering directory '/home/user/myapp/node_modules/speaker/build'
CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
../deps/mpg123/src/output/alsa.c: In function ‘initialize_device’:
../deps/mpg123/src/output/alsa.c:78:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
78 | for (i = 0; i < NUM_FORMATS; ++i) {
| ^
../deps/mpg123/src/output/alsa.c: In function ‘get_formats_alsa’:
../deps/mpg123/src/output/alsa.c:201:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
201 | for (i = 0; i < NUM_FORMATS; ++i) {
| ^
AR(target) Release/obj.target/deps/mpg123/liboutput.a
COPY Release/liboutput.a
CXX(target) Release/obj.target/binding/src/binding.o
In file included from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2298:62: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
2298 | , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
| ^
../src/binding.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/binding.cc:30:38: error: no matching function for call to ‘v8::Value::Int32Value()’
30 | ao->channels = info[1]->Int32Value(); /* channels /
| ^
In file included from /home/jp/.cache/node-gyp/12.8.0/include/node/node.h:63,
from ../../nan/nan.h:54,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate: ‘v8::Maybe v8::Value::Int32Value(v8::Localv8::Context) const’
2576 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local context) const;
| ^~~~~~~~~~
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc:31:34: error: no matching function for call to ‘v8::Value::Int32Value()’
31 | ao->rate = info[2]->Int32Value(); /
sample rate /
| ^
In file included from /home/jp/.cache/node-gyp/12.8.0/include/node/node.h:63,
from ../../nan/nan.h:54,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate: ‘v8::Maybe v8::Value::Int32Value(v8::Localv8::Context) const’
2576 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local context) const;
| ^~~~~~~~~~
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc:32:36: error: no matching function for call to ‘v8::Value::Int32Value()’
32 | ao->format = info[3]->Int32Value(); /
MPG123_ENC_* format /
| ^
In file included from /home/jp/.cache/node-gyp/12.8.0/include/node/node.h:63,
from ../../nan/nan.h:54,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate: ‘v8::Maybe v8::Value::Int32Value(v8::Localv8::Context) const’
2576 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local context) const;
| ^~~~~~~~~~
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Write(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/binding.cc:51:33: error: no matching function for call to ‘v8::Value::Int32Value()’
51 | int len = info[2]->Int32Value();
| ^
In file included from /home/jp/.cache/node-gyp/12.8.0/include/node/node.h:63,
from ../../nan/nan.h:54,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate: ‘v8::Maybe v8::Value::Int32Value(v8::Localv8::Context) const’
2576 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local context) const;
| ^~~~~~~~~~
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:2576:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc:62:78: warning: cast between incompatible function types from ‘void (
)(uv_work_t*)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
62 | uv_queue_work(uv_default_loop(), &req->req, write_async, (uv_after_work_cb)write_after);
| ^~~~~~~~~~~
../src/binding.cc: In function ‘void {anonymous}::write_after(uv_work_t*)’:
../src/binding.cc:80:31: warning: ‘v8::Localv8::Value Nan::Callback::Call(int, v8::Localv8::Value) const’ is deprecated [-Wdeprecated-declarations]
80 | wreq->callback->Call(1, argv);
| ^
In file included from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../../nan/nan.h:1740:3: note: declared here
1740 | Call(int argc, v8::Localv8::Value argv[]) const {
| ^~~~
../src/binding.cc: At global scope:
../src/binding.cc:104:17: error: variable or field ‘Initialize’ declared void
104 | void Initialize(Handle target) {
| ^~~~~~
../src/binding.cc:104:17: error: ‘Handle’ was not declared in this scope
../src/binding.cc:104:30: error: expected primary-expression before ‘>’ token
104 | void Initialize(Handle target) {
| ^
../src/binding.cc:104:32: error: ‘target’ was not declared in this scope
104 | void Initialize(Handle target) {
| ^~~~~~
In file included from ../../nan/nan.h:54,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../src/binding.cc:155:22: error: ‘Initialize’ was not declared in this scope
155 | NODE_MODULE(binding, Initialize)
| ^~~~~~~~~~
/home/jp/.cache/node-gyp/12.8.0/include/node/node.h:556:36: note: in definition of macro ‘NODE_MODULE_X’
556 | (node::addon_register_func) (regfunc),
| ^~~~~~~
../src/binding.cc:155:1: note: in expansion of macro ‘NODE_MODULE’
155 | NODE_MODULE(binding, Initialize)
| ^~~~~~~~~~~
In file included from /home/jp/.cache/node-gyp/12.8.0/include/node/node.h:63,
from ../../nan/nan.h:54,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfonode::ObjectWrap&)]’:
/home/jp/.cache/node-gyp/12.8.0/include/node/node_object_wrap.h:84:78: required from here
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:9853:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfonode::ObjectWrap::Callback’ {aka ‘void (
)(const v8::WeakCallbackInfonode::ObjectWrap&)’} to ‘Callback’ {aka ‘void ()(const v8::WeakCallbackInfo&)’} [-Wcast-function-type]
9853 | reinterpret_cast(callback), type);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P
, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfoNan::ObjectWrap&)]’:
../../nan/nan_object_wrap.h:65:61: required from here
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:9853:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfoNan::ObjectWrap::Callback’ {aka ‘void (
)(const v8::WeakCallbackInfoNan::ObjectWrap&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} [-Wcast-function-type]
In file included from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../src/binding.cc:93:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Close(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
93 | NAN_METHOD(Close) {
| ^~~~~
../../nan/nan.h:1566:33: note: in definition of macro ‘NAN_METHOD’
1566 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
../src/binding.cc:85:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Flush(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
85 | NAN_METHOD(Flush) {
| ^~~~~
../../nan/nan.h:1566:33: note: in definition of macro ‘NAN_METHOD’
1566 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
../src/binding.cc:47:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Write(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
47 | NAN_METHOD(Write) {
| ^~~~~
../../nan/nan.h:1566:33: note: in definition of macro ‘NAN_METHOD’
1566 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
../src/binding.cc:24:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Open(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
24 | NAN_METHOD(Open) {
| ^~~~
../../nan/nan.h:1566:33: note: in definition of macro ‘NAN_METHOD’
1566 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
make: *** [binding.target.mk:120: Release/obj.target/binding/src/binding.o] Error 1
make: Leaving directory '/home/user/myapp/node_modules/speaker/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:196:23)
gyp ERR! stack at ChildProcess.emit (events.js:203:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 5.2.7-200.fc30.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/myapp/node_modules/speaker
gyp ERR! node -v v12.8.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok

[email protected] install /home/user/myapp/node_modules/segfault-handler
node-gyp rebuild

make: Entering directory '/home/user/myapp/node_modules/segfault-handler/build'
CXX(target) Release/obj.target/segfault-handler/src/segfault-handler.o
In file included from ../src/segfault-handler.cpp:2:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2298:62: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
2298 | , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
| ^
In file included from ../../nan/nan.h:54,
from ../src/segfault-handler.cpp:2:
../src/segfault-handler.cpp: At global scope:
/home/jp/.cache/node-gyp/12.8.0/include/node/node.h:556:43: warning: cast between incompatible function types from ‘void ()(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void ()(v8::Localv8::Object)’} to ‘node::addon_register_func’ {aka ‘void ()(v8::Localv8::Object, v8::Localv8::Value, void)’} [-Wcast-function-type]
556 | (node::addon_register_func) (regfunc),
| ^
/home/jp/.cache/node-gyp/12.8.0/include/node/node.h:590:3: note: in expansion of macro ‘NODE_MODULE_X’
590 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
| ^~~~~~~~~~~~~
../src/segfault-handler.cpp:346:3: note: in expansion of macro ‘NODE_MODULE’
346 | NODE_MODULE(segfault_handler, init)
| ^~~~~~~~~~~
In file included from /home/jp/.cache/node-gyp/12.8.0/include/node/node.h:63,
from ../../nan/nan.h:54,
from ../src/segfault-handler.cpp:2:
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P*, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfonode::ObjectWrap&)]’:
/home/jp/.cache/node-gyp/12.8.0/include/node/node_object_wrap.h:84:78: required from here
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:9853:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfonode::ObjectWrap::Callback’ {aka ‘void (
)(const v8::WeakCallbackInfonode::ObjectWrap&)’} to ‘Callback’ {aka ‘void ()(const v8::WeakCallbackInfo&)’} [-Wcast-function-type]
9853 | reinterpret_cast(callback), type);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P
, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfoNan::ObjectWrap&)]’:
../../nan/nan_object_wrap.h:65:61: required from here
/home/jp/.cache/node-gyp/12.8.0/include/node/v8.h:9853:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfoNan::ObjectWrap::Callback’ {aka ‘void (
)(const v8::WeakCallbackInfoNan::ObjectWrap&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} [-Wcast-function-type]
SOLINK_MODULE(target) Release/obj.target/segfault-handler.node
COPY Release/segfault-handler.node
make: Leaving directory '/home/user/myapp/node_modules/segfault-handler/build'

[email protected] install /home/user/myapp/node_modules/naudiodon
node-gyp rebuild

make: Entering directory '/home/user/myapp/node_modules/naudiodon/build'
CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
AR(target) Release/obj.target/../node-addon-api/src/nothing.a
COPY Release/nothing.a
COPY ../build/Release/libportaudio.so.2
CXX(target) Release/obj.target/naudiodon/src/naudiodon.o
CXX(target) Release/obj.target/naudiodon/src/GetDevices.o
CXX(target) Release/obj.target/naudiodon/src/GetHostAPIs.o
CXX(target) Release/obj.target/naudiodon/src/AudioIO.o
CXX(target) Release/obj.target/naudiodon/src/PaContext.o
SOLINK_MODULE(target) Release/obj.target/naudiodon.node
COPY Release/naudiodon.node
make: Leaving directory '/home/user/myapp/node_modules/naudiodon/build'
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/speaker):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: node-gyp rebuild
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

  • [email protected]
    added 3 packages from 50 contributors, removed 1 package and audited 9558 packages in 13.627s
    found 0 vulnerabilities

Update the README with a list of available events and methods

I was hoping to get a bit more of an idea of the event handlers that I can hook into.

For example, I want to created a recorder that starts whenever an audio signal is received from a usb device. Something like:

ai.on('audioSignal', () => {
    // Start recording
}

Is there anything like that in portAudio? Or is that more something I would have to create an wrapper around the USB audio interface?

npm install fails on mac

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/spulipaka/Desktop/My Projects/Personal/demo/node_modules/segfault-handler/build'
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/spulipaka/Desktop/My Projects/Personal/demo/node_modules/segfault-handler
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/Users/spulipaka/Desktop/My Projects/Personal/demo/package.json'
npm WARN demo No description
npm WARN demo No repository field.
npm WARN demo No README data
npm WARN demo No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

naudiodon stops working after about an hour and a half

I have been using naudiodon for input and output for a desktop application built with Electron.
Everything works fine at the start but after an hour and a half or so the output audio stops and the application stops working. Below is the stack trace outputted by the electron application. Does anyone have an idea about what is causing the problem?

┏ Electron -------------------

PID 90015 received SIGSEGV for address: 0x0
  
┗ ----------------------------

┏ Electron -------------------

  0   segfault-handler.node               0x00000001072c0010 _ZL16segfault_handleriP9__siginfoPv + 304
  1   libsystem_platform.dylib            0x00007fff7278c5fd _sigtramp + 29
  2   ???                                 0x0000000000000000 0x0 + 0
  
┗ ----------------------------

┏ Electron -------------------

  3   Electron Framework                  0x000000010cff0766 napi_call_function + 150
  
┗ ----------------------------

┏ Electron -------------------

  4   naudiodon.node                      0x00000001072815c9 _ZNK4Napi8Function4CallERKSt16initializer_listIP12napi_value__E + 61
  5   naudiodon.node                      0x0000000107280d6d _ZNK4Napi17FunctionReference4CallERKSt16initializer_listIP12napi_value__E + 103
  6   naudiodon.node                      0x000000010728043e _ZN10streampunk10ReadWorker4OnOKEv + 392
  7   naudiodon.node                      0x0000000107280ab4 _ZZN4Napi11AsyncWorker14OnWorkCompleteEP10napi_env__11napi_statusPvENKUlvE_clEv + 72
  8   naudiodon.node                      0x00000001072809b5 _ZN4Napi11AsyncWorker14OnWorkCompleteEP10napi_env__11napi_statusPv + 57
  9   Electron Framework                  0x000000010d00a3d1 napi_ref_threadsafe_function + 1553
  10  Electron Framework                  0x000000010d116048 uv_inet_pton + 2648
  
┗ ----------------------------

┏ Electron -------------------

  11  Electron Framework                  0x000000010d119fe4 uv_async_send + 948
  12  Electron Framework                  0x000000010d12b2b0 uv_free_interface_addresses + 2288
  13  Electron Framework                  0x000000010d11a4b1 uv_run + 497
  14  Electron Framework                  0x0000000107921aa8 ElectronInitializeICUandStartNode + 1583704
  15  Electron Framework                  0x000000010779f13a ElectronInitializeICUandStartNode + 234
  16  Electron Helper (Renderer)          0x00000001069aef0a Electron Helper (Renderer) + 3850
  17  libdyld.dylib                       0x00007fff72593cc9 start + 1
  18  ???                                 0x0000000000000002 0x0 + 2

Get exact timestamp of audio recording start in with PortAudio

Basically, we record audio and video separately, but afterwards we still need to sync them together, and in order to do that, we need exact timestamp of audio start, and by piping into AudioIO or listening to data events we not getting it right. Port Audio has some delay in releasing chunks.

Fully described problem here.

Generates squeaks

When i try the sample program , it generates squeaks instead of the sound. I am using an external USB speaker to play.

Library not loaded: /usr/local/opt/portaudio/lib/libportaudio.2.dylib

Am running this in my app

import portAudo from "naudiodon"

console.log(portAudo.getDevices())

and get the following error

Library not loaded: /usr/local/opt/portaudio/lib/libportaudio.2.dylib
  Referenced from: /Users/<user>/personal/Projects/node/prjname/node_modules/naudiodon/build/Release/naudiodon.node
  Reason: image not found
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at bindings 

Input Overflow Error when stream is not read from

Is there a way to ignore the input overflow error thrown by a stream such that the stream is not closed, and continues to work?

My application records system audio and broadcasts it over a network; sometimes due to network issues or no clients listening in, the stream is not emptied quickly enough, and it overflows and closes, necessitating a server restart for it to work again.

Can the exception be ignored? I remember older versions of naudiodon not closing the stream when an input overflow error occurred, allowing the program to continue running

Record system output

Hi,

Basically I want to record and stream the system output of the host. If this is possible how do I modify the inoptions to point to an output?

Thanks

Is there a way to convert the recorded .raw file to a .wav file?

I realize that the README here says:

Note that this produces a raw audio file - wav headers would be required to create a wav file.

However, do you have any idea for how I should go about this? (Using JS, not a command line tool such as SoX, unless there is a wrapper for it)

Uncaught TypeError: Path must be a string. Received undefined

On the latest version of naudiodon, getDevices will throw an exception. I'm on macOS Sierra if that is any help.

var naudiodon = require('naudiodon')
...
console.log(naudiodon.getDevices()) // Uncaught TypeError: Path must be a string. Received undefined

I hope you'll be able to help - I'm looking very much forward, to use your great addon.

Reading from microphone every x seconds

Thanks for sharing this great package! I am currently trying to read data from the microphone every x seconds using the code below, where I just try to print out the length of the buffer obtained from the microphone:

const setTimeoutPromise = require("util").promisify(setTimeout);
const AudioIO = require("naudiodon").AudioIO;
const interval = 1;
let handleMICPromises = [];
let readPromises = [];
let microphoneOn = false;

const options = {inOptions: {channelCount: 1, sampleFormat: 16, sampleRate: 8000}};
const microphoneStream = new AudioIO(options);

function handleMIC(resolve, reject)
{
    if (microphoneOn)
    {
        const readPromise = setTimeoutPromise(interval * 1000);
        readPromise.then(read);
        readPromises.push(readPromise);
    }
    else
    {
        microphoneStream.quit();
    }
    handleMICPromises.shift();
    resolve();
}

function read()
{
    readPromises.shift();
    const handleMICPromise = new Promise(handleMIC);
    handleMICPromises.push(handleMICPromise);

    if (microphoneStream.readable)
    {
        let buffer = microphoneStream.read();
        if (buffer !== null)
        {
            console.log(buffer.byteLength);
        }
    }
}

process.on("SIGINT", () => {
    microphoneOn = false;
    Promise.all(readPromises.concat(handleMICPromises)).then(()=> {process.exit();});
});

microphoneStream.start();
microphoneOn = true;
const handleMICPromise = new Promise(handleMIC);
handleMICPromises.push(handleMICPromise);

When I try to run the above file, it prints out 16384 for the length of the buffer every 1 second. This seems about right, since audio sampled every second at 8000 samples per second with a sampling format of 16 (2 bytes) will be about 16,000 bytes. So far so good.

However, when I try to set the interval at the beginning of the code to, say, 5, I still get the same buffer length of 16384 printed out. This shouldn't be right. According to the NodeJS documentation on read(), read() should read everything that's in the readable stream. But this is not happening in this case.

Let me know if I'm missing something, or if this is a possible bug. I also looked at the resulting audio file when I parse and save the results of the buffer to a WAV file, and I only get 1 second worth of audio for every call to read() even if I make that call to read() every 5 seconds.

Thanks in advance for your help!

input overflow error when thread blocks

I am trying to capture input audio from device. This works great when the thread is free, but I have noticed that if the thread blocks for a short while, this can cause portAudio status - input overflow to be thrown and then the stream stops.

Managed to get the scratch/inputToFile.js to reproduce this by adding a fake sleep (loop that takes a long time to complete).

// add to scratch/inputToFile.js
var collection = []

setInterval(() => {
  for (var i = 0; i < 1000000; i++) {
    collection.push(i)
  }
}, 1000)

Then after a few seconds, you should see:

Error: portAudio status - input overflow 
    at Error (native)

I tried messing with the maxQueue value:

mInContext = std::make_shared<InContext>(std::make_shared<AudioOptions>(options), InCallback, 2);

But still hitting this.

Any ideas?

C++ Install errors with v2

When trying to install v2 on macOS mojave v10.14.3, I got the following errors :

../src/PaContext.h:63:23: error: extra qualification on member 'fillBuffer'
  uint32_t PaContext::fillBuffer(uint8_t *buf, uint32_t numBytes,
           ~~~~~~~~~~~^
../src/AudioIO.cc:34:45: warning: field 'mNumBytes' will be initialized after field 'mPaContext' [-Wreorder]
      : AsyncWorker(callback, "AudioRead"), mNumBytes(numBytes), mPaContext(paContext)
                                            ^
../src/AudioIO.cc:117:42: error: qualified reference to 'Object' is a constructor name rather than a type in this context
  Napi::Object inOptions = Napi::Object::Object();
                                         ^
../src/AudioIO.cc:118:43: error: qualified reference to 'Object' is a constructor name rather than a type in this context
  Napi::Object outOptions = Napi::Object::Object();

V1 installation is OK.
Is there something I am missing ? node-gyp is well installed, tested with different node version.

Thanks !

Electron libportaudio image not found - binding.gyp enhancement

I got hit with the Image not found error for libportaudio when I packaged up my electron application and ran it on a different machine, application ran fine on the development machine though. After digging through some documents about node-gyp, I was suggested to look for the linker section of the naudiodon.node binary and found out that the LC_PATH was set to an absolute path of the build/Release path on my development machine. What I did to make it work was to change the OTHER_LDFLAGS of OS=="mac" to "-Wl,-rpath,@loader_path/" which tells the linker to look for libraries relative to the binary file location.

Error from calls when running inside a docker container on RPi3

I am doing the following from within an ubuntu container running on an RPi3 Raspbian...

        var portAudio = require('naudiodon');
        var devices = portAudio.getDevices();
        var devices_str = ""
        for (device in devices) {
          temp = devices[device]
          if(temp['id'] == requested_device) {
            response_string = "<pre>" + JSON.stringify(temp, null, 4) + "</pre>";
            response_string += "Reading Data : <a href=\"socket_audio?device_id=" + temp['id'] + "\">" + temp['name'] + "</a>"
          }
        }

I am seeing the following coming out of the nodejs server

Server running at: http://0.0.0.0:8081
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
181001/193148.159, [response], http://0.0.0.0:8081: get /socket_audio {"device_id":"

No support for IEEE Sample Format.

I have a small script just loading in a single .wav file, mostly just a copy and paste from the README and the sound quality that outputs to my speakers is terrible. It's mostly screeching.

I've confirmed that the audio file was saved at 44100 Hz with 32 Bit Float (IEEE), 2 channels. So I've set up the outOptions accordingly.

var ao = new portAudio.AudioIO({
    outOptions: {
      channelCount: 2,
      sampleFormat: portAudio.SampleFormat32Bit,
      sampleRate: 44100,
      deviceId: -1 // Use -1 or omit the deviceId to select the default device
    }
});

The only way I could get the audio to behave nicely was to convert it to 16 Bit and then change the sampleFormat to SampleFormat16Bit. Is this intended by this library? Or is there some lower level detail that I am missing? Playing this same audio file through something like Audacity sounds just fine.


Edit

So from my understanding, this library is expecting Signed 32 Bit Integers, not floats at all. Yikes!

Confirmed within PaContext.cc Line 226, the switch statement looks for a parameter of 32 and then assigns a Sample Format of paInt32 to the context. This lib should be able to distinguish between 32 Bit Int and 32 Bit Float which could mean a more robust parameter coming in from the node side or a new implementation of enums here that map to a wider range of PaSampleFormat enums.


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.