Streampunk / naudiodon

Node.js stream bindings for PortAudio
Apache License 2.0
294 stars 80 forks source link

naudiodon <=> web audio api via electron? #66

Closed marcelblum closed 3 years ago

marcelblum commented 3 years ago

Is it possible to pipe audio generated in realtime by the web audio api in an Electron app to naudiodon with minimal latency? I imagine it can be done with maximal latency by using createMediaStreamDestination and MediaRecorder to write the web audio api output to an intermediary file which is then piped to a naudiodon instance. But is there a better more direct way to pipe raw audio data from a MediaStream into naudiodon? How are folks using this lib in Electron?

LuvbCa commented 3 years ago

i was wondering that too

marcelblum commented 3 years ago

In case anyone comes across this I wanted to post the results of my r&d. The best way to get Web Audio raw PCM output buffers in realtime seems to be via an audioWorklet, which is actually a pretty simple low latency method and no need to mess with MediaStreams at all. In Electron you can call Node modules directly from within worklets as long as nodeIntegrationInWorker is true so all the audio routing work can be done on its own thread if you want to use something like naudiodon.