Read samples from wav-file

前端 未结 1 1044
遇见更好的自我
遇见更好的自我 2021-01-02 05:56

I\'m trying to make a webpage in html5 which stores sample-data from a wav-file in an array. Is there any way to get the sample-data with javascript? I\'m using a file-input

相关标签:
1条回答
  • 2021-01-02 06:44

    You'll need to learn a lot about Web APIs to accomplish that, but in the end it's quite simple.

    1. Get the file contents in an ArrayBuffer with the File API
    2. Pass it to the Web Audio API's decodeAudioData method.
    3. Get a typed ArrayBuffer with the raw samples you wanted.

    Edit: If you want to implement an equalizer, you're wasting your time, there's a native equalizer node in the Audio API. Depending on the length of your wave file it might be better not to load it all in memory and instead to just create a source that reads from it and connect that source to an equalizer node.

    0 讨论(0)
提交回复
热议问题