How do I handle heavy load of sound using JavaScript / HTML5?

I am creating a small sequencer like this one , but I want to use only HTML / JavaScript (i.e. no Flash).

When you play with the applet in the link above, you will notice that several sounds can play simultaneously and / or quickly. I use an array of audio objects that mimic different β€œslots” or channels to achieve the desired polyphony, and as a concept, this works. I do not experience any trim or cut in my audio.

However, this process becomes excessively resource intensive very quickly, regardless of the original file / compression type. It is not uncommon for the web browser itself to crash as the number of sounds increases.

So, I wonder: What, if any, is the best way to facilitate a rather heavy download of audio without strangling the browser? Or, trying to get HTML / JS to work for this purpose - a crazy errand?

Any insight would be greatly appreciated. Here is the silent version.

+4
source share
1 answer

I can’t say it myself, but here are some examples using the new web audio api. http://chromium.googlecode.com/svn/trunk/samples/audio/index.html However, the drum machine is quite taxable. In any case, I suppose you would be interested in the link.

+1
source

Source: https://habr.com/ru/post/1387312/


All Articles