我正在尝试对计算机上运行的可视化器进行一些音频分析。
是否可以直接从浏览器访问输出音频数据流?
当前正在运行带有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();
}
最佳答案
如果没有Audio Hijack之类的外部软件,则无法从计算机中获取音频。抱歉!
关于javascript - 我可以使用webAudio API从Chrome访问本地音频输出流吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58016209/