engineerchuan
engineerchuan

Reputation: 2708

Is there any way to feed a file to a MediaSource Analyser Node

I'd like to test whether some FFT analysis code I am writing in Python is exactly the same implementation as the Javascript MediaSource FFT node. (See example here Web Audio API Analyser Node Not Working With Microphone Input).

I have read the specs but I'd prefer to do a test. I want to push the same exact snippet of audio through both, and then get the output and do a diff.

Is there anyway to hook up Javascript to a local file instead of a microphone? likely WAV format 48kHz

Upvotes: 1

Views: 184

Answers (1)

Brad
Brad

Reputation: 163262

Yes.

  1. Create an AudioElement.
  2. Set the src property to the blob URL for your MediaSource.
  3. Create a new MediaElementAudioSourceNode, with the AudioElement.
  4. Connect that node to your AnalyserNode.
  5. Make sure the AnalyserNode is connected to some output, even if muted by way of GainNode.

Upvotes: 1

Related Questions