I am working with audio files where in I upload and each time the audio file is fetched from the server it is represented in the UI with functionality to play/pause etc. I am working with .wav/.mp3 files of duration close to about an hour.
The library I am using for displaying the waveform loads the entire audio file at once into an audioBuffer
so streaming is out of option.
I am trying to find a way to cache the audioBuffer
in order to skip the decodeAudioData()
step entirely.
What I am currently doing is store the Float32Array
representation using audioBuffer.getChannelData(0)
method and convert back to audioBuffer
(which almost takes the same amount of time) and using localforage
to use indexedDB to set and get, but it has it's limitations and cannot store the Float32Array
for large mp3 files (1hr ~ file size of about 86-100mb)
I cannot direclty store audioBuffers
in indexedDB due to incompatibility of indexedDB to store such formats.
I need a way to skip the decodeAudioData()
step and directly consume the audioBuffer
of the files already loaded once.