katspaugh/wavesurfer.js — pull request #192 by jlegoff (2014-05-14 08:41:42+00:00)
Title: AudioTag backend.

Hi,

First, thanks for your project! It works really well and the code is clear and easy to modify.

So I've been tinkering with it in order to be able to load large audio files (>1 hour), which didn't work for me. I'm aware of the streaming mode, but I want the wave to be drawn straight away. The only solution I've found is to get my server to compute them and send them to wavesurfer.

So I did two things:

1. add a new parameter 'getPeaks', which is a function that gets called instead of backend.getPeaks if provided

2. add a new backend which does not make use of the webaudio api. It just adds an audio tag, just like loadStream does. This allows me to make the waveform compatible with browsers which don't support the web api.

This is a work in progress and not very well tested. I wanted to let you know about it in case you think this might interest other people.

A couple of comments:

At some point I started moving the downloadArrayBuffer and loadArrayBuffer into the WebAudio backend. My goal was to be able to do something like:

```
var params = {
backend: "AudioTag",
getPeaks: getPeaks
};

wave.load(url); // don't download the file via ajax and don't decode it

var params = {
backend: "WebAudio"
};

wave.load(url); // use the WebAudio backend just like now
```
but then I realized I'd broken the loadBlob function. I could have fixed it but I prefered dropping you a word in order to know what your take is on this. Right now my feeling is that websurfer.js is too aware of the stream handling and that this could be delegated to the backend (or something else).

I also don't like passing in a function in the parameters, but this was the easiest way of getting it to work for me.

So there you go, sorry for the long comment :-)