meldron / node-alsa-capture Goto Github PK
View Code? Open in Web Editor NEWNode.js module to capture PCM data with ALSA.
Home Page: https://www.npmjs.com/package/alsa-capture
License: MIT License
Node.js module to capture PCM data with ALSA.
Home Page: https://www.npmjs.com/package/alsa-capture
License: MIT License
Hello,
I get errors using DietPi v8.10.2.
node was installed by the software selection of dietpi.
Help would be much appreciated :-)
Thanks
pi@dietPi:~/rr$ uname -a
Linux dietPi 5.15.61-v8+ #1579 SMP PREEMPT Fri Aug 26 11:16:44 BST 2022 **aarch64** GNU/Linux
pi@dietPi:~/rr$ node -v
v19.0.0
pi@dietPi:~/rr$ npm -v
8.19.2
pi@dietPi:~/rr$ apt-cache policy libasound2
libasound2:
Installed: 1.2.4-1.1+rpt2
Candidate: 1.2.4-1.1+rpt2
Version table:
*** 1.2.4-1.1+rpt2 500
500 https://archive.raspberrypi.org/debian bullseye/main arm64 Packages
100 /var/lib/dpkg/status
1.2.4-1.1 500
500 https://deb.debian.org/debian bullseye/main arm64 Packages
pi@dietPi:~/rr$ apt-cache policy libasound2-dev
libasound2-dev:
Installed: 1.2.4-1.1+rpt2
Candidate: 1.2.4-1.1+rpt2
Version table:
*** 1.2.4-1.1+rpt2 500
500 https://archive.raspberrypi.org/debian bullseye/main arm64 Packages
100 /var/lib/dpkg/status
1.2.4-1.1 500
500 https://deb.debian.org/debian bullseye/main arm64 Packages
pi@dietPi:~/rr$ npm install alsa-capture --save
npm ERR! code 1
npm ERR! path /home/pi/rr/node_modules/alsa-capture
npm ERR! command failed
npm ERR! command sh -c -- node-gyp rebuild
npm ERR! make: Entering directory '/home/pi/rr/node_modules/alsa-capture/build'
npm ERR! CXX(target) Release/obj.target/capture/capture.o
npm ERR! make: Leaving directory '/home/pi/rr/node_modules/alsa-capture/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | arm64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/pi/rr/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/pi/rr/node_modules/alsa-capture/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/pi/rr/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/pi/.cache/node-gyp/19.0.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/pi/.cache/node-gyp/19.0.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/pi/rr/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/pi/.cache/node-gyp/19.0.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/pi/rr/node_modules/alsa-capture',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from /home/pi/.cache/node-gyp/19.0.0/include/node/v8-object.h:9,
npm ERR! from /home/pi/.cache/node-gyp/19.0.0/include/node/v8-array-buffer.h:13,
npm ERR! from /home/pi/.cache/node-gyp/19.0.0/include/node/v8.h:24,
npm ERR! from /home/pi/.cache/node-gyp/19.0.0/include/node/node.h:73,
npm ERR! from ../../nan/nan.h:60,
npm ERR! from ../capture.cc:13:
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:106:45: error: ‘is_lvalue_reference_v’ is not a member of ‘std’; did you mean ‘is_lvalue_reference’?
npm ERR! 106 | template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
npm ERR! | ^~~~~~~~~~~~~~~~~~~~~
npm ERR! | is_lvalue_reference
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:106:66: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
npm ERR! 106 | template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
npm ERR! | ^
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:106:67: error: template argument 1 is invalid
npm ERR! 106 | template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
npm ERR! | ^
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:106:71: error: expected unqualified-id before ‘>’ token
npm ERR! 106 | template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
npm ERR! | ^
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:123:43: error: ‘is_lvalue_reference_v’ is not a member of ‘std’; did you mean ‘is_lvalue_reference’?
npm ERR! 123 | template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
npm ERR! | ^~~~~~~~~~~~~~~~~~~~~
npm ERR! | is_lvalue_reference
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:123:64: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
npm ERR! 123 | template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
npm ERR! | ^
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:123:65: error: template argument 1 is invalid
npm ERR! 123 | template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
npm ERR! | ^
npm ERR! /home/pi/.cache/node-gyp/19.0.0/include/node/v8-maybe.h:123:70: error: expected unqualified-id before ‘=’ token
npm ERR! 123 | template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
npm ERR! | ^
npm ERR! make: *** [capture.target.mk:117: Release/obj.target/capture/capture.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/home/pi/rr/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Linux 5.15.61-v8+
npm ERR! gyp ERR! command "/usr/local/bin/node" "/home/pi/rr/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/pi/rr/node_modules/alsa-capture
npm ERR! gyp ERR! node -v v19.0.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2022-10-25T10_27_04_769Z-debug-0.log
pi@dietPi:~/rr$
Hi,
Is it possible to retrive specific channel data from the buffer that store the data of 'audio' event of alsa-capture?
Node 14.x and 15.x emit the following compiler warning:
In file included from ../node_modules/nan/nan.h:56,
from ../capture.cc:10:
/home/runner/.cache/node-gyp/15.11.0/include/node/node.h:838:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
838 | (node::addon_register_func) (regfunc), \
| ^
/home/runner/.cache/node-gyp/15.11.0/include/node/node.h:872:3: note: in expansion of macro ‘NODE_MODULE_X’
872 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
| ^~~~~~~~~~~~~
../capture.cc:459:1: note: in expansion of macro ‘NODE_MODULE’
459 | NODE_MODULE(capture, StreamWorkerWrapper::Init)
| ^~~~~~~~~~~
SOLINK_MODULE(target) Release/obj.target/capture.node
COPY Release/capture.node
Hi Meldorn,
I currently use the USB soundinterface: Behringer U-Phono UFO202.
If I try to open it with sample rate 44100 I get a 'rateDeviating' event telling me 48000 is used and I don't understand why.
My guess it you fall back to 'Altset 1' instead of using 'Altset 3' that offers 44100.
Help would be appreciated.
Best DrCWO
arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: CODEC [USB Audio CODEC], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
cat /proc/asound/card1/stream0
Burr-Brown from TI USB Audio CODEC at usb-0000:01:00.0-1.3, full speed : USB Audio
Playback:
Status: Stop
Interface 1
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 2 OUT (ADAPTIVE)
Rates: 32000, 44100, 48000
Bits: 16
Channel map: FL FR
Interface 1
Altset 2
Format: S16_LE
Channels: 1
Endpoint: 2 OUT (ADAPTIVE)
Rates: 32000, 44100, 48000
Bits: 16
Channel map: MONO
Interface 1
Altset 3
Format: S8
Channels: 2
Endpoint: 2 OUT (ADAPTIVE)
Rates: 32000, 44100, 48000
Bits: 8
Channel map: FL FR
Interface 1
Altset 4
Format: S8
Channels: 1
Endpoint: 2 OUT (ADAPTIVE)
Rates: 32000, 44100, 48000
Bits: 8
Channel map: MONO
Interface 1
Altset 5
Format: U8
Channels: 2
Endpoint: 2 OUT (ADAPTIVE)
Rates: 32000, 44100, 48000
Bits: 8
Channel map: FL FR
Interface 1
Altset 6
Format: U8
Channels: 1
Endpoint: 2 OUT (ADAPTIVE)
Rates: 32000, 44100, 48000
Bits: 8
Channel map: MONO
Capture:
Status: Stop
Interface 2
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 4 IN (ASYNC)
Rates: 48000
Bits: 16
Channel map: FL FR
Interface 2
Altset 2
Format: S16_LE
Channels: 1
Endpoint: 4 IN (ASYNC)
Rates: 48000
Bits: 16
Channel map: MONO
Interface 2
Altset 3
Format: S16_LE
Channels: 2
Endpoint: 4 IN (ASYNC)
Rates: 44100
Bits: 16
Channel map: FL FR
Interface 2
Altset 4
Format: S16_LE
Channels: 1
Endpoint: 4 IN (ASYNC)
Rates: 44100
Bits: 16
Channel map: MONO
Interface 2
Altset 5
Format: S16_LE
Channels: 2
Endpoint: 4 IN (ASYNC)
Rates: 32000
Bits: 16
Channel map: FL FR
Interface 2
Altset 6
Format: S16_LE
Channels: 1
Endpoint: 4 IN (ASYNC)
Rates: 32000
Bits: 16
Channel map: MONO
Interface 2
Altset 7
Format: S16_LE
Channels: 2
Endpoint: 4 IN (ASYNC)
Rates: 22050
Bits: 16
Channel map: FL FR
Interface 2
Altset 8
Format: S16_LE
Channels: 1
Endpoint: 4 IN (ASYNC)
Rates: 22050
Bits: 16
Channel map: MONO
Interface 2
Altset 9
Format: S16_LE
Channels: 2
Endpoint: 4 IN (ASYNC)
Rates: 16000
Bits: 16
Channel map: FL FR
Interface 2
Altset 10
Format: S16_LE
Channels: 1
Endpoint: 4 IN (ASYNC)
Rates: 16000
Bits: 16
Channel map: MONO
Interface 2
Altset 11
Format: S8
Channels: 2
Endpoint: 4 IN (ASYNC)
Rates: 16000
Bits: 8
Channel map: FL FR
Interface 2
Altset 12
Format: S8
Channels: 1
Endpoint: 4 IN (ASYNC)
Rates: 16000
Bits: 8
Channel map: MONO
Interface 2
Altset 13
Format: S8
Channels: 2
Endpoint: 4 IN (ASYNC)
Rates: 8000
Bits: 8
Channel map: FL FR
Interface 2
Altset 14
Format: S8
Channels: 1
Endpoint: 4 IN (ASYNC)
Rates: 8000
Bits: 8
Channel map: MONO
Interface 2
Altset 15
Format: S16_LE
Channels: 2
Endpoint: 4 IN (SYNC)
Rates: 11025
Bits: 16
Channel map: FL FR
Interface 2
Altset 16
Format: S16_LE
Channels: 1
Endpoint: 4 IN (SYNC)
Rates: 11025
Bits: 16
Channel map: MONO
Interface 2
Altset 17
Format: S8
Channels: 2
Endpoint: 4 IN (SYNC)
Rates: 11025
Bits: 8
Channel map: FL FR
Interface 2
Altset 18
Format: S8
Channels: 1
Endpoint: 4 IN (SYNC)
Rates: 11025
Bits: 8
Channel map: MONO
Some dependencies are out of date and need to be updated.
Hi,
I tried to setup 8 captures at the same time.
It look the maximum 4 instance can be initialized.
Hello,
the Capture is limited to 192kHz for what reason I don't know.
I just hacked the binary caputure.node. Afer that it runs with 384kHz without any problems.
Would you please change the line
if (!rate_okay || (rate < 4000 || rate > 196000))
to
if (!rate_okay || (rate < 4000 || rate > 384000))
and publish a new release.
Thanks DrCWO
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.