0

我正在尝试对在我的计算机上运行的可视化器进行一些音频分析。

是否可以直接从浏览器访问输出音频数据流?

当前使用three.js 和meyda 库运行JavaScript。

我已经弄清楚如何使用 webAudio API 来分析来自麦克风的输入,但似乎无法访问我计算机上的音频输出。

我尝试使用将源连接到目标

source.connect(audioContext.destination) 

但这似乎无济于事。

这是我们当前的监听器配置:

// // Listener
const bufferSize = 256;
let analyzer;

// The navigator object contains information about the browser.
// this async call initializes audio input from the user
navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(stream => {
  if (!analyzer) initAnalyzer(stream)
})


function initAnalyzer(stream) {
  const audioContext = new AudioContext();
  // set audio source to input stream from microphone (Web Audio API https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamAudioSourceNode)
  const source = audioContext.createMediaStreamSource(stream);

  analyzer = Meyda.createMeydaAnalyzer({
    audioContext: audioContext,
    source: source,
    bufferSize: bufferSize,
    featureExtractors: [ 'amplitudeSpectrum', 'spectralFlatness' ], // ["rms", "energy"],
    callback: features => null
  });
  analyzer.start();
}
4

2 回答 2

0

如果没有 Audio Hijack 等外部软件,就无法从计算机中获取音频。对不起!

于 2020-03-22T23:38:31.227 回答
0

出于隐私考虑,无法访问音频输出,只能访问音频输入(并且只有在与用户确认后)。在 Windows 上,您可以启用将所有输出路由到虚拟输入的“立体声混音”,您可以使用它,但它要求所有用户都启用立体声混音...

您看到的可视化工具正在使用他们创建的缓冲区或源,因此他们当然可以访问它。

于 2022-02-02T21:54:29.473 回答