How to get sample rate, bit depth, and number of channels with Web Audio API?

Viewed 389

I am wondering how I can get the following audio metadata after uploading a file and embedding within <audio> tag.

  • Sample rate
  • Bit depth
  • Number of channels

Is this possible with Web Audio API? Or do I need to parse the binary data of each audio file?

2 Answers

After researching this, I could not find a currently-available API for obtaining the metadata without manually parsing the binary file headers. I opened Git issue WebCodecs #411 with the WebCodecs team. WebCodecs is a new API that could potentially offer this metadata viewing feature.

Have you checked out music-metadata? It appears to support parsing all of the metadata mentioned above and supports quite a few formats.

Related