node-web-audio-api icon indicating copy to clipboard operation
node-web-audio-api copied to clipboard

Error: error while querying device output config: DeviceNotAvailable

Open AAAkater opened this issue 10 months ago • 4 comments

When I run this command in wsl2 arch

node examples/granular-scrub.js

The following error occurred

ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5205:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5205:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5205:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5728:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM default

node:internal/modules/run_main:122
    triggerUncaughtException(
    ^
Error: error while querying device output config: DeviceNotAvailable
    at file:///home/ym/code/ts/node-web-audio-api/examples/granular-scrub.js:7:22
    at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)

Node.js v22.13.0

Is it currently not supported on arch ?

AAAkater avatar Feb 03 '25 08:02 AAAkater

The ALSA audio driver reports it cannot find an audio device to play the output to. Are you able to play sounds in wsl2 via any other terminal command?

orottier avatar Feb 03 '25 09:02 orottier

set {sinkId:{type:'none'}} if you don't need the playback, see https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/AudioContext#sinkid

might be worth adding it to the readme, could a common use case (at least I've been stuck with it for a while running audio analysis under docker with no audio sinks)

qwelias avatar Apr 10 '25 15:04 qwelias

The webaudio backend could probably do a bit better than throwing this uncaught error. I should read up on the recent onerror spec addition. Perhaps in case of these exceptions, the audio context should run as if a none sinkId was provided

orottier avatar Apr 10 '25 15:04 orottier

Hey,

Perhaps in case of these exceptions, the audio context should run as if a none sinkId was provided

Not sure about that, it could be terrible to debug (in the reverse way) if you want to do regular audio, have no sound card for some reason and nothing happens... In my opinion a more readable error would the best way to go

might be worth adding it to the readme, could a common use case (at least I've been stuck with it for a while running audio analysis under docker with no audio sinks)

Not sure how to phrase that on my side, this is not a use-case I'm used to... If you have any idea, this is welcome (maybe under a "recipes" header)?

b-ma avatar Apr 10 '25 16:04 b-ma