【问题标题】:Can I access the local audio output stream from Chrome using the webAudio API?我可以使用 webAudio API 从 Chrome 访问本地音频输出流吗?
【发布时间】:2022-02-03 05:54:29
【问题描述】:

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

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

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

我已经知道如何使用 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();
}

【问题讨论】:

    标签: javascript audio web-audio-api audio-analysis


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多