Reputation: 1137
I know that I can collect Audio Data of an currently played audio with getByteFrequenzyData()
and I'll get back an Uint8Array
.
Now I collect all data of one Audio File by pushing each animationFrame
the currently data in an Array, do for example:
I have a audio file with duration of 20min. Then I have after 20min all Audio data in one Array, which then looks kind a like this:
var data = [Uint8Array[1024], Uint8Array[1024], Uint8Array[1024], Uint8Array[1024], ... ];
Is there a faster way to get all these audio data, so I don't have to wait the full 20 minutes of the video, and get the audio data nearly instant?
It would be good to receive the audio information in fixed steps for, like 50ms or so!
Upvotes: 1
Views: 107
Reputation: 6056
Instead of using an AudioContext, use an OfflineAudioContext to process the data. This can run much faster than real time. To get consistent data at well defined times, you'll also need to use a browser that implements the recently added suspend and resume feature for offline contexts so that you can sample the data for getByteFrequencyData at well-defined time intervals.
Upvotes: 2