Currently, I am working on audio analysis for a visualizer application running on my computer.
I am wondering if there is a way to directly access the output audio data stream from the browser?
For this project, I am using JavaScript along with the three.js and meyda libraries.
Although I have successfully used the webAudio API to analyze microphone input, I am struggling to access the audio output from my computer.
I attempted to connect the source to the destination like this:
source.connect(audioContext.destination)
Unfortunately, this method doesn't seem to have any effect.
Here is the current listener configuration:
// // Listener
const bufferSize = 256;
let analyzer;
// The navigator object provides browser information.
// This asynchronous call initializes user audio input.
navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(stream => {
if (!analyzer) initAnalyzer(stream)
})
function initAnalyzer(stream) {
const audioContext = new AudioContext();
// Set the audio source to the input stream from the 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();
}