jussi-kalliokoski / audiolib.js

audiolib.js is a powerful audio tools library for javascript.
http://audiolibjs.org/
672 stars 58 forks source link

Sampler.loadWav performance #41

Closed kindohm closed 12 years ago

kindohm commented 12 years ago

I'm seeing some very slow load times when Sampler.loadWav is called on larger wave file samples. In my specific case I have 2-channel 44.1khz samples ranging from 128 KB in size to 844 KB. The 128kb sample takes about 4-5 seconds to load during loadWav(). My 844kb sample takes a very long time - more than a minute at least. Are the included codecs just not capable of dealing with larger samples?

jussi-kalliokoski commented 12 years ago

Yeah, the problem here is the memory speed in JS, a huge amount of time is spent just allocating the buffers (especially for the strings that contain the data). All of the loading should be done asynchronously with XHR, and then the sampler should stream through multiple buffers instead of one big buffer, similarly to how we have done the JS codecs (mp3 alac flac). This would, however, require more advanced SRC features, etc, so it will take some time, but it's on the plan to make it possible to use our codec suite, aurora.js alongside with audiolib.js, so you can load even big samples and in the format you prefer.

jussi-kalliokoski commented 12 years ago

So far, on Chrome, the problem is even more escalated, if you try to load a sample too big, the page just freezes.

kindohm commented 12 years ago

Ok - thanks for the feedback. I figured that that was the case.