Wavesurfer.js: Pre-generated json peaks array not loading

Created on 8 May 2016  路  10Comments  路  Source: katspaugh/wavesurfer.js

Hi,

I'm trying out your library to replace my own homegrown player based on audiowaveform. Upon upload, I'm generating json via audiowaveform so that I can pre-load the peaks in your player. Unfortunately, wavesurfer doesn't seem to like the json array range generated by audiowaveform (or more likely, I'm doing something boneheaded).

The generated json looks like this (snip):
[0,0,-12,7,-12,8,-14,15,-16,10,-11,13,-15,11, ... ]
Here's a test page with the array loaded at runtime

http://www.internetdj.com/test.html

Any tips? Many thanks in advanced.

Michael

bug

Most helpful comment

The problem was with the negative values generated by audiowaveform. I simply stripped them out of my peaks array and now we're in business.

Here's an example of wavesurfer in production:

http://www.internetdj.com/song/118198

All 10 comments

The problem was with the negative values generated by audiowaveform. I simply stripped them out of my peaks array and now we're in business.

Here's an example of wavesurfer in production:

http://www.internetdj.com/song/118198

Great that you figured it out. I actually thought negative peaks were not a problem. I'll mark this as a bug to add a Math.abs to the drawing code.

Thanks for the confirmation. Love this library!

Having a unit test for this would be nice!

@mbordash how are you making to draw waveform with json data can you share some code ?

Perhaps something like audiowaveform -i some-file.mp3 --pixels-per-second 10 -b 8 -o some-file.json.

@katspaugh Yeah i find it and i got file like this http://collabshot.com/show/0T3kzy but when I am loading it with wavesurfer I think it creates incorrectly, see : http://collabshot.com/show/CovV4L

wavesurfer.load('fifties_rock.mp3', result);
I tried also :
wavesurfer.load('fifties_rock.mp3', result.data);

@btomashvili I guess you also need to filter out negative values like the OP did.
result.data.filter(function (val) { return val >= 0; })

Oh yeah, and you need the normalize: true option.

thanks ;)

Closing: inactive

Was this page helpful?
0 / 5 - 0 ratings